List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:GridBag5.java
public GridBag5() { setLayout(new GridBagLayout()); int x, y; // for clarity addGB(new JButton("North"), x = 1, y = 0); constraints.ipadx = 25; // add padding constraints.ipady = 25;/*from w ww.j ava2s . co m*/ addGB(new JButton("West"), x = 0, y = 1); constraints.ipadx = 0; // remove padding constraints.ipady = 0; 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()); int x, y; // for clarity addGB(new JButton("North"), x = 1, y = 0); constraints.ipadx = 25; // add padding constraints.ipady = 25;//from w w w . j av a 2 s . c om addGB(new JButton("West"), x = 0, y = 1); constraints.ipadx = 0; // remove padding constraints.ipady = 0; 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()); 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;/*from w ww. ja va 2s.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
Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(500, 500);/*from ww w .j a v a 2 s. co m*/ JPanel panel1 = new JPanel(new GridBagLayout()); JButton b1 = new JButton("button 1"), b2 = new JButton("button 2"); panel1.add(b1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel1.add(b2, new GridBagConstraints(1, 0, 1, 1, 2.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(panel1); setVisible(true); }
From source file:MainClass.java
public MainClass() { setLayout(new GridBagLayout()); constraints.weightx = 1.0;/*from w ww . jav a 2 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:Main.java
public static JPanel createKV(final Component key, final Component value, final int keyWidth, final boolean fill) { initComponentHeight(key, value);//from ww w. j a v a 2 s .co m if (keyWidth > 0) { key.setPreferredSize(new Dimension(keyWidth, key.getPreferredSize().height)); } final JPanel jp = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(0, 0, 0, 4); jp.add(key, gbc); gbc.gridx = 1; gbc.insets = new Insets(0, 0, 0, 0); gbc.weightx = 1.0; if (fill) { gbc.fill = GridBagConstraints.HORIZONTAL; } jp.add(value, gbc); return jp; }
From source file:Main.java
Main() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0;/* ww w . j a v a 2 s . c o m*/ this.add(new Button("Resizable"), c); c = new GridBagConstraints(); c.weightx = 0.0; this.add(new Button("Not Resizable")); this.pack(); }
From source file:Main.java
public Main() { this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTH; gbc.weighty = 0.0;/*from www. jav a 2s. c o m*/ JPanel one = new JPanel(); one.setPreferredSize(new Dimension(200, 200)); one.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel two = new JPanel(); two.setPreferredSize(new Dimension(200, 200)); two.setBorder(BorderFactory.createLineBorder(Color.BLACK)); this.add(one, gbc); gbc.gridy = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.VERTICAL; this.add(two, gbc); this.pack(); this.setVisible(true); }
From source file:Main.java
public Main() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag);//from ww w . j a v a2 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); }