中国高校课件下载中心 》 教学资源 》 大学文库

内蒙古科技大学:《Java编程》课程教学课件(PPT讲稿)第8章 图形用户界面

文档信息
资源类别:文库
文档格式:PPT
文档页数:66
文件大小:1.73MB
团购合买:点击进入团购
内容简介
内蒙古科技大学:《Java编程》课程教学课件(PPT讲稿)第8章 图形用户界面
刷新页面文档预览

第8章图形用户界面 GUI基础

第8章 图形用户界面 ——GUI 基础

8.1文件类File 8.2运用try、catch、finally处理异常 8.3运用throw抛出异常 8.4运用throws声明异常

8.1 文件类File 8.2 运用 try 、catch 、 finally 处理异常 8.3 运用 throw 抛出异常 8.4 运用 throws 声明异常

Motivations 本章介绍Java GUI程序设计的基础知识

Motivations 本章介绍 Java GUI 程序设计的基础知识

Creating GUI Objects /Create a button with text OK JButton jbtoK new JButton ("OK"); /Create a label with text "Enter your name: JLabel jlblName new JLabel("Enter your name:") Display GUI Components -▣x OK Enter your name:Type Name HereBold RedRed Red Green Blue /Create a text field with text "Type Name Here" JTextField jtfName new JTextField("Type Name Here"); /Create a check box with text bold JCheckBox jchkBold new JCheckBox("Bold"); /Create a radio button with text red JRadioButton jrbRed new JRadioButton("Red"); /Create a combo box with choices red,green,and blue JComboBox jcboColor new JComboBox(new String[]{"Red", "Green","Blue"});

Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your name: " JLabel jlblName = new JLabel("Enter your name: "); // Create a text field with text "Type Name Here" JTextField jtfName = new JTextField("Type Name Here"); // Create a check box with text bold JCheckBox jchkBold = new JCheckBox("Bold"); // Create a radio button with text red JRadioButton jrbRed = new JRadioButton("Red"); // Create a combo box with choices red, green, and blue JComboBox jcboColor = new JComboBox(new String[]{"Red", "Green", "Blue"}); Button Label Text field Check Box Radio Button Combo Box

Swing vs.AWT GUI API包含的类可以分成三个组:组件类( component class.)、容器类(container class)和 辅助类(helper class)

Swing vs. AWT GUI API包含的类可以分成三个组:组件类( component class)、容器类(container class)和 辅助类(helper class)

GUI Class Hierarchy (Swing) 4444444444444440444444 4444 44444444444 Dimension Classes in the java awt LayoutManager package Heavyweight Font FontMetrics Object Color Panel Applet JApplet Graphics Component Container Window Frame JFrame Dialog JDialog JComponen Swing GU阻件, Swing Components 例如:JButton、 in the javax.swing package JLabel、 444 JTextField Lightweight 轻量级

GUI Class Hierarchy (Swing) Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Dialog Window JComponent JApplet JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager * 轻量级 Swing GUI组件, 例如:JButton、 JLabel、 JTextField

J Test.java 1eimport java.awt.*: 2 import javax.swing.*: 3 public class Test 4日 public static void main(String[]args) JButton jbtoK=new JButton("OK"); System.out.println(jbtOk instanceof JButton); 2 System.out.println(jbtOK instanceof JComponent); 8 System.out.println(jbtoK instanceof Container): System.out.println(jbtoK instanceof Component); 10 System.out.println(jbtok instanceof Object); 11 12 13 貝Console3 Test [Java Application]C:(Program Files\Genui true true true true true

instanceof运算符判断一个对象是否目标类的实例

instanceof 运算符判断一个对象是否目标类的实例

Container Classes Dimension Classes in the java awt LayoutManager package Heavyweight Font 1 FontMetrics Object Color Panel Applet JApplet Graphics Component Container Window Frame JFrame Dialog JDialog 容器类是用于容纳其它组 JComponent JPanel Swing Components in the javax.swing package 件的组件。 Lightweight

Container Classes Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Dialog Window JComponent JApplet JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager * JPanel 容器类是用于容纳其它组 件的组件

Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied.In the chapters that follow,you will learn the framework of Java GUI API and use the GUI components to develop user-friendly interfaces for applications and applets

Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the framework of Java GUI API and use the GUI components to develop user-friendly interfaces for applications and applets

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档