lecture15

lecture15 - 1 Introduction to Computation and Problem...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 Introduction to Computation and Problem Solving Prof. Steven R. Lerman and Dr. V. Judson Harward Class 15: Class 15: Constructing Interfaces with Constructing Interfaces with Swing Swing 2 Topics In this lecture, we are going to explore how to build more complex interfaces with Swing. We will not demonstrate many components; for that see http://java.sun.com/docs/books/tutorial/uiswing/components/components.html We will explore how to build up an interface component by component and container by container; how to use layout management to configure your GUI Tuesday's active learning will focus on how to make your program respond to events. 1 3 Constructing GUIs simple calculator. the containers into larger containers. JPanel interfaces. It is ) Later in this course, we are going to build a We will build the GUI by nesting simpler components into containers, and then combining is the workhorse of most complicated a good all purpose container the standard drawing surface (Lecture 17 a base class for many composite components 4 1. Overall subclass of 2.1 2.2 2.2.1 subclass Calculator GUI JFrame 2. Reusable JPanel JPanel contains JLabel JPanel subclass Keypad JButton KeyButton 2 5 Calculator GUI Diagram 1. 2. 1. 2.1 2.1.1 2.2 2.2.1 JFrame Calculator extends JPanel JFrame. contentPane JPanel the result pane JLabel Keypad extends JPanel KeyButton extends JButton 6 Layout management is the process of components. an instance of another class. different layout policy . Container content = getContentPane(); content.setLayout( new FlowLayout() ); Layout Management, 1 determining the size and location of a container's Java containers do not handle their own layout. They delegate that task to their layout manager, Each type (class) of layout manager enforces a If you do not like a container's default layout manager, you can change it. 3 7 If a container encloses another container, the enclosing container can not position the inner container nor size itself until it knows how big the inner container needs to be. And the inner container can not size itself Layout Management, 2 Layout management proceeds top down in the containment hierarchy. until it queries its contents. 8 1. Overall subclass of 2.1 2.2 2.2.1 subclass Calculator GUI JFrame 2. Reusable JPanel JPanel contains JLabel JPanel subclass Keypad JButton KeyButton 4 9 Calculator GUI Diagram 1. 2. 1. 2.1 2.1.1 2.2 2.2.1 depends on depends on depends on both depends on 20 of depends on JFrame Calculator extends JPanel JFrame. contentPane JPanel JLabel Keypad extends JPanel KeyButton extends JButton 10 good reason. via a call to setLayout(null) ....
View Full Document

Page1 / 20

lecture15 - 1 Introduction to Computation and Problem...

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

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