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

License:asdf

public static void main(String[] argv) throws Exception {
    JWindow window = new JWindow();

    JButton component = new JButton("asdf");
    // Add component to the window
    window.getContentPane().add(component, BorderLayout.CENTER);

    // Set initial size
    window.setSize(300, 300);/*from   w  w w.ja v  a 2  s. c  o m*/

    // Show the window
    window.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JTextArea textarea = new JTextArea();
    textarea.setDragEnabled(true);//from   w w w  .jav  a2s.  c  o m

    textarea.setText("Drag target");

    frame.getContentPane().add(BorderLayout.CENTER, textarea);

    JTextField textarea1 = new JTextField();
    textarea1.setText("Drop target");
    frame.getContentPane().add(BorderLayout.SOUTH, textarea1);

    frame.setSize(500, 300);
    frame.setVisible(true);
    frame.setLocation(100, 100);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame result = new JFrame();
    JComboBox<String> combobox = new JComboBox<>(new String[] { "foo", "bar", "aaa", "Hello World" });
    result.add(combobox, BorderLayout.CENTER);

    JCheckBox toggleVisibility = new JCheckBox("Toggle visibility");
    toggleVisibility.setSelected(combobox.isVisible());
    toggleVisibility.addItemListener(e -> {
        combobox.setVisible(e.getStateChange() == ItemEvent.SELECTED);
    });/* w  w w .  jav  a 2 s .  c o m*/
    result.add(toggleVisibility, BorderLayout.SOUTH);

    result.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    result.pack();
    result.setVisible(true);

}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JTree Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);
    f.add(scrollPane, BorderLayout.CENTER);
    f.setSize(300, 200);//from  w  w  w.  j ava2s  .  com
    f.setVisible(true);
}

From source file:TabbedPaneTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JTabbedPane");
    final Container contentPane = frame.getContentPane();
    JTabbedPane jtp = new JTabbedPane();
    contentPane.add(jtp, BorderLayout.CENTER);
    for (int i = 0; i < 5; i++) {
        JButton button = new JButton("Card " + i);
        jtp.add("Btn " + i, button);
    }/*from  w ww .  jav  a  2  s .c  om*/
    frame.setSize(300, 200);
    frame.show();
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    fileChooser.rescanCurrentDirectory();
    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*  ww w.  j  a  va2  s  .  com*/
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");
    fileChooser.setAcceptAllFileFilterUsed(false);

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*from   w ww.j  av a  2 s . c o m*/
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    int mode = fileChooser.getFileSelectionMode();
    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();// ww  w.  ja  v  a 2  s  .c  om
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    int mu = fileChooser.getApproveButtonMnemonic();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*  w ww. j a  v  a  2s.  c o  m*/
    frame.setVisible(true);
}

From source file:Main.java

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

    JFileChooser fileChooser = new JFileChooser(".");

    String text = fileChooser.getApproveButtonText();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();//from w w  w .jav  a2 s . c o  m
    frame.setVisible(true);
}