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();
}
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;
}
}
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);
}
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);
}
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());
}
Aggregations