List of usage examples for java.awt GridBagConstraints REMAINDER
int REMAINDER
To view the source code for java.awt GridBagConstraints REMAINDER.
Click Source Link
From source file:GridBagLayoutGridHeight.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(); pane.add(new JLabel("First row, first column"), gbc); pane.add(new JLabel("First row, second column"), gbc); gbc.gridheight = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.VERTICAL; pane.add(new JLabel("First row, third column"), gbc); gbc.gridx = 0;//from w w w . j av a2 s. c o m gbc.gridheight = 1; gbc.fill = GridBagConstraints.NONE; pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:GridBagLayoutRemainder.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(); pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("First row, second column"), gbc); pane.add(new JButton("First row, third column"), gbc); gbc.gridx = 0;/*w w w .j a va 2 s . c om*/ pane.add(new JButton("Second row"), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Third row, gridwidth set to REMAINDER"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:Main.java
public Main() { JPanel bigPanel = new JPanel(new GridBagLayout()); JPanel panel_a = new JPanel(); JButton btnA = new JButton("button a"); panel_a.add(btnA);/*from w ww . ja v a 2 s .co m*/ JPanel panel_b = new JPanel(); JButton btnB = new JButton("button b"); panel_b.add(btnB); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; bigPanel.add(panel_a, c); bigPanel.add(panel_b, c); c.weighty = 1.0; bigPanel.add(new JPanel(), c); this.add(bigPanel); }
From source file:Main.java
public Main() { setPreferredSize(new Dimension(500, 500)); getContentPane().setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(4, 4, 4, 4); panel.add(new JLabel("Label"), c); panel.add(new JTextField(20), c); c.gridwidth = GridBagConstraints.REMAINDER; panel.add(new JButton("btn"), c); c.gridwidth = 1;// w w w.j a v a 2s . c om panel.add(new JLabel("Name"), c); panel.add(new JTextField(20), c); c.gridwidth = GridBagConstraints.REMAINDER; panel.add(new JButton("btn"), c); c.weighty = 1.0; panel.add(Box.createGlue(), c); add(panel, BorderLayout.LINE_START); pack(); setVisible(true); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); JPanel upper = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); upper.setLayout(gridbag);/*from w ww. j a v a 2 s .c o m*/ GridBagConstraints gbc = new GridBagConstraints(); JButton toolbar1 = new JButton("toolbar1"); JButton toolbar2 = new JButton("toolbar2"); JButton toolbar3 = new JButton("toolbar3"); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.anchor = GridBagConstraints.WEST; upper.add(toolbar1, gbc); gbc.gridx = 1; gbc.anchor = GridBagConstraints.CENTER; upper.add(toolbar2, gbc); gbc.gridx = 2; gbc.anchor = GridBagConstraints.EAST; gbc.gridwidth = GridBagConstraints.REMAINDER; upper.add(toolbar3, gbc); add(upper, BorderLayout.NORTH); JPanel something = new JPanel(); something.setBackground(Color.WHITE); something.setPreferredSize(new Dimension(600, 600)); something.repaint(); add(something, BorderLayout.CENTER); pack(); setVisible(true); }
From source file:fll.scheduler.ChooseChallengeDescriptor.java
private void initComponents() { getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1;/*from w w w. j av a 2s . c om*/ gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; final JTextArea instructions = new JTextArea( "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.", 3, 40); instructions.setEditable(false); instructions.setWrapStyleWord(true); instructions.setLineWrap(true); getContentPane().add(instructions, gbc); gbc = new GridBagConstraints(); mCombo = new JComboBox<DescriptionInfo>(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(mCombo, gbc); mCombo.setRenderer(new DescriptionInfoRenderer()); mCombo.setEditable(false); final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo(); for (final DescriptionInfo info : descriptions) { mCombo.addItem(info); } mFileField = new JLabel(); gbc = new GridBagConstraints(); gbc.weightx = 1; getContentPane().add(mFileField, gbc); final JButton chooseButton = new JButton("Choose File"); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(chooseButton, gbc); chooseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mFileField.setText(null); final JFileChooser fileChooser = new JFileChooser(); final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" }); fileChooser.setFileFilter(filter); final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selectedFile = fileChooser.getSelectedFile(); mFileField.setText(selectedFile.getAbsolutePath()); } } }); final Box buttonPanel = new Box(BoxLayout.X_AXIS); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(buttonPanel, gbc); buttonPanel.add(Box.createHorizontalGlue()); final JButton ok = new JButton("Ok"); buttonPanel.add(ok); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { // use the selected description if nothing is entered in the file box final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex()); if (null != descriptionInfo) { mSelected = descriptionInfo.getURL(); } final String text = mFileField.getText(); if (!StringUtils.isEmpty(text)) { final File file = new File(text); if (file.exists()) { try { mSelected = file.toURI().toURL(); } catch (final MalformedURLException e) { throw new FLLInternalException("Can't turn file into URL?", e); } } } setVisible(false); } }); final JButton cancel = new JButton("Cancel"); buttonPanel.add(cancel); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mSelected = null; setVisible(false); } }); pack(); }
From source file:events.TreeExpandEventDemo.java
public TreeExpandEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;//from ww w .ja v a2 s . c o m c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); demoArea = new DemoArea(); gridbag.setConstraints(demoArea, c); add(demoArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:org.tranche.gui.add.wizard.AFTStep3Panel.java
public AFTStep3Panel(AddFileToolWizard wizard) { this.wizard = wizard; setBackground(Styles.COLOR_PANEL_BACKGROUND); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); // title/*from w w w. ja va 2s .c o m*/ gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(10, 10, 0, 10); headerLabel.setFont(Styles.FONT_18PT); add(headerLabel, gbc); // license panels gbc.insets = new Insets(5, 25, 15, 15); gbc.weighty = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.BOTH; add(cc0LicensePanel, gbc); add(customLicensePanel, gbc); }
From source file:org.pentaho.ui.xul.swing.tags.SwingStatusbar.java
public void resetContainer() { container.removeAll();// w w w . jav a 2 s .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:components.TextDemo.java
public TextDemo() { super(new GridBagLayout()); textField = new JTextField(20); textField.addActionListener(this); textArea = new JTextArea(5, 20); textArea.setEditable(false);// w w w.ja v a2 s.c om JScrollPane scrollPane = new JScrollPane(textArea); //Add Components to this panel. GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; add(textField, c); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; add(scrollPane, c); }