Example usage for java.awt GridBagConstraints REMAINDER

List of usage examples for java.awt GridBagConstraints REMAINDER

Introduction

In this page you can find the example usage for java.awt GridBagConstraints REMAINDER.

Prototype

int REMAINDER

To view the source code for java.awt GridBagConstraints REMAINDER.

Click Source Link

Document

Specifies that this component is the last component in its column or row.

Usage

From source file:org.pentaho.ui.xul.swing.tags.SwingWindow.java

public void resetContainer() {

    container.removeAll();/*  ww  w .  j av  a2 s  . com*/

    gc = new GridBagConstraints();
    gc.gridy = GridBagConstraints.RELATIVE;
    gc.gridx = 0;
    gc.gridheight = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weightx = 1;

}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

@SuppressWarnings("LeakingThisInConstructor")
public KeyValuePairPanel(int addCols, boolean widelist) {

    setOpaque(false);//  w w  w  . j  a va  2s . c  o  m

    ViewUtil.applyVerticalBoxLayout(this);
    kvpPanel = ViewUtil.getClearPanel();
    toolbar = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(toolbar);

    add(kvpPanel);
    add(toolbar);

    additionalColumns = addCols;
    keyKeyComponentMap = new HashMap<String, JLabel>();
    keyValueComponentMap = new HashMap<String, JPanel>();
    keyDetailComponentMap = new HashMap<String, JPanel>();
    keyExtraComponentsMap = new HashMap<String, JPanel[]>();

    columnConstraints = new ArrayList<GridBagConstraints>();
    keysInMoreSection = new ArrayList<String>();

    // Full-width detail component
    keyDetailConstraints = new GridBagConstraints();
    keyDetailConstraints.anchor = GridBagConstraints.SOUTHWEST;
    keyDetailConstraints.weightx = 1.0;
    keyDetailConstraints.fill = GridBagConstraints.BOTH;
    keyDetailConstraints.gridx = 0;
    keyDetailConstraints.gridy = 0;
    keyDetailConstraints.gridwidth = GridBagConstraints.REMAINDER;

    // Constraints for keys
    GridBagConstraints keyConstraints = new GridBagConstraints();
    keyConstraints.anchor = GridBagConstraints.SOUTHWEST;
    keyConstraints.fill = GridBagConstraints.BOTH;
    keyConstraints.weightx = 0;
    keyConstraints.gridx = 0;
    keyConstraints.gridy = 0;
    keyConstraints.ipadx = 5;

    // Constraints for values
    GridBagConstraints valueConstraints = new GridBagConstraints();
    valueConstraints.anchor = GridBagConstraints.SOUTHWEST;
    valueConstraints.fill = GridBagConstraints.BOTH;
    valueConstraints.weightx = widelist ? 0 : 1;
    valueConstraints.gridx = 1;
    valueConstraints.gridy = 0;
    valueConstraints.ipadx = 5;

    columnConstraints.add(keyConstraints);
    columnConstraints.add(valueConstraints);

    // Constraints for additional columns
    for (int i = 0; i < additionalColumns; i++) {
        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.WEST;
        c.fill = GridBagConstraints.BOTH;

        // 1 iff widelist and last additional column
        c.weightx = widelist ? ((i == additionalColumns - 1) ? 1 : 0) : 0;
        c.gridx = i + columnConstraints.size();
        c.gridy = 0;
        columnConstraints.add(c);
    }

    GridBagLayout gbl = new GridBagLayout();
    kvpPanel.setLayout(gbl);
}

From source file:components.TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);//from  w  w w.j  a  v a  2 s  .  c  o  m

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text in a field and press Enter.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}

From source file:medsavant.enrichment.app.OntologyAggregatePanel.java

public OntologyAggregatePanel(String page) {
    super(page);//from   w  ww .  jav  a2  s.com
    setLayout(new GridBagLayout());

    chooser = new JComboBox(OntologyListItem.DEFAULT_ITEMS);
    chooser.setMaximumSize(new Dimension(400, chooser.getMaximumSize().height));
    progress = new JProgressBar();
    progress.setPreferredSize(new Dimension(600, progress.getMaximumSize().height));
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new GridBagLayout());
    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Ontology"));

    tree = new TreeTable();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    banner.add(chooser, gbc);
    gbc.anchor = GridBagConstraints.EAST;
    banner.add(progress, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    add(banner, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(tree), gbc);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (termFetcher != null) {
                termFetcher.cancel(true);
                termFetcher = null;
            }
            recalculate();
        }
    });

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.CloturePanel.java

public CloturePanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0;// w ww .  j a va  2s . c  o  m
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.weightx = 0;
    c.weighty = 0;

    JLabel rappel = new JLabelBold("Oprations  effectuer avant de continuer: ");
    JLabel label = new JLabel("- report des charges et produits constats d'avance");
    JLabel label2 = new JLabel("- report des charges  payer et produits  recevoir");
    JLabel label3 = new JLabel("- impression du bilan, compte de rsultat, grand livre, journaux et balance");
    JLabel label5 = new JLabel("- gnration les critures comptables des payes");
    JLabel label4 = new JLabel("Il est prfrable de raliser une sauvegarde avant de continuer.");

    JLabel op = new JLabelBold("Oprations qui vont etre effectues: ");
    JLabel labelValid = new JLabel(
            "- validation de toutes les critures concernant la priode de l'exercice.");
    JLabel labelSoldeGestion = new JLabel("- soldes de tous les comptes de gestions 6* et 7*");
    JLabel labelSoldeBilan = new JLabel("- soldes de tous les comptes de bilan");
    JLabel labelAN = new JLabel("- report des  nouveaux");

    c.gridy = GridBagConstraints.RELATIVE;
    c.gridx = 0;

    // Date de l'ancien exercice
    Calendar dDebut = this.rowExercice.getDate("DATE_DEB");
    Calendar dFin = this.rowExercice.getDate("DATE_FIN");
    JLabel labelAncienExercice = new JLabel("Clture de l'exercice du " + dateFormat.format(dDebut.getTime())
            + " au " + dateFormat.format(dFin.getTime()));
    this.add(labelAncienExercice, c);
    c.insets = new Insets(10, 2, 1, 2);
    this.add(rappel, c);
    this.add(label, c);
    this.add(label2, c);
    this.add(label3, c);
    this.add(label5, c);
    this.add(label4, c);

    c.insets = new Insets(15, 2, 1, 2);
    this.add(op, c);

    c.insets = new Insets(10, 2, 1, 2);
    this.add(labelValid, c);
    this.add(labelSoldeGestion, c);
    this.add(labelSoldeBilan, c);
    this.add(labelAN, c);

    // Date du prochain exercice
    c.gridwidth = 1;
    c.gridy = GridBagConstraints.RELATIVE;
    c.gridx = 0;
    c.gridx = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.NONE;

    this.add(new JLabel("Date du nouvel exercice du "), c);

    dDebut.set(Calendar.YEAR, dDebut.get(Calendar.YEAR) + 1);
    this.dateOuv.setValue(dDebut.getTime());
    this.add(this.dateOuv, c);
    this.add(new JLabel("au"), c);
    dFin.set(Calendar.YEAR, dFin.get(Calendar.YEAR) + 1);
    this.dateFerm.setValue(dFin.getTime());
    this.add(this.dateFerm, c);

    c.gridx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 2;
    c.weightx = 1;
    this.add(this.opEnCours, c);

    c.gridwidth = 4;
    c.gridx = 0;
    c.weightx = 1;
    this.add(this.bar, c);

    //
    this.add(this.boxValid, c);

    // Button
    final JPanel buttonBar = new JPanel();
    buttonBar.add(this.valider);
    buttonBar.add(this.annul);

    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx = 0;
    this.add(buttonBar, c);

    final PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            CloturePanel.this.valider.setEnabled(isDateValid());
        }
    };
    this.dateFerm.addValueListener(listener);
    this.dateOuv.addValueListener(listener);

    // TODO afficher le deroulement de etapes apres validation

    this.valider.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {
                clotureExercice();
                // show OK works fine
                Component comp = SwingUtilities.getRoot(CloturePanel.this);
                JOptionPane.showMessageDialog(CloturePanel.this, "Exercice cltur", "Fin de la clture",
                        JOptionPane.INFORMATION_MESSAGE);
                ((JFrame) comp).dispose();
            } catch (Exception ex) {
                ExceptionHandler.handle("Erreur lors de la clture", ex);
            }
        }
    });

    this.valider.setEnabled(isDateValid());

    this.boxValid.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CloturePanel.this.valider.setEnabled(isDateValid());
        }
    });

    this.annul.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            ((JFrame) SwingUtilities.getRoot(CloturePanel.this)).dispose();
        }
    });
}

From source file:net.chaosserver.timelord.swingui.SummaryPanel.java

/**
 * Constructs the panel.//from  w ww.  j a  va  2s.co  m
 */
protected void buildSummaryPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    setLayout(gridBagLayout);

    if (isToday()) {
        JLabel remainderName = new JLabel("Remainder");
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridwidth = 1;
        gridBagLayout.addLayoutComponent(remainderName, gridBagConstraints);
        add(remainderName);

        timeLeftLabel = new JLabel();
        gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
        gridBagConstraints.fill = GridBagConstraints.NONE;
        gridBagConstraints.weightx = 0;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
        gridBagLayout.addLayoutComponent(timeLeftLabel, gridBagConstraints);
        add(timeLeftLabel);
    }

    JLabel taskName = new JLabel("Total");
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.gridwidth = 1;
    gridBagLayout.addLayoutComponent(taskName, gridBagConstraints);
    add(taskName);

    totalTimeLabel = new JLabel();
    gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.addLayoutComponent(totalTimeLabel, gridBagConstraints);
    add(totalTimeLabel);

    updateTotalTimeLabel();
    updateTimeLeftLabel();
}

