Lecture13 - Graphical User Interfaces AWT and Swing...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Graphical Applications The example programs we've explored thus far have been text-based command-line applications , which interact with the user using text prompts Let's examine some Java applications that have graphical components These components will serve as a foundation to programs with true graphical user interfaces (GUIs) We will start with generating a frame with panels containing text “labels” or images
Background image of page 2
3 Graphical Applications GUI-related classes are defined primarily in java.awt and javax.swing packages The Abstract Windowing Toolkit (AWT) was the original Java GUI package The Swing package provides additional and more versatile components Sometimes called Java Foundation Classes (mimicking Microsoft Foundation Classes)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 GUI Containers - Frame A GUI container is a component that is used to hold and organize other components JFrame, JDialog, and JApplet are the three top level containers that are used to display graphics in GUI applications We will work only with JFrame for now A JFrame is displayed as a separate window with a title bar – it can be repositioned and resized on the screen as needed
Background image of page 4
5 Frame-based Hello World JFrame frame attribute title JFrame frame JLabel label JFrame frame width = 300 JFrame frame height = 200
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Frame-based Hello World import javax.swing.*; // Get JFrame and JLabel classes public class HelloWorld { public static void main(String[] args) { //Create and set up the window. JFrame frame = new JFrame("HelloWorld Using Swing");
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/25/2010 for the course CS 110 taught by Professor Wilson during the Spring '10 term at University of Massachusetts Boston.

Page1 / 21

Lecture13 - Graphical User Interfaces AWT and Swing...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online