四叫川学国家性 GINEEHING OahGE Object-Oriented Design and Programming Java)
Object-Oriented Design and Programming (Java)
Topics Covered Today 3.2 Graphical User Interface 3.2. 1 Swing Components and Containers 3.2.2 Swing Event Handling
2 Topics Covered Today • 3.2 Graphical User Interface – 3.2.1 Swing Components and Containers – 3.2.2 Swing Event Handling
GUI libraries in java Abstract Windows Toolkit(AWT) since Java 1.0 Swing- Add-on since Java 1. I and integral part of Java 1.2 Third party GUI libraries like the Standard Windows Toolkit(SWT)e.g. used in eclipse Here, we use Swing
3 GUI libraries in JAVA • Abstract Windows Toolkit (AWT) since Java 1.0 • Swing - Add-on since Java 1.1 and integral part of Java 1.2 • Third party GUI libraries like the Standard Windows Toolkit (SWT) e.g. used in Eclipse Here, we use Swing!
Swing is Standard in Java 2 Platform (also known as JDK 1.2 Includes java2D Adds support for MIDi, Wav, and other audio Swing package: javax. swing. awt package: java. awt. x
4 Swing is Standard in Java 2 Platform (also known as JDK 1.2) • Includes Java2D • Adds support for MIDI, WAV, and other audio. • Swing package: javax.swing.* AWT package: java.awt.*
Reference book Thinking in Java (2nd Edition), bruce Eckel. prentice hall Chapter l3 Creating windows applets Getting Started with Swing http://java.sun.com/docs/books/tutorial/uiswing/
5 Reference Book • Thinking in Java (2nd Edition), Bruce Eckel, Prentice Hall Chapter 13 Creating Windows & Applets • Getting Started with Swing http://java.sun.com/docs/books/tutorial/uiswing/
New Features in Swing Lightweight. Not built on native window-system windows Much bigger set of built-in controls. Trees, image buttons tabbed panes, sliders, toolbars, color choosers tables etc Much more customizable(可定制) Can change border, text alignment, or add image to almost any control
6 New Features in Swing • Lightweight. Not built on native window-system windows. • Much bigger set of built-in controls. Trees, image buttons, tabbed panes, sliders, toolbars, color choosers, tables, etc. • Much more customizable(可定制). Can change border, text alignment, or add image to almost any control
New Features in Swing Pluggable" look and feel. Can change look and feel at runtime or design own look and feel Many miscellaneous new features. Double buffering built in, tool tips, keyboard accelerators custom cursors. etc
7 New Features in Swing • Pluggable" look and feel. Can change look and feel at runtime, or design own look and feel. • Many miscellaneous new features. Doublebuffering built in, tool tips, keyboard accelerators, custom cursors, etc
AWT Components primitive r- Component Button Container \container canvas Checkbox Panel window 「 Choice Label Frame Dialog List Scrollbar ile Dialog Textcomponent javaaPplet Applet Textarea TextField
8 AWT Components primitive container
Swing Components JComponent」 JButton 恒E烈 儿 Sahel JPanel COmbo口x CHeckbOx H □ JApplet]翻頵癜鼬H JList JScrollbar Jframe JDialog JTextcomponent卜 Jwindow 「 JTextField「 JTextArea
9 Swing Components
Frame a Frame is a top -level window with a title and a border java. lang Object +----iavaawt component java. awt Container +-<-java awt window +----java awt Frame
10 Frame • A Frame is a top-level window with a title and a border