examples
Class Example2
java.lang.Object
examples.Example2
public class Example2
- extends java.lang.Object
This example provides an alternate code for the gui in the following
tutorial on Group Layout.
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()
{
// Main frame and its container
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");
JCheckBox matchCase=new JCheckBox("Match Case");
JCheckBox wrapAround= new JCheckBox("Wrap Around");
JButton cancel=new JButton("Cancel");
JCheckBox wholeWords=new JCheckBox("Whole Words");
JCheckBox searchBackwards=new JCheckBox("Search Backwards");
The components are laid out in a row of three columns.
//The components are laid out in a row of three columns.
Row topLevel= row( column(findWhat),
column(textInput,
row(matchCase,wrapAround),
row(wholeWords,searchBackwards)),
column(find,cancel));
// Add size constraints
topLevel.linkHeight(find,1,textInput);
topLevel.linkWidth(cancel,1,find);
topLevel.linkWidth(wholeWords,1,matchCase);
// Construct the layout
topLevel.createLayout(container);
frame.pack();
frame.setSize(frame.getPreferredSize());
frame.setResizable(false);
frame.show();
}
Method Summary |
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 |
Example2
public Example2()
createGUI
public static void createGUI()
main
public static void main(java.lang.String[] args)
run
public static void run()