Search in sources :

Example 1 with JRadioButton

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);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Font(java.awt.Font) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ButtonGroup(javax.swing.ButtonGroup) PCGenSettings(pcgen.system.PCGenSettings) File(java.io.File)

Example 2 with JRadioButton

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);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) RollMethod(pcgen.cdom.content.RollMethod) GridBagLayout(java.awt.GridBagLayout) PointBuyMethod(pcgen.core.PointBuyMethod) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) GameMode(pcgen.core.GameMode) ButtonGroup(javax.swing.ButtonGroup) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 3 with JRadioButton

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

the class RadioChooserDialog method buildButtonPanel.

/**
	 * Create the panel of radio buttons.
	 */
private void buildButtonPanel() {
    ListFacade<InfoFacade> availableList = chooser.getAvailableList();
    int row = 0;
    avaRadioButton = new JRadioButton[availableList.getSize()];
    avaGroup = new ButtonGroup();
    // Create the buttons
    for (InfoFacade infoFacade : availableList) {
        avaRadioButton[row] = new JRadioButton(infoFacade.toString(), false);
        avaGroup.add(avaRadioButton[row]);
        avaRadioButton[row].addActionListener(this);
        ++row;
    }
    int numRows = row;
    if (numRows > 0) {
        avaRadioButton[0].setSelected(true);
        selectedButton = avaRadioButton[0];
    }
    // Layout the buttons
    GridBagLayout gridbag = new GridBagLayout();
    buttonPanel = new JPanel();
    TitledBorder title = BorderFactory.createTitledBorder(null, "");
    buttonPanel.setBorder(title);
    buttonPanel.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    if (numRows > 11) {
        buildTwoColLayout(numRows, c, gridbag);
    } else {
        for (int i = 0; i < numRows; ++i) {
            int cr = i;
            c.anchor = GridBagConstraints.WEST;
            Utility.buildConstraints(c, 0, cr, 2, 1, 1, 0);
            gridbag.setConstraints(avaRadioButton[i], c);
            buttonPanel.add(avaRadioButton[i]);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) InfoFacade(pcgen.facade.core.InfoFacade) ButtonGroup(javax.swing.ButtonGroup) TitledBorder(javax.swing.border.TitledBorder)

Example 4 with JRadioButton

use of javax.swing.JRadioButton in project EnrichmentMapApp by BaderLab.

the class PostAnalysisInputPanel method getSignatureDiscoveryRadio.

JRadioButton getSignatureDiscoveryRadio() {
    if (signatureDiscoveryRadio == null) {
        signatureDiscoveryRadio = new JRadioButton("Signature Discovery");
        signatureDiscoveryRadio.addActionListener(evt -> {
            showInputPanel(getSignatureDiscoveryPanel());
        });
    }
    return signatureDiscoveryRadio;
}
Also used : JRadioButton(javax.swing.JRadioButton)

Example 5 with JRadioButton

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;
}
Also used : Arrays(java.util.Arrays) CardLayout(java.awt.CardLayout) ActionListener(java.awt.event.ActionListener) PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) JTextField(javax.swing.JTextField) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Ranking(org.baderlab.csplugins.enrichmentmap.model.Ranking) IconManager(org.cytoscape.util.swing.IconManager) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) GeneExpressionMatrix(org.baderlab.csplugins.enrichmentmap.model.GeneExpressionMatrix) Map(java.util.Map) EnablementComboBoxRenderer(org.baderlab.csplugins.enrichmentmap.view.EnablementComboBoxRenderer) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) SwingUtil.makeSmall(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.makeSmall) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) DEFAULT_SIZE(javax.swing.GroupLayout.DEFAULT_SIZE) UniverseType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType) JFormattedTextField(javax.swing.JFormattedTextField) ButtonGroup(javax.swing.ButtonGroup) DecimalFormat(java.text.DecimalFormat) ComponentPlacement(javax.swing.LayoutStyle.ComponentPlacement) JOptionPane(javax.swing.JOptionPane) JRadioButton(javax.swing.JRadioButton) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) PostAnalysisFilterType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) Optional(java.util.Optional) Collections(java.util.Collections) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) DecimalFormat(java.text.DecimalFormat) JFormattedTextField(javax.swing.JFormattedTextField) GroupLayout(javax.swing.GroupLayout)

Aggregations

JRadioButton (javax.swing.JRadioButton)331 ButtonGroup (javax.swing.ButtonGroup)187 JPanel (javax.swing.JPanel)170 JLabel (javax.swing.JLabel)146 ActionEvent (java.awt.event.ActionEvent)104 ActionListener (java.awt.event.ActionListener)95 JTextField (javax.swing.JTextField)82 JButton (javax.swing.JButton)77 BoxLayout (javax.swing.BoxLayout)61 GridBagLayout (java.awt.GridBagLayout)59 JCheckBox (javax.swing.JCheckBox)59 GridBagConstraints (java.awt.GridBagConstraints)54 BorderLayout (java.awt.BorderLayout)52 Insets (java.awt.Insets)52 Dimension (java.awt.Dimension)45 FlowLayout (java.awt.FlowLayout)42 JScrollPane (javax.swing.JScrollPane)41 GridLayout (java.awt.GridLayout)32 JComboBox (javax.swing.JComboBox)32 JSpinner (javax.swing.JSpinner)26