From source file:org.rdv.ui.ImportDialog.java

private void initComponents() {
    JPanel container = new JPanel();
    setContentPane(container);/*from w  w  w .  ja  v a  2  s  .c  om*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Please specify the desired source name for the data.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 5);
    container.add(new JLabel("Source name: "), c);

    sourceNameTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(10, 0, 10, 10);
    container.add(sourceNameTextField, c);

    importProgressBar = new JProgressBar(0, 100000);
    importProgressBar.setStringPainted(true);
    importProgressBar.setValue(0);
    importProgressBar.setVisible(false);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(importProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action importAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -4719316285523193555L;

        public void actionPerformed(ActionEvent e) {
            importData();
        }
    };
    importAction.putValue(Action.NAME, "Import");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import");
    actionMap.put("export", importAction);
    importButton = new JButton(importAction);
    getRootPane().setDefaultButton(importButton);
    panel.add(importButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 7909429022904810958L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();

    sourceNameTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

From source file:DiningPhilosophers.java

public void init() {

    imgs[HUNGRYDUKE] = new ImageIcon(getURL("images/hungryduke.gif"));
    imgs[RIGHTSPOONDUKE] = new ImageIcon(getURL("images/rightspoonduke.gif"));
    imgs[BOTHSPOONSDUKE] = new ImageIcon(getURL("images/bothspoonsduke.gif"));

    width = imgs[HUNGRYDUKE].getIconWidth() + (int) (MARGIN * 2.0);
    height = imgs[HUNGRYDUKE].getIconHeight() + (int) (MARGIN * 2.0);
    spacing = width + MARGIN;/*from   w  ww  . j a v a 2s .  co  m*/

    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    JPanel contentPane = new JPanel();
    contentPane.setLayout(gridBag);

    philosopherArea = new JPanel(null);
    philosopherArea.setBackground(Color.white);
    Dimension preferredSize = createPhilosophersAndChopsticks();
    philosopherArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    philosopherArea.setPreferredSize(preferredSize);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    gridBag.setConstraints(philosopherArea, c);
    contentPane.add(philosopherArea);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.weighty = 0.0;
    gridBag.setConstraints(stopStartButton, c);
    contentPane.add(stopStartButton);

    c.gridwidth = GridBagConstraints.RELATIVE; //don't end row
    c.weightx = 1.0;
    c.weighty = 0.0;
    gridBag.setConstraints(grabDelaySlider, c);
    contentPane.add(grabDelaySlider);

    c.weightx = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    gridBag.setConstraints(label, c);
    contentPane.add(label);
    contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);

    stopStartButton.addActionListener(this);
    grabDelaySlider.addChangeListener(this);

}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

/**
 * //from ww  w.j  av a2s.  c  o  m
 * @param parent
 * @param title
 * @param message
 * @return <code>true</code> if project should also be physically deleted,
 * <code>false</code> is project should be deleted but all files should be left alone,
 * <code>null</code> if user cancelled the dialog/project should not be deleted
 */
public static Boolean showDeleteProjectDialog(IAssemblyProject project) {
    final JDialog dialog = new JDialog((Window) null, "Delete project " + project.getName());

    dialog.setModal(true);

    final JTextArea message = createMultiLineLabel(
            "Do you really want to delete project '" + project.getName() + " ?");
    final JCheckBox checkbox = new JCheckBox("Delete project files");

    final DialogResult[] outcome = { DialogResult.CANCEL };

    final JButton yesButton = new JButton("Yes");
    yesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.YES;
            dialog.dispose();
        }
    });

    final JButton noButton = new JButton("No");
    noButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.NO;
            dialog.dispose();
        }
    });
    final JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            outcome[0] = DialogResult.CANCEL;
            dialog.dispose();
        }
    });

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(yesButton);
    buttonPanel.add(noButton);
    buttonPanel.add(cancelButton);

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    messagePanel.add(checkbox, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right         
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    dialog.getContentPane().add(panel);
    dialog.pack();
    dialog.setVisible(true);

    if (outcome[0] != DialogResult.YES) {
        return null;
    }
    return checkbox.isSelected();
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

protected void createNotVerified() {
    GridBagConstraints c = new GridBagConstraints();
    JTextArea text = newTextArea(getNotVerifiedString());
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;/*from ww  w.  ja  v a  2  s  .c o m*/
    c.weighty = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    DETAILS.add(text, c);

    JButton button = new JButton(getVerifyString());
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LICENSE.verify(LicenseWindow.this);
            buildDetails();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.SOUTHWEST;
    DETAILS.add(button, c);
}