lecture19

lecture19 - PIC 20A Lecture 19: More Swing GUI Components...

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

View Full Document Right Arrow Icon
PIC 20A Lecture 19: More Swing GUI Components
Background image of page 1

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

View Full DocumentRight Arrow Icon
JPanel • a container on which JComponent objects can be placed • often extended to create new components • default size is 0 pixels wide, 0 pixels tall • opaque by default JPanel p = new JPanel();
Background image of page 2
Creating Borders around JPanel EtchedBorder eb = new EtchedBorder(); TitledBorder tb = new TitledBorder(eb, "Title"); p.setBorder(eb); //or. . p.setBorder(tb)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Problems Combining Swing GUI and Drawings • Swing GUI components are displayed using the same graphics techniques and in the same area as the drawings • JComponent and drawings can paint over each other. • To fix this problem, separate the GUI and the graphics by creating dedicated drawing areas as subclasses of JPanel ( override paintComponent)
Background image of page 4
JButton • the text on the face of a JButton is called a button label . • supports the display of icons • can also have a rollover icon - an icon displayed when a mouse is positioned over the button JButton b = new JButton(“BLabel”);
Background image of page 5

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

View Full DocumentRight Arrow Icon
JLabel • an area where non-editable text or icons can be displayed JLabel label = new JLabel(“Label Text”); String text = label.getText(); label.setText(“New Text for JLabel”);
Background image of page 6
JTextField • used for single-line text input and display
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

lecture19 - PIC 20A Lecture 19: More Swing GUI Components...

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

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