examples
Class Example3
java.lang.Object
examples.Example3
public class Example3
- extends java.lang.Object
This example provides an alternate code using the Pagelayout
for the gui in the following
tutorial on Table Layout. The simplicity of
the program to create this GUI is quite notworthy, in that all the components are placed in a vertically stacked set of rows with proper alignment specified for
each row.
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()
{
// Frame
JFrame frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Container container=frame.getContentPane();
// Components
JLabel connect=new JLabel("Connect using:");
JTextField choice=new JTextField();
JButton config=new JButton("Configure:");
JLabel info=new JLabel(
"This connection use the following items:");
JTextArea tbox=new JTextArea();
tbox.setRows(15);
tbox.setBorder(
BorderFactory.createLineBorder(Color.black,1));
JButton install=new JButton("Install");
JButton uninstall=new JButton("Uninstall");
JButton props=new JButton("Properties");
JCheckBox showi=new JCheckBox(
"Show icon notification area when connected");
JCheckBox notifybox=new JCheckBox(
"Notify me when this connection has limited or no connectivity");
JButton ok=new JButton("OK");
JButton cancel=new JButton("Cancel");
// The components are laid out in a column.
Column topLevel=column( connect,
row(choice,config),
info,
tbox,
row(justified,none,
install,uninstall,props),
showi,
notifybox,
row(right,none,ok,cancel));
// Construct the Layout from the page
topLevel.createLayout(container);
// Dimension constraints
topLevel.linkHeight(config,1,choice);
frame.pack();
frame.setSize(frame.getPreferredSize());
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 |
Example3
public Example3()
createGUI
public static void createGUI()
main
public static void main(java.lang.String[] args)
run
public static void run()