Search in sources :

Example 26 with AbstractButton

use of javax.swing.AbstractButton in project vcell by virtualcell.

the class DisplayAdapterServicePanel method updateColorModelRadioButtons.

/**
 * Insert the method's description here.
 * Creation date: (10/11/00 6:15:25 PM)
 */
private void updateColorModelRadioButtons() {
    String currentSelection = getDisplayAdapterService().getActiveColorModelID();
    JRadioButton toBeSelectedButton = null;
    // remove all from panel and buttongroup
    java.awt.Component[] components = getColorGridPanel().getComponents();
    if (components != null) {
        for (int i = 0; i < components.length; i += 1) {
            if (components[i].getName() == null || !components[i].getName().equals("SpecialColorsJPanel")) {
                ((java.awt.Container) getColorGridPanel()).remove(components[i]);
            }
        }
    }
    java.util.Enumeration<AbstractButton> buttons = getColorMapButtonGroup().getElements();
    while (buttons.hasMoreElements()) {
        AbstractButton button = buttons.nextElement();
        getColorMapButtonGroup().remove(button);
    }
    // now add new ones
    String[] colorNames = getDisplayAdapterService().getColorModelIDs();
    if (colorNames != null) {
        for (int i = 0; i < colorNames.length; i += 1) {
            JRadioButton jcb = new JRadioButton(colorNames[i]);
            jcb.addActionListener(this);
            if (colorNames[i].equals(currentSelection)) {
                toBeSelectedButton = jcb;
            }
            jcb.setActionCommand(colorNames[i]);
            java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints();
            // constraints.gridy = i;
            constraints.gridy = i + 1;
            constraints.insets = new java.awt.Insets(0, 5, 0, 0);
            constraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            constraints.weightx = 1.0;
            getColorGridPanel().add(jcb, constraints);
            getColorMapButtonGroup().add(jcb);
        }
        if (toBeSelectedButton != null) {
            toBeSelectedButton.setSelected(true);
        }
    }
    getColorGridPanel().revalidate();
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) AbstractButton(javax.swing.AbstractButton) GridBagConstraints(java.awt.GridBagConstraints)

Example 27 with AbstractButton

use of javax.swing.AbstractButton in project gephi by gephi.

the class TopDialog method option2Button.

private static Component option2Button(Object option, NotifyDescriptor nd, ActionListener l, JRootPane rp) {
    if (option instanceof AbstractButton) {
        AbstractButton b = (AbstractButton) option;
        b.addActionListener(l);
        return b;
    } else if (option instanceof Component) {
        return (Component) option;
    } else if (option instanceof Icon) {
        return new JLabel((Icon) option);
    } else {
        String text;
        boolean defcap;
        if (option == NotifyDescriptor.OK_OPTION) {
            // XXX I18N
            text = "OK";
            defcap = true;
        } else if (option == NotifyDescriptor.CANCEL_OPTION) {
            // XXX I18N
            text = "Cancel";
            defcap = false;
        } else if (option == NotifyDescriptor.YES_OPTION) {
            // XXX I18N
            text = "Yes";
            defcap = true;
        } else if (option == NotifyDescriptor.NO_OPTION) {
            // XXX I18N
            text = "No";
            defcap = false;
        } else if (option == NotifyDescriptor.CLOSED_OPTION) {
            throw new IllegalArgumentException();
        } else {
            text = option.toString();
            defcap = false;
        }
        JButton b = new JButton(text);
        if (defcap && (rp.getDefaultButton() == null)) {
            rp.setDefaultButton(b);
        }
        // added a simple accessible name to buttons
        b.getAccessibleContext().setAccessibleName(text);
        b.addActionListener(l);
        return b;
    }
}
Also used : AbstractButton(javax.swing.AbstractButton) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) ImageIcon(javax.swing.ImageIcon) Icon(javax.swing.Icon) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 28 with AbstractButton

use of javax.swing.AbstractButton in project adempiere by adempiere.

the class CompiereToggleButtonUI method paint.

