use of javax.swing.JRadioButton in project pcgen by PCGen.
the class SourceSelectionPanel method setupDisplay.
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel label = new JLabel("Please select the Source Directory to Convert: ");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(50, 25, 10, 25);
panel.add(label, gbc);
JButton button = new JButton("Browse...");
button.setMnemonic('r');
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser(SourceFolder.OTHER.getFile());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogType(JFileChooser.OPEN_DIALOG);
chooser.setSelectedFile(path);
while (true) {
int open = chooser.showOpenDialog(null);
if (open == JFileChooser.APPROVE_OPTION) {
File fileToOpen = chooser.getSelectedFile();
if (fileToOpen.isDirectory()) {
path = fileToOpen;
SourceFolder.OTHER.setFile(fileToOpen);
pc.put(ObjectKey.DIRECTORY, path);
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path.getAbsolutePath());
JRadioButton button = radioButtons[SourceFolder.OTHER.ordinal()];
button.setSelected(true);
button.setText(buildFolderText(SourceFolder.OTHER, fileToOpen.getAbsolutePath()));
break;
}
JOptionPane.showMessageDialog(null, "Selection must be a valid Directory");
chooser.setSelectedFile(path);
} else if (open == JFileChooser.CANCEL_OPTION) {
break;
}
}
}
});
radioButtons = new JRadioButton[SourceFolder.values().length];
String selectedPath = null;
File selectedFile = pc.get(ObjectKey.DIRECTORY);
if (selectedFile != null) {
selectedPath = selectedFile.getAbsolutePath();
} else {
PCGenSettings context = PCGenSettings.getInstance();
selectedPath = context.getProperty(PCGenSettings.CONVERT_INPUT_PATH, null);
}
ButtonGroup group = new ButtonGroup();
boolean haveSelected = false;
Font font = panel.getFont();
font = FontManipulation.plain(font);
for (SourceFolder folder : SourceFolder.values()) {
JRadioButton pathButton = new JRadioButton();
final SourceFolder buttonFolder = folder;
pathButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, buttonFolder.getFile().getAbsolutePath());
pc.put(ObjectKey.DIRECTORY, buttonFolder.getFile());
}
});
String path;
if (folder.getFile() == null) {
path = "Undefined";
pathButton.setEnabled(false);
} else {
path = folder.getFile().getAbsolutePath();
if (path.equals(selectedPath)) {
pathButton.setSelected(true);
haveSelected = true;
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path);
selectedFile = folder.getFile();
}
}
pathButton.setText(buildFolderText(folder, path));
pathButton.setFont(font);
radioButtons[folder.ordinal()] = pathButton;
group.add(pathButton);
if (folder == SourceFolder.OTHER) {
Utility.buildRelativeConstraints(gbc, 1, GridBagConstraints.REMAINDER, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
} else {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
}
gbc.insets = new Insets(10, 25, 10, 25);
panel.add(pathButton, gbc);
if (folder == SourceFolder.OTHER) {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHEAST);
gbc.insets = new Insets(10, 25, 10, 25);
panel.add(button, gbc);
}
}
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
panel.add(new JLabel(" "), gbc);
if (!haveSelected) {
if (selectedPath != null) {
JRadioButton btn = radioButtons[SourceFolder.OTHER.ordinal()];
btn.setSelected(true);
selectedFile = new File(selectedPath);
SourceFolder.OTHER.setFile(selectedFile);
path = selectedFile;
btn.setText(buildFolderText(SourceFolder.OTHER, selectedFile.getAbsolutePath()));
} else if (radioButtons[SourceFolder.VENDORDATA.ordinal()].isEnabled()) {
JRadioButton btn = radioButtons[SourceFolder.VENDORDATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.VENDORDATA.getFile();
} else if (radioButtons[SourceFolder.HOMEBREWDATA.ordinal()].isEnabled()) {
JRadioButton btn = radioButtons[SourceFolder.HOMEBREWDATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.HOMEBREWDATA.getFile();
} else {
JRadioButton btn = radioButtons[SourceFolder.DATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.DATA.getFile();
}
}
pc.put(ObjectKey.DIRECTORY, selectedFile);
}
use of javax.swing.JRadioButton in project pcgen by PCGen.
the class CharacterStatsPanel method initComponents.
/**
* Build and initialise the user interface.
*/
private void initComponents() {
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JLabel label;
ButtonGroup exclusiveGroup;
Border etched = null;
TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
title1.setTitleJustification(TitledBorder.LEFT);
this.setBorder(title1);
this.setLayout(gridbag);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(2, 2, 2, 2);
final GameMode gameMode = SettingsHandler.getGame();
int row = 0;
exclusiveGroup = new ButtonGroup();
Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
gameMode.getDisplayName()));
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
gridbag.setConstraints(abilitiesUserRolledButton, c);
this.add(abilitiesUserRolledButton);
exclusiveGroup.add(abilitiesUserRolledButton);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
gridbag.setConstraints(abilitiesAllSameButton, c);
this.add(abilitiesAllSameButton);
exclusiveGroup.add(abilitiesAllSameButton);
Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityScoreCombo = new JComboBoxEx();
for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
abilityScoreCombo.addItem(String.valueOf(i));
}
gridbag.setConstraints(abilityScoreCombo, c);
this.add(abilityScoreCombo);
ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
if (!rollMethods.isEmpty()) {
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesRolledButton = new JRadioButton("Rolled:");
gridbag.setConstraints(abilitiesRolledButton, c);
this.add(abilitiesRolledButton);
exclusiveGroup.add(abilitiesRolledButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityRolledModeCombo = new JComboBoxEx();
for (RollMethod rm : rollMethods) {
abilityRolledModeCombo.addItem(rm.getDisplayName());
}
gridbag.setConstraints(abilityRolledModeCombo, c);
this.add(abilityRolledModeCombo);
}
Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
final int purchaseMethodCount = methods.size();
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
gridbag.setConstraints(abilitiesPurchasedButton, c);
this.add(abilitiesPurchasedButton);
exclusiveGroup.add(abilitiesPurchasedButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
pMode = new String[purchaseMethodCount];
pModeMethodName = new String[purchaseMethodCount];
int i = 0;
for (PointBuyMethod pbm : methods) {
pMode[i] = pbm.getDescription();
pModeMethodName[i] = pbm.getDisplayName();
i++;
}
abilityPurchaseModeCombo = new JComboBoxEx(pMode);
gridbag.setConstraints(abilityPurchaseModeCombo, c);
this.add(abilityPurchaseModeCombo);
//
if (purchaseMethodCount == 0) {
abilityPurchaseModeCombo.setVisible(false);
abilitiesPurchasedButton.setVisible(false);
}
Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
gridbag.setConstraints(purchaseModeButton, c);
this.add(purchaseModeButton);
purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
}
use of javax.swing.JRadioButton in project zaproxy by zaproxy.
the class PersistSessionDialog method getTemporaryRadioButton.
private JRadioButton getTemporaryRadioButton() {
if (temporaryRadioButton == null) {
temporaryRadioButton = new JRadioButton(Constant.messages.getString("database.newsession.temporary"));
temporaryRadioButton.addActionListener(this);
}
return temporaryRadioButton;
}
use of javax.swing.JRadioButton in project ACS by ACS-Community.
the class SearchDialog method getBackwardRB.
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getBackwardRB() {
if (backwardRB == null) {
backwardRB = new JRadioButton();
backwardRB.setText("Backward");
backwardRB.setToolTipText("Search backward");
backwardRB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
forwardRB.setSelected(false);
}
});
}
return backwardRB;
}
use of javax.swing.JRadioButton in project EnrichmentMapApp by BaderLab.
the class PostAnalysisWeightPanel method createHypergeomPanel.
private JPanel createHypergeomPanel() {
ActionListener universeSelectActionListener = e -> {
boolean enable = e.getActionCommand().equals("User Defined");
universeSelectionTextField.setEnabled(enable);
};
gmtRadioButton = new JRadioButton();
gmtRadioButton.setActionCommand("GMT");
gmtRadioButton.addActionListener(universeSelectActionListener);
gmtRadioButton.setSelected(true);
expressionSetRadioButton = new JRadioButton();
expressionSetRadioButton.setActionCommand("Expression Set");
expressionSetRadioButton.addActionListener(universeSelectActionListener);
intersectionRadioButton = new JRadioButton();
intersectionRadioButton.setActionCommand("Intersection");
intersectionRadioButton.addActionListener(universeSelectActionListener);
userDefinedRadioButton = new JRadioButton("User Defined:");
userDefinedRadioButton.setActionCommand("User Defined");
userDefinedRadioButton.addActionListener(universeSelectActionListener);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(gmtRadioButton);
buttonGroup.add(expressionSetRadioButton);
buttonGroup.add(intersectionRadioButton);
buttonGroup.add(userDefinedRadioButton);
DecimalFormat intFormat = new DecimalFormat();
intFormat.setParseIntegerOnly(true);
universeSelectionTextField = new JFormattedTextField(intFormat);
universeSelectionTextField.addPropertyChangeListener("value", e -> {
Number val = (Number) universeSelectionTextField.getValue();
if (val == null || val.intValue() < 0) {
universeSelectionTextField.setValue(1);
CySwingApplication application = serviceRegistrar.getService(CySwingApplication.class);
JOptionPane.showMessageDialog(application.getJFrame(), "Universe value must be greater than zero", "Parameter out of bounds", JOptionPane.WARNING_MESSAGE);
}
});
universeSelectionTextField.setEnabled(false);
gmtRadioButton.setText("GMT");
expressionSetRadioButton.setText("Expression Set");
intersectionRadioButton.setText("Intersection");
universeSelectionTextField.setValue(0);
makeSmall(gmtRadioButton, expressionSetRadioButton, intersectionRadioButton, userDefinedRadioButton, universeSelectionTextField);
JPanel panel = new JPanel();
panel.setBorder(LookAndFeelUtil.createTitledBorder("Advanced Hypergeometric Universe"));
final GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING, true).addComponent(gmtRadioButton).addComponent(expressionSetRadioButton).addComponent(intersectionRadioButton).addGroup(layout.createSequentialGroup().addComponent(userDefinedRadioButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(universeSelectionTextField, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(gmtRadioButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(expressionSetRadioButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(intersectionRadioButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(userDefinedRadioButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(universeSelectionTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)));
if (LookAndFeelUtil.isAquaLAF())
panel.setOpaque(false);
return panel;
}
Aggregations