List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);// w ww. ja v a 2 s.c o m frame.add(new JButton("1")); frame.add(new JButton("2")); gbl.layoutContainer(frame); gbl.columnWeights = new double[] { 0.0f, 1.0f, 2.0f }; gbl.rowWeights = new double[] { 0.0f, 1.0f }; frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//from ww w . j a v a2 s .c om frame.add(new JButton("1")); frame.add(new JButton("2")); gbl.layoutContainer(frame); double[][] weights = gbl.getLayoutWeights(); for (int i = 0; i < 2; i++) { for (int j = 0; j < weights[i].length; j++) { weights[i][j] = 1; } } gbl.columnWeights = weights[0]; gbl.rowWeights = weights[1]; frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);// ww w . java 2s .co m JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//w w w . j a v a 2 s . c o m JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 2; gbl.setConstraints(component, gbc); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);/*from w ww . j a v a2 s.c o m*/ JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.VERTICAL; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);// w w w . j a v a 2s .c om JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//www .jav a2s . com JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);/* ww w . j a v a2 s .c o m*/ JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); // Make the component on stretchable gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);/*from w w w . j a va 2 s . com*/ JButton component = new JButton("1"); frame.add(new JButton("2")); frame.add(new JButton("3")); frame.add(new JButton("4")); frame.add(new JButton("5")); frame.add(component); frame.add(new JButton("6")); frame.add(new JButton("7")); frame.add(new JButton("8")); frame.add(new JButton("9")); frame.add(new JButton("0")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); int top = 20; int left = 20; int bottom = 2; int right = 40; gbc.insets = new Insets(top, left, bottom, right); gbl.setConstraints(component, gbc); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JFrame demo = new JFrame("GridBag demo, to center a component"); JPanel parentPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.CENTER; gridbag.setConstraints(parentPanel, constraints); parentPanel.setLayout(gridbag);/*from ww w . j a v a2 s .c o m*/ Label centerLabel = new Label(" AAA..."); parentPanel.add(centerLabel); demo.add(parentPanel); demo.setSize(500, 500); demo.setVisible(true); }