//  update
/**
	 *  Paint 3D Box
	 *  @param g Graphics
	 *  @param c Component
	 */
public void paint(Graphics g, JComponent c) {
    super.paint(g, c);
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    boolean in = model.isPressed() || model.isSelected();
    //
    CompiereUtils.paint3Deffect((Graphics2D) g, c, CompiereLookAndFeel.ROUND, !in);
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 29 with AbstractButton

use of javax.swing.AbstractButton in project pcgen by PCGen.

the class OptionsPathDialog method addRadioButton.

private void addRadioButton(String text, String command, ButtonGroup group, ActionListener listener, GridBagConstraints gbc) {
    boolean selected = command.equals(selectedDir);
    if (selected) {
        //for i18n this will need to be handled differently
        text += " (default)";
    }
    AbstractButton rButton = new JRadioButton(text);
    rButton.setActionCommand(command);
    rButton.setSelected(selected);
    rButton.addActionListener(listener);
    group.add(rButton);
    getContentPane().add(rButton, gbc);
}
Also used : AbstractButton(javax.swing.AbstractButton) JRadioButton(javax.swing.JRadioButton)

Example 30 with AbstractButton

use of javax.swing.AbstractButton in project pcgen by PCGen.

the class WriteDirectoryPanel method setupDisplay.

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(layout);
    Component label = new JLabel("Please select the Directory where Converted files should be written: ");
    AbstractButton button = new JButton("Browse...");
    button.setMnemonic('r');
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setCurrentDirectory(path.getParentFile());
            chooser.setSelectedFile(path);
            while (true) {
                int open = chooser.showOpenDialog(null);
                if (open == JFileChooser.APPROVE_OPTION) {
                    File fileToOpen = chooser.getSelectedFile();
                    if (fileToOpen.isDirectory() && fileToOpen.canRead() && fileToOpen.canWrite()) {
                        path = fileToOpen;
                        pc.put(ObjectKey.WRITE_DIRECTORY, path);
                        fileLabel.setText(path.getAbsolutePath());
                        PCGenSettings context = PCGenSettings.getInstance();
                        context.setProperty(PCGenSettings.CONVERT_OUTPUT_SAVE_PATH, path.getAbsolutePath());
                        showWarning();
                        break;
                    }
                    JOptionPane.showMessageDialog(null, "Selection must be a valid " + "(readable & writeable) Directory");
                    chooser.setCurrentDirectory(path.getParentFile());
                } else if (open == JFileChooser.CANCEL_OPTION) {
                    break;
                }
            }
        }
    });
    panel.add(label);
    panel.add(fileLabel);
    panel.add(button);
    panel.add(warningLabel);
    showWarning();
    layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, button, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, fileLabel, 25, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, panel);
    layout.putConstraint(SpringLayout.NORTH, warningLabel, 20, SpringLayout.SOUTH, fileLabel);
    layout.putConstraint(SpringLayout.WEST, warningLabel, 25, SpringLayout.WEST, panel);
    fileLabel.setText(path.getAbsolutePath());
}
Also used : AbstractButton(javax.swing.AbstractButton) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Component(java.awt.Component) PCGenSettings(pcgen.system.PCGenSettings) File(java.io.File)

Aggregations

AbstractButton (javax.swing.AbstractButton)50 JLabel (javax.swing.JLabel)8 JPanel (javax.swing.JPanel)8 Component (java.awt.Component)7 ButtonModel (javax.swing.ButtonModel)7 JRadioButton (javax.swing.JRadioButton)5 JButton (javax.swing.JButton)4 Dimension (java.awt.Dimension)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NotConfigurableException (org.knime.core.node.NotConfigurableException)3 FlowLayout (java.awt.FlowLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 MouseEvent (java.awt.event.MouseEvent)2 JComboBox (javax.swing.JComboBox)2 JComponent (javax.swing.JComponent)2 JFileChooser (javax.swing.JFileChooser)2 JTextField (javax.swing.JTextField)2