Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

To view the source code for java.awt GridBagConstraints BOTH.

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:GridBag4.java

public GridBag4() {
    setLayout(new GridBagLayout());
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weighty = 1.0;//from w  ww . j a v  a2s .com
    int x, y; // for clarity
    constraints.weightx = 0.1;
    addGB(new JButton("one"), x = 0, y = 0);
    constraints.weightx = 0.5;
    addGB(new JButton("two"), ++x, y);
    constraints.weightx = 1.0;
    addGB(new JButton("three"), ++x, y);
}

From source file:Main.java

public Main() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;//from www  . j a  va2 s  . c  om
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y; // for clarity
    addGB(new JButton("North"), x = 1, y = 0);
    addGB(new JButton("West"), x = 0, y = 1);
    addGB(new JButton("Center"), x = 1, y = 1);
    addGB(new JButton("East"), x = 2, y = 1);
    addGB(new JButton("South"), x = 1, y = 2);
}

From source file:Main.java

public Main() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;/*from w  ww .  j  a v a2s . com*/
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y;
    constraints.gridheight = 2; // span two rows
    addGB(new JButton("one"), x = 0, y = 0);
    constraints.gridheight = 1; // set it back
    addGB(new JButton("two"), x = 1, y = 0);
    addGB(new JButton("three"), x = 2, y = 0);
    constraints.gridwidth = 2; // span two columns
    addGB(new JButton("four"), x = 1, y = 1);
    constraints.gridwidth = 1; // set it back
}

From source file:GridBag2.java

public GridBag2() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;//from w  ww  .j  ava2  s .  c  om
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y; // for clarity
    addGB(new JButton("North"), x = 1, y = 0);
    addGB(new JButton("West"), x = 0, y = 1);
    addGB(new JButton("Center"), x = 1, y = 1);
    addGB(new JButton("East"), x = 2, y = 1);
    addGB(new JButton("South"), x = 1, y = 2);
}

From source file:MainClass.java

public MainClass() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;//  w w  w. j a  v a2s. c  o  m
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y; // for clarity
    addGB(new JButton("North"), x = 1, y = 0);
    addGB(new JButton("West"), x = 0, y = 1);
    addGB(new JButton("Center"), x = 1, y = 1);
    addGB(new JButton("East"), x = 2, y = 1);
    addGB(new JButton("South"), x = 1, y = 2);
}

From source file:GridBag3.java

public GridBag3() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;/* w  w w  . j ava2  s.  com*/
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y;
    constraints.gridheight = 2; // span two rows
    addGB(new JButton("one"), x = 0, y = 0);
    constraints.gridheight = 1; // set it back
    addGB(new JButton("two"), x = 1, y = 0);
    addGB(new JButton("three"), x = 2, y = 0);
    constraints.gridwidth = 2; // span two columns
    addGB(new JButton("four"), x = 1, y = 1);
    constraints.gridwidth = 1; // set it back
}

From source file:MainClass.java

public MainClass() {
    setLayout(new GridBagLayout());
    constraints.weightx = 1.0;/*from  w w w  .  ja v  a  2 s  . c o m*/
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    int x, y;
    constraints.gridheight = 2; // span two rows
    addGB(new JButton("one"), x = 0, y = 0);
    constraints.gridheight = 1; // set it back
    addGB(new JButton("two"), x = 1, y = 0);
    addGB(new JButton("three"), x = 2, y = 0);
    constraints.gridwidth = 2; // span two columns
    addGB(new JButton("four"), x = 1, y = 1);
    constraints.gridwidth = 1; // set it back
}

From source file:Main.java

public Main() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);//from w  w w.  ja v  a 2  s .c  o  m
    c.weightx = 1.0;
    c.weighty = 1.0;
    makebutton("Button 1", gridbag, c);
    c.fill = GridBagConstraints.BOTH;
    makebutton("Button 2", gridbag, c);
}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel panel1 = new JPanel();
    Border eBorder = BorderFactory.createEtchedBorder();
    panel1.setBorder(BorderFactory.createTitledBorder(eBorder, "70pct"));
    gbc.gridx = gbc.gridy = 0;/*w  ww . j a  v  a 2  s.c  o  m*/
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.weightx = gbc.weighty = 70;
    getContentPane().add(panel1, gbc);
    JPanel panel2 = new JPanel();
    panel2.setBorder(BorderFactory.createTitledBorder(eBorder, "30pct"));
    gbc.gridy = 1;
    gbc.weightx = 30;
    gbc.weighty = 30;
    gbc.insets = new Insets(2, 2, 2, 2);
    getContentPane().add(panel2, gbc);
    pack();
}

From source file:Main.java

public Main() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel panel1 = new JPanel();
    Border eBorder = BorderFactory.createEtchedBorder();

    panel1.setBorder(BorderFactory.createTitledBorder(eBorder, "70pct"));
    gbc.gridx = gbc.gridy = 0;//from   w  ww .j  a  v  a 2s.c  o m
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.weightx = gbc.weighty = 70;
    add(panel1, gbc);

    JPanel panel2 = new JPanel();
    panel2.setBorder(BorderFactory.createTitledBorder(eBorder, "30pct"));
    gbc.gridy = 1;
    gbc.weightx = gbc.weighty = 30;
    gbc.insets = new Insets(2, 2, 2, 2);
    add(panel2, gbc);

    JPanel panel3 = new JPanel();
    panel3.setBorder(BorderFactory.createTitledBorder(eBorder, "20pct"));
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 2;
    gbc.weightx = 20;
    gbc.insets = new Insets(2, 2, 2, 2);
    add(panel3, gbc);

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