Search in sources :

Example 61 with GroupLayout

use of javax.swing.GroupLayout in project cytoscape-api by cytoscape.

the class LookAndFeelUtil method createOkCancelPanel.

/**
	 * Use this method to include a help button in the bottom left corner.
	 * @param helpStr can be a full url, a lookup, or a help page name
	 */
public static JPanel createOkCancelPanel(final JButton okBtn, final JButton cancelBtn, String helpStr, JComponent... otherComponents) {
    final JPanel panel = new JPanel();
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(false);
    layout.setAutoCreateGaps(true);
    final SequentialGroup hg = layout.createSequentialGroup();
    final ParallelGroup vg = layout.createParallelGroup(Alignment.CENTER, false);
    if (helpStr != null && !helpStr.trim().isEmpty()) {
        final JButton helpButton = createHelpButton(helpStr);
        hg.addComponent(helpButton);
        vg.addComponent(helpButton);
    }
    if (otherComponents != null) {
        for (int i = 0; i < otherComponents.length; i++) {
            final JComponent c = otherComponents[i];
            hg.addComponent(c);
            vg.addComponent(c);
        }
    }
    hg.addGap(0, 0, Short.MAX_VALUE);
    final JButton btn1 = isMac() ? cancelBtn : okBtn;
    final JButton btn2 = isMac() ? okBtn : cancelBtn;
    if (btn1 != null) {
        hg.addComponent(btn1);
        vg.addComponent(btn1);
    }
    if (btn2 != null) {
        hg.addComponent(btn2);
        vg.addComponent(btn2);
    }
    layout.setHorizontalGroup(hg);
    layout.setVerticalGroup(vg);
    if (okBtn != null && cancelBtn != null)
        equalizeSize(okBtn, cancelBtn);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ParallelGroup(javax.swing.GroupLayout.ParallelGroup) SequentialGroup(javax.swing.GroupLayout.SequentialGroup) GroupLayout(javax.swing.GroupLayout) JButton(javax.swing.JButton) JComponent(javax.swing.JComponent)

Aggregations

GroupLayout (javax.swing.GroupLayout)61 JPanel (javax.swing.JPanel)43 JLabel (javax.swing.JLabel)36 JButton (javax.swing.JButton)17 JScrollPane (javax.swing.JScrollPane)11 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)9 JCheckBox (javax.swing.JCheckBox)9 JTextField (javax.swing.JTextField)9 AfterInjection (org.baderlab.csplugins.enrichmentmap.AfterInjection)8 JFormattedTextField (javax.swing.JFormattedTextField)6 Dimension (java.awt.Dimension)5 JTable (javax.swing.JTable)5 Color (java.awt.Color)4 JRadioButton (javax.swing.JRadioButton)4 JSpinner (javax.swing.JSpinner)4 SpinnerNumberModel (javax.swing.SpinnerNumberModel)4 MouseEvent (java.awt.event.MouseEvent)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 Arrays (java.util.Arrays)3