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:com.sshtools.common.ui.OptionsPanel.java
/** * * * @param parent//from ww w.java 2 s. c o m * @param tabs tabs * * @return */ public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) { final OptionsPanel opts = new OptionsPanel(tabs); opts.reset(); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Options", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Options", true); } else { d = new JDialog((JFrame) null, "Options", true); } final JDialog dialog = d; // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { opts.cancelled = true; dialog.setVisible(false); } }); final JButton ok = new JButton("Ok"); ok.setMnemonic('o'); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (opts.validateTabs()) { dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(ok); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(opts, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(true); UIUtil.positionComponent(SwingConstants.CENTER, dialog); dialog.setVisible(true); if (!opts.cancelled) { opts.applyTabs(); } return !opts.cancelled; }
From source file:org.intermine.install.swing.PreferencesDialog.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners. // www .j a va2 s. c o m */ private void init() { setName("Preferences Dialog"); setTitle(Messages.getMessage("preferences.title")); lfCombo.setRenderer(new LookAndFeelComboCellRenderer()); Container cp = getContentPane(); GridBagConstraints cons = GridBagHelper.setup(cp); cons.weightx = 0.0; cons.gridwidth = 1; cp.add(new JLabel(Messages.getMessage("preferences.lookandfeel")), cons); cons.gridx++; cons.gridwidth = GridBagConstraints.REMAINDER; cons.weightx = 1.0; cp.add(lfCombo, cons); cons.gridx = 0; cons.gridy++; cp.add(wrongPlaformLabel, cons); cons.gridy++; cp.add(new ButtonPanel(new OkAction(), new CancelAction()), cons); pack(); wrongPlaformLabel.setVisible(false); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.ClotureMensuellePayePanel.java
public ClotureMensuellePayePanel() { super();//from ww w. j a v a 2 s . c o m this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 2, 1, 2); c.weightx = 0; c.weighty = 0; c.gridheight = 1; c.gridwidth = 1; c.gridx = 0; c.gridy = 0; JLabel labelMois = new JLabel("Cloture du mois de "); this.add(labelMois, c); final ElementComboBox selMois = new ElementComboBox(true, 25); selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory() .getElement(MoisSQLElement.class)); selMois.setButtonsVisible(false); c.gridx++; this.add(selMois, c); JLabel labelAnnee = new JLabel("Anne"); c.gridx++; this.add(labelAnnee, c); final JTextField textAnnee = new JTextField(5); c.gridx++; this.add(textAnnee, c); DateFormat format = new SimpleDateFormat("yyyy"); textAnnee.setText(format.format(new Date())); c.gridy++; c.gridx = 0; final JCheckBox boxValid = new JCheckBox("Valider toutes les payes du mois"); final JCheckBox boxCompta = new JCheckBox("Gnrer les critures comptables associes"); c.gridwidth = GridBagConstraints.REMAINDER; this.add(boxValid, c); boxValid.setSelected(true); c.gridy++; this.add(boxCompta, c); JButton buttonClot = new JButton("Clturer"); JButton buttonFermer = new JButton("Fermer"); JPanel panelButton = new JPanel(); panelButton.add(buttonClot); panelButton.add(buttonFermer); c.anchor = GridBagConstraints.SOUTHEAST; c.fill = GridBagConstraints.NONE; c.weighty = 1; c.gridy++; this.add(panelButton, c); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(ClotureMensuellePayePanel.this)).dispose(); } }); buttonClot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Valider les fiches non valids des salaris actifs if (boxValid.isSelected()) { SQLSelect selFiche = new SQLSelect(); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE"); SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.FALSE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); selFiche.andWhere( new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE"))); selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=", tableSalarie.getField("ID_INFOS_SALARIE_PAYE"))); // FIXME ne pas valider les fiches d'un employ renvoy // Where w2 = new Where(tableInfosSal.getField("DATE_SORTIE"), "IS", // "NULL"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DATE, 1); cal.set(Calendar.MONTH, selMois.getSelectedId() - 2); cal.set(Calendar.YEAR, Integer.parseInt(textAnnee.getText())); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Where w = new Where(tableInfosSal.getField("DATE_SORTIE"), "<=", cal.getTime()); w = w.or(new Where(tableInfosSal.getField("DATE_SORTIE"), "=", (Object) null)); selFiche.andWhere(w); String req = selFiche.asString(); System.err.println(req); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); SQLRow rowFicheTmp = tableFiche.getRow(Integer.parseInt(tmp[0].toString())); System.err.println(rowFicheTmp); FichePayeSQLElement.validationFiche(rowFicheTmp.getID()); } } // cloture du mois et generation compta SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableMois = ClotureMensuellePayePanel.this.base.getTable("MOIS"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.TRUE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); String req = selFiche.asString(); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); if (l != null && l.size() > 0) { int[] idS = new int[l.size()]; SQLRow rowMois = tableMois.getRow(selMois.getSelectedId()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); idS[i] = Integer.parseInt(tmp[0].toString()); SQLRow rowFiche = tableFiche.getRow(idS[i]); FichePayeSQLElement.clotureMensuelle(selMois.getSelectedId(), Integer.parseInt(textAnnee.getText()), rowFiche.getInt("ID_SALARIE")); } if (boxCompta.isSelected()) { new GenerationMvtFichePaye(idS, rowMois.getString("NOM"), textAnnee.getText()); } } System.err.println( "ClotureMensuellePayePanel.ClotureMensuellePayePanel().new ActionListener() {...}.actionPerformed()"); JOptionPane.showMessageDialog(null, "Clture termine"); } catch (Exception ex) { ExceptionHandler.handle("Unable to complete operation", ex); } } }); }
From source file:events.ContainerEventDemo.java
public ContainerEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); //Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); //Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);//w w w .ja v a 2s. com addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; //Fill entire cell. c.weighty = 1.0; //Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; //Add/remove buttons have equal width. c.gridwidth = 1; //NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; //Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:savant.ucscexplorer.UCSCExplorerPlugin.java
@Override public void init(JPanel panel) { topLevelPanel = panel;//from ww w . j a va 2 s .c o m panel.setLayout(new GridBagLayout()); // If the UCSC plugin is already loaded, we can build our UI. Otherwise, // we leave a placeholder here. if (getUCSCPlugin() != null) { buildUI(); } else { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.gridwidth = GridBagConstraints.REMAINDER; panel.add(new JLabel("Unable to access UCSC DataSource plugin."), gbc); JButton installUCSCButton = new JButton("Install Now"); installUCSCButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { PluginUtils.installPlugin(UCSC_PLUGIN_URL); } }); panel.add(installUCSCButton, gbc); PluginController.getInstance().addListener(new Listener<PluginEvent>() { @Override public void handleEvent(PluginEvent event) { if (event.getPluginID().equals(UCSC_PLUGIN_ID)) { if (event.getType().equals(PluginEvent.Type.LOADED)) { // Yay! The UCSC plugin has finally made an appearance. buildUI(); } PluginController.getInstance().removeListener(this); } } }); } }
From source file:Main.java
public Main() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); // Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); // Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);/*from www . j ava 2 s . c o m*/ addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; // Fill entire cell. c.weighty = 1.0; // Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; // Add/remove buttons have equal width. c.gridwidth = 1; // NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; // Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:pcgen.gui2.converter.panel.CampaignPanel.java
/** * @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject) *//*from w w w . jav a2s .c o m*/ @Override public void setupDisplay(JPanel panel, final CDOMObject pc) { panel.setLayout(new GridBagLayout()); JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:"); GridBagConstraints gbc = new GridBagConstraints(); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); gbc.insets = new Insets(25, 25, 5, 25); panel.add(introLabel, gbc); final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName); final JTable table = new JTable(model) { //Implement table cell tool tips. @Override public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); String tip = String.valueOf(getValueAt(rowIndex, colIndex)); return tip; } }; table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent event) { pc.removeListFor(ListKey.CAMPAIGN); int[] selRows = table.getSelectedRows(); if (selRows.length == 0) { saveSourceSelection(pc); fireProgressEvent(ProgressEvent.NOT_ALLOWED); } else { for (int row : selRows) { Campaign selCampaign = (Campaign) model.getValueAt(row, 0); pc.addToListFor(ListKey.CAMPAIGN, selCampaign); } saveSourceSelection(pc); fireProgressEvent(ProgressEvent.ALLOWED); } } }); JScrollPane listScroller = new JScrollPane(table); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0); gbc.fill = GridBagConstraints.BOTH; panel.add(listScroller, gbc); initSourceSelection(model, table); }
From source file:FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);/*from ww w .j av a 2s . c o m*/ GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; // Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; // Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); // It's easier to see the focus change // if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; // Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; // Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); // The setRequestFocusEnabled method prevents a // component from being clickable, but it can still // get the focus through the keyboard - this ensures // user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:ContainerEventDemo.java
public ContainerEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); // Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); // Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);// w w w .j a v a 2s .co m addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; // Fill entire cell. c.weighty = 1.0; // Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; // Add/remove buttons have equal width. c.gridwidth = 1; // NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; // Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:savant.plugin.Tool.java
@Override public void init(JPanel panel) { mainPanel = panel;/* ww w. j a v a 2 s . co m*/ panel.setLayout(new CardLayout()); JPanel settingsPanel = new ToolSettingsPanel(this); panel.add(new JScrollPane(settingsPanel), "Settings"); JPanel waitCard = new JPanel(); waitCard.setLayout(new GridBagLayout()); // Left side filler. GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 100, 0, 100); waitCard.add(new JLabel(getDescriptor().getName()), gbc); progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(240, progressBar.getPreferredSize().height)); waitCard.add(progressBar, gbc); progressInfo = new JLabel(); progressInfo.setAlignmentX(1.0f); Font f = progressInfo.getFont(); f = f.deriveFont(f.getSize() - 2.0f); progressInfo.setFont(f); waitCard.add(progressInfo, gbc); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (toolProc != null) { Process p = toolProc; toolProc = null; p.destroy(); } showCard("Settings"); } }); gbc.fill = GridBagConstraints.NONE; waitCard.add(cancelButton, gbc); // Console output at the bottom. console = new JTextArea(); console.setFont(f); console.setLineWrap(false); console.setEditable(false); JScrollPane consolePane = new JScrollPane(console); consolePane.setPreferredSize(new Dimension(800, 200)); gbc.weighty = 1.0; gbc.insets = new Insets(30, 5, 5, 5); gbc.fill = GridBagConstraints.BOTH; waitCard.add(consolePane, gbc); panel.add(waitCard, "Progress"); }