Example usage for java.awt BorderLayout CENTER

List of usage examples for java.awt BorderLayout CENTER

Introduction

In this page you can find the example usage for java.awt BorderLayout CENTER.

Prototype

String CENTER

To view the source code for java.awt BorderLayout CENTER.

Click Source Link

Document

The center layout constraint (middle of container).

Usage

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Editable Tree");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object array[] = { Boolean.TRUE, Boolean.FALSE, "Hello" };
    JTree tree = new JTree(array);
    tree.setEditable(true);/*from   www  .  j a  va2 s .c o  m*/
    tree.setRootVisible(true);
    JCheckBox checkBox = new JCheckBox();
    TreeCellEditor editor = new DefaultCellEditor(checkBox);
    tree.setCellEditor(editor);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    String TITLE = "Full Screen Test";
    JFrame f = new JFrame(TITLE);
    JDesktopPane jdp = new JDesktopPane();

    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JInternalFrame jif = new JInternalFrame(TITLE, true, true, true);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH);
    jif.pack();//from   w ww  .  j av  a  2  s . com
    jif.setLocation(100, 100);
    jif.setVisible(true);
    jdp.add(jif);
    f.add(jdp, BorderLayout.CENTER);
    dev.setFullScreenWindow(f);

}

From source file:VetoableChangeListenerDemo.java

public static void main(final String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JDesktopPane desktop = new JDesktopPane();

    JInternalFrame palette = new JInternalFrame("Palette", true, true, true, true);

    palette.addVetoableChangeListener(new IconPolice());

    palette.setBounds(350, 150, 100, 100);
    desktop.add(palette, JDesktopPane.PALETTE_LAYER);
    palette.setVisible(true);/*  ww  w . j  a  va2 s. c  om*/

    frame.add(desktop, BorderLayout.CENTER);
    frame.setSize(500, 300);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
    container.setLayout(layout);/*from   www.ja v a2s .  c o m*/

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        button.setAlignmentX(Component.TOP_ALIGNMENT);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
    container.setLayout(layout);// w  ww.  j  a  v a  2 s.  c o m

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        button.setAlignmentX(Component.LEFT_ALIGNMENT);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JTabbedPane Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTabbedPane tabbedPane = new JTabbedPane();
    addIt(tabbedPane, "Tab One");
    addIt(tabbedPane, "Tab Two");
    addIt(tabbedPane, "Tab Three");
    f.add(tabbedPane, BorderLayout.CENTER);
    f.setSize(300, 200);/*  w ww.  j  a  v a2 s .  co m*/
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
    container.setLayout(layout);/*from w  w w .j  av  a 2 s . co  m*/

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        button.setAlignmentX(Component.RIGHT_ALIGNMENT);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
    container.setLayout(layout);//from ww  w.ja v a 2s. c  om

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        button.setAlignmentX(Component.BOTTOM_ALIGNMENT);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextField[] txtAllAverages;//from  w  w  w . ja va 2 s  .  c o  m
    int testCount = 2;

    txtAllAverages = new JTextField[testCount];

    JPanel inputControls = new JPanel(new BorderLayout(5, 5));

    JPanel inputControlsLabels = new JPanel(new GridLayout(0, 1, 3, 3));
    JPanel inputControlsFields = new JPanel(new GridLayout(0, 1, 3, 3));
    inputControls.add(inputControlsLabels, BorderLayout.WEST);
    inputControls.add(inputControlsFields, BorderLayout.CENTER);
    for (int i = 0; i < testCount; i++) {
        inputControlsLabels.add(new JLabel("Test score: "));
        JTextField field = new JTextField(10);
        inputControlsFields.add(field);
        txtAllAverages[i] = field;
    }

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));

    controls.add(new JButton("Reset"));
    controls.add(new JButton("Submit"));

    JPanel gui = new JPanel(new BorderLayout(10, 10));
    gui.setBorder(new TitledBorder("Averages"));
    gui.add(inputControls, BorderLayout.CENTER);
    gui.add(controls, BorderLayout.SOUTH);

    JFrame f = new JFrame();
    f.setContentPane(gui);

    f.pack();
    f.setLocationByPlatform(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
    container.setLayout(layout);//  www.  j  av a 2  s. c o  m

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}