List of usage examples for java.awt GridBagConstraints RELATIVE
int RELATIVE
To view the source code for java.awt GridBagConstraints RELATIVE.
Click Source Link
From source file:RelativeXY.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1;/*www .j a v a 2 s .c o m*/ gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(500, 300); f.setVisible(true); }
From source file:GridBagLayoutFill.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;//w ww . j a va2 s. c om gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("This button's preferred width " + "is large because its text is long"), gbc); pane.add(new JButton("Small centered button"), gbc); gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Expands to fill column width"), gbc); f.setSize(400, 300); f.setVisible(true); }
From source file:GridBagLayoutColumnSpanHORIZONTAL.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1;/*from w ww . j a v a 2 s .co m*/ gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Third row, spans two columns"), gbc); gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(400, 300); f.setVisible(true); }
From source file:RelativeX.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0;//from w w w . j av a 2 s . c o m pane.add(new JButton("First row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; gbc.gridy = 1; pane.add(new JButton("Second row, first column"), gbc); pane.add(new JButton("Second row, second column"), gbc); pane.add(new JButton("Second row, third column"), gbc); gbc.gridy = 2; pane.add(new JButton("Third row"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:RelativeY.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;/*from w w w.j av a2 s . co m*/ pane.add(new JButton("First column"), gbc); gbc.gridx = 1; gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("Second column, first row"), gbc); pane.add(new JButton("Second column, second row"), gbc); pane.add(new JButton("Second column, third row"), gbc); gbc.gridx = 2; pane.add(new JButton("Third column"), gbc); f.setSize(500, 300); f.setVisible(true); }
From source file:TextAcceleratorExample.java
public static void main(String[] args) { try {//w w w . j a v a2 s .c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JLabel l; JTextField t; JButton b; JFrame f = new JFrame("Text Accelerator Example"); Container cp = f.getContentPane(); cp.setLayout(new GridBagLayout()); cp.setBackground(UIManager.getColor("control")); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.EAST; cp.add(l = new JLabel("Name:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('n'); cp.add(l = new JLabel("House/Street:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('h'); cp.add(l = new JLabel("City:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('c'); cp.add(l = new JLabel("State/County:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('s'); cp.add(l = new JLabel("Zip/Post code:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('z'); cp.add(l = new JLabel("Telephone:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('t'); cp.add(b = new JButton("Clear"), c); b.setMnemonic('l'); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; cp.add(t = new JTextField(35), c); t.setFocusAccelerator('n'); c.gridx = 1; c.gridy = GridBagConstraints.RELATIVE; cp.add(t = new JTextField(35), c); t.setFocusAccelerator('h'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('c'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('s'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('z'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('t'); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; cp.add(b = new JButton("OK"), c); b.setMnemonic('o'); f.pack(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); f.setVisible(true); }
From source file:Main.java
public static GridBagConstraints gbConstr() { return compConstraint(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE); }
From source file:Main.java
public static GridBagConstraints gbConstr(int gridy) { return compConstraint(GridBagConstraints.RELATIVE, gridy); }
From source file:org.pentaho.ui.xul.swing.tags.SwingStatusbar.java
public void resetContainer() { container.removeAll();/*from w w w. j a v a 2s .c o m*/ gc = new GridBagConstraints(); gc.gridx = GridBagConstraints.RELATIVE; gc.gridy = 0; gc.gridheight = GridBagConstraints.REMAINDER; gc.gridwidth = 1; gc.insets = new Insets(0, 0, 0, 0); gc.fill = GridBagConstraints.BOTH; gc.anchor = GridBagConstraints.CENTER; gc.weighty = 1; }
From source file:org.pentaho.ui.xul.swing.tags.SwingGroupbox.java
public void resetContainer() { container.removeAll();/*from w w w. j a v a 2 s .c o m*/ if (this.getOrientation() == Orient.VERTICAL) { gc = new GridBagConstraints(); gc.gridy = GridBagConstraints.RELATIVE; gc.gridx = 0; gc.gridheight = 1; gc.gridwidth = GridBagConstraints.REMAINDER; int pad = getPadding(); gc.insets = new Insets(pad, pad, pad, pad); gc.fill = GridBagConstraints.HORIZONTAL; gc.anchor = GridBagConstraints.NORTHWEST; gc.weightx = 1; } else { gc = new GridBagConstraints(); gc.gridy = 0; gc.gridx = GridBagConstraints.RELATIVE; gc.gridheight = GridBagConstraints.REMAINDER; gc.gridwidth = 1; gc.insets = new Insets(2, 2, 2, 2); gc.fill = GridBagConstraints.VERTICAL; gc.anchor = GridBagConstraints.NORTHWEST; gc.weighty = 1; } }