Example usage for java.awt GridLayout GridLayout

List of usage examples for java.awt GridLayout GridLayout

Introduction

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

Prototype

public GridLayout(int rows, int cols) 

Source Link

Document

Creates a grid layout with the specified number of rows and columns.

Usage

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel(new GridLayout(0, 5));
    panel.add(new BasicArrowButton(BasicArrowButton.EAST));
    panel.add(new BasicArrowButton(BasicArrowButton.NORTH));
    panel.add(new BasicArrowButton(BasicArrowButton.SOUTH));
    panel.add(new BasicArrowButton(BasicArrowButton.WEST));
    JOptionPane.showMessageDialog(null, panel);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();

    content.setLayout(new GridLayout(0, 2));

    JTextArea leftTextArea = new JTextArea();
    content.add(leftTextArea);// w  w  w.  j ava  2s.  c om
    leftTextArea.paste();

    frame.setSize(250, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JSeparator Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridLayout(0, 1));
    JLabel above = new JLabel("Above Separator");
    f.add(above);/*from  w w  w.  ja  v  a2  s .  c  o  m*/
    JSeparator separator = new JSeparator();
    f.add(separator);
    JLabel below = new JLabel("Below Separator");
    f.add(below);
    f.setSize(300, 100);
    f.setVisible(true);
}

From source file:BasicArrowButtonSample.java

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

    frame.setLayout(new GridLayout(0, 5));
    frame.add(new BasicArrowButton(BasicArrowButton.EAST));
    frame.add(new BasicArrowButton(BasicArrowButton.NORTH));
    frame.add(new BasicArrowButton(BasicArrowButton.SOUTH));
    frame.add(new BasicArrowButton(BasicArrowButton.WEST));
    frame.setSize(300, 200);//ww w  . j a va2 s . co  m
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(0, 1));
    JTextField textField = new JTextField("Left");
    textField.setHorizontalAlignment(JTextField.LEFT);
    frame.add(textField);//from  w w  w.  ja  va 2 s.com
    textField = new JTextField("Center");
    textField.setHorizontalAlignment(JTextField.CENTER);
    frame.add(textField);
    textField = new JTextField("Right");
    textField.setHorizontalAlignment(JTextField.RIGHT);
    frame.add(textField);
    textField = new JTextField("Leading");
    textField.setHorizontalAlignment(JTextField.LEADING);
    frame.add(textField);
    textField = new JTextField("Trailing");
    textField.setHorizontalAlignment(JTextField.TRAILING);
    frame.add(textField);
    frame.pack();
    frame.setSize(250, (int) frame.getSize().getHeight());
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton component1 = new JButton();
    JButton component2 = new JButton();

    int rows = 2;
    int cols = 2;
    JPanel panel = new JPanel(new GridLayout(rows, cols));
    panel.add(component1);//from  w ww.  j a va 2 s.  c o  m
    panel.add(component2);

}

From source file:Main.java

public static void main(String args[]) {
    JPanel p = new JPanel();

    p.setLayout(new GridLayout(2, 1));
    JList<String> lista = new JList<>(new String[] { "1", "2", "3", "4" });
    p.add(new JScrollPane(lista));
    JComboBox<String> combo = new JComboBox<>();
    for (int i = 0; i < 100; i++) {
        combo.addItem(Integer.toString(i));
        p.add(combo);/*  w  w  w  .  j av  a 2s.c  o  m*/
    }

    JFrame f = new JFrame();
    f.getContentPane().add(p, BorderLayout.CENTER);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(200, 200);
    f.setVisible(true);
}

From source file:SpinnerDemo.java

public static void main(String[] args) {
    JFrame jf = new JFrame("It Spins");
    Container cp = jf.getContentPane();
    cp.setLayout(new GridLayout(0, 1));

    // Create a JSpinner using one of the pre-defined SpinnerModels
    JSpinner dates = new JSpinner(new SpinnerDateModel());
    cp.add(dates);/*from   w w  w  .  jav  a2 s . co  m*/

    // Create a JSPinner using a SpinnerListModel. 
    String[] data = { "One", "Two", "Three" };
    JSpinner js = new JSpinner(new SpinnerListModel(data));
    cp.add(js);

    jf.setSize(100, 80);
    jf.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));
    ButtonGroup group = new ButtonGroup();
    JRadioButton option = new JRadioButton("French Fries", true);
    group.add(option);/*w w w.j  a va  2 s  . c  o  m*/
    contentPane.add(option);
    option = new JRadioButton("Onion Rings", false);
    group.add(option);
    contentPane.add(option);
    option = new JRadioButton("Ice Cream", false);
    group.add(option);
    contentPane.add(option);
    frame.setSize(200, 200);
    frame.show();
}

From source file:FocusCycleSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Focus Cycle Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(3, 3));
    for (int i = 0; i < 3; i++) {
        JButton button = new JButton("" + i);
        frame.add(button);/*  w w  w .  j  av a 2  s .c om*/
    }
    JPanel panel = new JPanel();
    panel.setFocusCycleRoot(true);
    panel.setFocusTraversalPolicyProvider(true);
    panel.setLayout(new GridLayout(1, 3));
    for (int i = 0; i < 3; i++) {
        JButton button = new JButton("" + (i + 3));
        panel.add(button);
    }
    frame.add(panel);
    for (int i = 0; i < 3; i++) {
        JButton button = new JButton("" + (i + 6));
        frame.add(button);
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}