Unformatted text preview: ls as Sub-Containers SubPanels Panels act as sub-containers for grouping user interface components. subIt is recommended that you place the user interface components in panels and It place the panels in a frame. You can also place panels in a panel.
Decompose Decompose into manageable sub-interface subEasy Easy for management You You can use new JPanel() to create a panel with a default FlowLayout manager or new JPanel default FlowLayout new JPanel( new JPanel(LayoutManager layout) to create a panel with the specified layout manager. Use Use the add(Component) method to add a component to the panel. For example,
JPanel p = new JPanel(); JPanel(); p.add(new JButton("OK")); p.add(new JButton("OK"));
EE3206/EE5805 Java Programming & Applications 20 // FlowLayout by default Testing Testing Panels Example
This example uses panels to organize components. The program creates a user interface for a Microwave oven.
frame A textfield p2
A button 12 buttons p1 TestPanels Run EE3206/EE5805 Java Programming & Applications 21 Common Common Features of Swing Components
-font: java.awt.Font -background: java.awt.Color -foreground: java.awt.Color -preferredSize: Dimension -visible: boolean +getWidth(): int +getHeight(): int +getX(): int +getY(): int The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. The font of this component. The background color of this component. The foreground color of this component. The preferred size of this component. Indicates whether this component is visible. Returns the width of this component. Returns the height of thi...
View Full Document
- Spring '10
- Java Programming, BorderLayout Manager