Gui Programming II Components
Gui Programming II Components
Lecture 23
1
Previously
• Hello World as GUI
• Layout Design
• Criteria In GUI
• Human Interface Concepts
• Requirements
Add record
View record
•
actor
Design GUI actor Delete record
java.awt
Component
Abstract Window Toolkit
Container (AWT)
JComponent javax.swing
• JMenu • JLabel
• JMenuItem Fix text on the display
• JTextField • JDialog Data was saved.
Application title
• JTabbedPane
Tab 1 Tab 2
Panel
Tab 3
• JTabel
• JTextArea
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true); // show the GUI
} // Constructor ()
} // end class HelloWorldGUI
Amadeo Ascó , Adam Moore 8
Swing Components
• Extend JFrame to get the general look of a GUI
• JLabel corresponds to fix text to add to the GUI
public class HelloWorldGUI extends JFrame {
... Hello World
height
HelloWorldGUI() {
super("Hello World"); // the title
JLabel jlbHelloWorld = new JLabel(" Hello World!"); width
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true); // show the GUI
} // Constructor ()
} // end class HelloWorldGUI Amadeo Ascó , Adam Moore 9
Swing Components
• Creating and Showing Simple Dialogs
– It is a accomplished by using the class JDialog
– Different ones depending of the message to display
– Default title and icon
JOptionPane.showMessageDialog(frame, Data was saved.
Java API
http://download.oracle.com/javase/6/docs/api/