<<< Border Layout | Index | A8 GridLayout and Radio Buttons, cont. >>> |
GridLayout class arranges swing components in tabular format:
// Use grid with 2 rows and one column: this.setLayout(new GridLayout(2, 1)); this.getContentPane().add(mRadioPanel); this.getContentPane().add(mMainPanel); this.pack(); // Auto-arrange frame layout
The following example demonstrates FrameRadioButtons class with two panels. GroupRadioButtons panel contains the radio buttons; another panel contains the push buttons, Change Color and Quit:
SwingMain.java (download) class SwingMain
FrameApplication.java (download) class FrameApplication extends javax.swing.JFrame
FrameApplicationClosing.java (download) class FrameApplicationClosing extends java.awt.event.WindowAdapter
FrameRadioButtons.java (download) class FrameRadioButtons extends FrameApplication implements ActionListener
GroupRadioButtonsListener.java (download) class GroupRadioButtonsListener implements ActionListener
GroupRadioButtons.java (download) class GroupRadioButtons extends JPanel, GroupRadioButtonsListener, JRadioButton, ButtonGroup, GridLayout, BorderFactory, Border
<<< Border Layout | Index | A8 GridLayout and Radio Buttons, cont. >>> |