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() 

Source Link

Document

Creates a grid layout with a default of one column per component, in a single row.

Usage

From source file:Main.java

public Main() {

    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    setLayout(gridLayout);/*  ww w. j  a  v a  2s. c o m*/

    System.out.println(gridLayout.minimumLayoutSize(this));
}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);//from   ww  w  .  java2  s .c om
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    setLayout(gridLayout);

    gridLayout.layoutContainer(this);

}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);/*w ww .j ava2  s .c  o m*/
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    setLayout(gridLayout);

    gridLayout.removeLayoutComponent(button);

}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);// w w w.j  av a  2s . c o  m
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    gridLayout.setVgap(20);
    gridLayout.setHgap(30);
    setLayout(gridLayout);

}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);/*  w  w w .j a  v  a  2 s  .c  o  m*/
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    gridLayout.setColumns(2);
    gridLayout.setRows(2);
    setLayout(gridLayout);

}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);/*from  ww  w .j  a va 2s. co m*/
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    gridLayout.setVgap(20);
    gridLayout.setHgap(30);
    setLayout(gridLayout);

    System.out.println(gridLayout.toString());

}

From source file:Main.java

public Main() {
    dialog.setLayout(new GridLayout());
    yes.addActionListener(this);
    no.addActionListener(this);
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    btnPanel.add(yes);/*from  ww  w  .j a v  a2  s. c om*/
    btnPanel.add(no);
    dialog.add(message, "Center");
    dialog.add(btnPanel, "South");
    dialog.pack();
    dialog.setVisible(true);
    dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    new Thread(this).start();
}

From source file:Main.java

public LoadImage() {
    super(new GridLayout());
    try {//www  .ja  v a2s.c o m
        image = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
    } catch (Exception ex) {
        ex.printStackTrace(System.err);
    }
    int w = image.getWidth(null) / 2;
    int h = image.getHeight(null) / 2;
    this.add(new JLabel(new ImageIcon(image.getScaledInstance(w, h, Image.SCALE_SMOOTH))));
}

From source file:Main.java

public MyPanel() {
    this.setLayout(new GridLayout());
    this.setPreferredSize(new Dimension(W, H));
    int w = W / 2;
    int h = H / 2;
    int r = w / 5;
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics();
    g.setColor(Color.gray);//from w ww . j  a v a2 s  .  c  o  m
    g.fillRect(0, 0, w, h);
    g.setColor(Color.blue);
    g.fillRect(w / 2 - r, h / 2 - r / 2, 2 * r, r);
    g.dispose();
    this.add(new JLabel(new ImageIcon(bi), JLabel.CENTER));
}

From source file:Main.java

Main() {
    Object[][] data = { { "A", "B", "Snowboarding", new Integer(5) }, { "C", "D", "Pool", new Integer(10) } };
    Object[] columnNames = { "firstname", "lastname", "age" };
    final JTable table = new JTable(data, columnNames) {
        @Override//from w ww . ja v a2s  . c o m
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            int n = getRowHeight();
            return new Dimension(d.width, (n * ROWS));
        }
    };
    JPanel jPanel = new JPanel();
    jPanel.setLayout(new GridLayout());
    JScrollPane sp = new JScrollPane(table);
    jPanel.add(sp);
    JDialog jdialog = new JDialog();
    jdialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    jdialog.setContentPane(jPanel);

    jdialog.pack();
    jdialog.setVisible(true);
}