examples
Class Example5

java.lang.Object
  extended by examples.Example5

public class Example5
extends java.lang.Object

In this example the top level container contains a panel which itself contains child components. The layout of the panel is managed by using an object of the class PanelCell, without a separate layout manager for the panel.


Note that the code requires that the static methods of the class EasyCell be imported using the import static pagelayout.EasyCell.* statement.
        public static void createGUI()
        {


                JFrame frame=new JFrame();
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Container container=frame.getContentPane();

                // Create the components
                JLabel findWhat=new JLabel("Find What:");
                JTextField textInput=new JTextField();

                JButton find=new JButton("Find Next");
                JButton cancel=new JButton("Cancel");

                JCheckBox matchWhole=new JCheckBox("Match Whole Word Only");
                JCheckBox matchCase= new JCheckBox("Match Case");
                JPanel p=new JPanel();


                // Create Button group
                PanelCell panelCell=createButtonGroup(p);

               // Top level GUI consists of a row of two columns,
               // The second of these consists of the buttons on the right,
               // and the rest of the components are in the first column.
               Row topLevel=row(
                        column(row(findWhat,textInput),
                               row(column(matchWhole,matchCase),panelCell)),
                        column(find,cancel));

                // Add size constraints
                topLevel.linkHeight(find,1,textInput);
                topLevel.linkWidth(find,1,cancel);

                // Construct the layout
                topLevel.createLayout(container);


                frame.pack();
                frame.setSize(frame.getPreferredSize());
                frame.setVisible(true);



        }
        public static PanelCell createButtonGroup(JPanel p)
        {
                 // Create Button group
                ButtonGroup bg=new ButtonGroup();
                JRadioButton b1=new JRadioButton("Up");
                JRadioButton b2=new JRadioButton("Down");
                bg.add(b1);
                bg.add(b2);
                Border b=BorderFactory.createLineBorder(Color.black);
                p.setBorder(b=BorderFactory.createTitledBorder(b,"Direction"));
                //The row of buttons.
                Row row=new Row();
                row.add(b1).add(b2).add(5,5,Cell.MAX);
                //The main column
                //Create the layout.
                return new PanelCell(p,row);
        }


Constructor Summary
Example5()
           
 
Method Summary
static PanelCell createButtonGroup(javax.swing.JPanel p)
           
static void createGUI()
           
static void main(java.lang.String[] args)
           
static void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Example5

public Example5()
Method Detail

createGUI

public static void createGUI()

createButtonGroup

public static PanelCell createButtonGroup(javax.swing.JPanel p)

main

public static void main(java.lang.String[] args)

run

public static void run()