ch13 (1)

ch13 (1) - Java Programming Fourth Edition Chapter 13...

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

View Full Document Right Arrow Icon
Java Programming Fourth Edition Chapter 13 Understanding Swing Components
Background image of page 1

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 2 Objectives • Use the JFrame class • Customize a JFrame 's appearance • Extend the JFrame class • Use the JPanel class • Understand Swing event listeners
Background image of page 2
Java Programming, Fourth Edition 3 Objectives (continued) • Use the JCheckBox class • Use the ButtonGroup class • Use the JComboBox class • Create JScrollPanes • Learn when to use getContentPane()
Background image of page 3

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 4 Using the JFrame Class • Swing component – Descendant of JComponent – Inherits from java.awt.Container class • import statement import javax.swing.*; • Container – Type of component that holds other components – Can treat group as single entity – Defined in Container class
Background image of page 4
Java Programming, Fourth Edition 5 Using the JFrame Class (continued) • Container (continued) – Often takes form of window • Drag • Resize • Minimize • Restore • Close
Background image of page 5

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 6 Using the JFrame Class (continued) • Window class – Child of Container – Does not have title bars or borders – Rarely used – Instead use subclasses • Frame • JFrame
Background image of page 6
Java Programming, Fourth Edition 7 Relationship of the JFrame Class to Its Ancestors
Background image of page 7

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 8 Using the JFrame Class (continued) • Create JFrame – Place other objects within it for display • Constructors JFrame() JFrame(String title) JFrame(GraphicsConfiguration gc) JFrame(String title, GraphicsConfiguration gc)
Background image of page 8
Java Programming, Fourth Edition 9 Useful Methods Inherited by the JFrame Class
Background image of page 9

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 10 Using the JFrame Class (continued) • Create JFrame JFrame firstFrame = new JFrame("Hello"); • Set size and title firstFrame.setSize(200, 100); firstFrame.setTitle("My frame");
Background image of page 10
Java Programming, Fourth Edition 11 The JFrame1 Application
Background image of page 11

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 12 Using the JFrame Class (continued) • Close JFrame – Click Close button – JFrame becomes hidden and application keeps running • Default behavior – To change this behavior • Use setDefaultCloseOperation() method
Background image of page 12
Java Programming, Fourth Edition 13 Using the JFrame Class (continued) • Add components to JFrame – Get reference to JFrame ’s automatically created content pane – getContentPane() method
Background image of page 13

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

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 14 Customizing a JFrame 's Appearance • Window decorations – Icon and buttons • Look and feel – Default appearance and behavior of user interface – setDefaultLookAndFeelDecorated() method • Set JFrame ’s look and feel
Background image of page 14
Java Programming, Fourth Edition 15 The JFrame3 Class
Background image of page 15

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

View Full Document Right Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 47

ch13 (1) - Java Programming Fourth Edition Chapter 13...

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

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