70 likes | 201 Views
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010. Graphical User Interface (GUI) Design using Swing. “pixel, n.: A mischievous, magical spirit associated with screen displays.”
E N D
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Graphical User Interface (GUI) Design using Swing “pixel, n.: A mischievous, magical spirit associated with screen displays.” --Jeff Meyer Course Lecture Slides9 June 2010 GaneshViswanathan
Swing • A visual guide to swing components:
Swing - Hello World Example • /*Hello World example*/ • import javax.swing.*; • public class Swing1 { • private static void createAndDisplayFrame() { • //Create and set up the frame. • JFrame frame = new JFrame("Swing Example 1"); • frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); • //Add label "Hello World" • JLabel label = new JLabel("Hello World!"); • frame.getContentPane().add(label); • //Display the frame. • frame.pack(); • frame.setVisible(true); • }
Swing - Hello World Example • /*Hello World example - contd.*/ • public static void main(String[] args) { • SwingUtilities.invokeLater(new Runnable() { • public void run() { • createAndDisplayFrame(); • } • }); • } • }
Get more info! • Oracle’s Swing Tutorial: • http://download-llnw.oracle.com/javase/tutorial/uiswing/index.html • Walter Milner’s Java Swing tutorial : • http://www.waltermilner.com/downloads/JavaSwing/ • Java docs: Swing Class Hierarchy • http://download-llnw.oracle.com/javase/1.5.0/docs/api/javax/swing/package-tree.html