Example usage for javax.swing JRadioButton getText

List of usage examples for javax.swing JRadioButton getText

Introduction

In this page you can find the example usage for javax.swing JRadioButton getText.

Prototype

public String getText() 

Source Link

Document

Returns the button's text.

Usage

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Helper function to update the error tab
 *///ww w.j  av a2  s  .  co  m
private void updateDescriptionErrors(ConnectorMessage connectorMessage) {
    String processingError = connectorMessage.getProcessingError();
    String postProcessorError = connectorMessage.getPostProcessorError();
    String responseError = connectorMessage.getResponseError();

    ErrorsRadioPane.removeAll();
    boolean paneSelected = false;
    String firstVisiblePane = null;

    if (processingError != null) {
        ErrorsRadioPane.add(ProcessingErrorRadioButton);
        paneSelected = lastUserSelectedErrorType.equals(ProcessingErrorRadioButton.getText());
        if (firstVisiblePane == null) {
            firstVisiblePane = ProcessingErrorRadioButton.getText();
        }
        setCorrectDocument(ProcessingErrorTextPane, processingError, null);
    }

    if (postProcessorError != null) {
        ErrorsRadioPane.add(PostprocessorErrorRadioButton);
        paneSelected = lastUserSelectedErrorType.equals(PostprocessorErrorRadioButton.getText());
        if (firstVisiblePane == null) {
            firstVisiblePane = PostprocessorErrorRadioButton.getText();
        }
        setCorrectDocument(PostprocessorErrorTextPane, postProcessorError, null);
    }

    if (responseError != null) {
        ErrorsRadioPane.add(ResponseErrorRadioButton);
        paneSelected = lastUserSelectedErrorType.equals(ResponseErrorRadioButton.getText());
        if (firstVisiblePane == null) {
            firstVisiblePane = ResponseErrorRadioButton.getText();
        }
        setCorrectDocument(ResponseErrorTextPane, responseError, null);
    }

    String paneToSelect;
    // Set the default pane if the last user selected one is not added.
    if (!paneSelected) {
        if (firstVisiblePane != null) {
            paneToSelect = firstVisiblePane;
        } else {
            paneToSelect = ProcessingErrorRadioButton.getText();
        }
    } else {
        paneToSelect = lastUserSelectedErrorType;
    }

    JRadioButton button = getRadioButtonForErrorPane(paneToSelect);

    button.setSelected(true);
    showErrorPane(button.getText());
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

public void updateMessageRadioGroup() {
    JRadioButton button = getRadioButtonForMessagePane(lastUserSelectedMessageType);

    if (!button.isShowing()) {
        button = RawMessageRadioButton;/*from www  .j  a  v a 2s.co m*/
    }

    button.setSelected(true);
    showMessagePane(button.getText());
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

private JPanel createXPathVersionPanel() {
    JPanel p = new JPanel();
    p.add(new JLabel("XPath Version:"));
    for (Entry<String, String> values : XPathRule.VERSION_DESCRIPTOR.mappings().entrySet()) {
        JRadioButton b = new JRadioButton();
        b.setText(values.getKey());//from  ww w . jav  a 2s .c om
        b.setActionCommand(b.getText());
        if (values.getKey().equals(XPathRule.VERSION_DESCRIPTOR.defaultValue())) {
            b.setSelected(true);
        }
        xpathVersionButtonGroup.add(b);
        p.add(b);
    }
    return p;
}

From source file:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java

private JPanel addStockPanelToolButtons() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    List<Integer> editableColumns = new ArrayList<Integer>();
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.GENERATION));
    stockTablePanel.getTable().setEditableColumns(editableColumns);
    ;//  ww w . j  av a 2 s  . c  o m
    JButton importStockList = new JButton("Import Stocks By Search");
    JButton importHarvestGroup = new JButton("Import Stocks From Harvest Group");
    JPanel subPanel1 = new JPanel();
    subPanel1.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    subPanel1.add(importStockList, "gapRight 10");
    subPanel1.add(importHarvestGroup, "gapRight 10, wrap");
    panel.add(subPanel1, "gapLeft 10, spanx,wrap");
    importStockList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            StocksInfoPanel stockInfoPanel = CreateStocksInfoPanel
                    .createStockInfoPanel("stock annotation popup");
            stockInfoPanel.setSize(new Dimension(500, 400));
            int option = JOptionPane.showConfirmDialog(null, stockInfoPanel, "Search Stock Packets",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            ArrayList<Integer> stockIds = new ArrayList<Integer>();

            if (option == JOptionPane.OK_OPTION) {
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                CheckBoxIndexColumnTable stocksOutputTable = stockInfoPanel.getSaveTablePanel().getTable();
                for (int row = 0; row < stocksOutputTable.getRowCount(); ++row) {
                    int stockId = (Integer) stocksOutputTable.getValueAt(row,
                            stocksOutputTable.getIndexOf(ColumnConstants.STOCK_ID));
                    stockIds.add(stockId);
                }
                List<Stock> stocks = StockDAO.getInstance().getStocksByIds(stockIds);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }

            }

        }

    });

    importHarvestGroup.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ArrayList<PMProject> projects = TokenRelationDAO.getInstance()
                    .findProjectObjects(LoginScreen.loginUserId);
            HashMap<String, Harvesting> name_tap = new HashMap<String, Harvesting>();
            for (PMProject project : projects) {
                List<HarvestingGroup> HarvestingGroups = HarvestingGroupDAO.getInstance()
                        .findByProjectid(project.getProjectId());
                for (HarvestingGroup hg : HarvestingGroups) {
                    Harvesting harvestingPanel = (Harvesting) getContext()
                            .getBean("Harvesting - " + project.getProjectId() + hg.getHarvestingGroupName());
                    name_tap.put(project.getProjectName() + "-" + hg.getHarvestingGroupName(), harvestingPanel);
                }

            }
            JPanel popup = new JPanel(new MigLayout("insets 0, gap 5"));
            JScrollPane jsp = new JScrollPane(popup) {
                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(250, 320);
                }
            };
            ButtonGroup group = new ButtonGroup();
            for (String name : name_tap.keySet()) {
                JRadioButton button = new JRadioButton(name);
                group.add(button);
                popup.add(button, "wrap");

                button.setSelected(true);
            }
            String selected_group = null;
            int option = JOptionPane.showConfirmDialog(null, jsp, "Select Harvesting Group Name: ",
                    JOptionPane.OK_CANCEL_OPTION);
            if (option == JOptionPane.OK_OPTION) {
                for (Enumeration<AbstractButton> buttons = group.getElements(); buttons.hasMoreElements();) {
                    AbstractButton button = buttons.nextElement();
                    if (button.isSelected()) {
                        selected_group = button.getText();

                    }
                }
            }
            if (selected_group != null) {
                Harvesting harvestingPanel = name_tap.get(selected_group);
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                ArrayList<String> stocknames = harvestingPanel.getStickerGenerator().getCreatedStocks();
                List<Stock> stocks = StockDAO.getInstance().getStocksByNames(stocknames);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();

                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }
            }

        }

    });
    getstockTablePanel().getTable().addFocusListener(new FocusAdapter() {
        public void focusLost(FocusEvent e) {
            int row = getstockTablePanel().getTable().getSelectionModel().getAnchorSelectionIndex();
            getstockTablePanel().getTable().setValueAt(true, row,
                    getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
        }
    });
    JPanel subPanel2 = new JPanel();
    subPanel2.setLayout(new MigLayout("insets 0 0 0 0 , gapx 0"));
    subPanel2.add(new JLabel("Pedigree: "));
    this.pedigreeField = new JTextField(10);
    subPanel2.add(pedigreeField);
    JButton setPedigree = new JButton("set");
    setPedigree.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(pedigreeField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.PEDIGREE));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setPedigree, "gapRight 15");

    subPanel2.add(new JLabel("Accession: "));
    this.accessionField = new JTextField(10);
    subPanel2.add(accessionField);
    JButton setAccession = new JButton("set");
    setAccession.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(accessionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.ACCESSION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));

            }
        }
    });
    subPanel2.add(setAccession, "gapRight 15");

    subPanel2.add(new JLabel("Generarion: "));
    this.generarionField = new JTextField(10);
    subPanel2.add(generarionField);
    JButton setGeneration = new JButton("set");
    setGeneration.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(generarionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.GENERATION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setGeneration);

    panel.add(subPanel2, "gapLeft 10,spanx");
    return panel;

}

From source file:org.jets3t.gui.UserInputFields.java

/**
 *
 *
 * @return//from  w w  w .  j  a  v  a  2s .  co m
 * properties containing the user's answers to the input fields. Property names correspond to
 * the field's name, and the property values are the user's response.
 */
public Properties getUserInputsAsProperties(boolean hashPasswords) {
    Properties properties = new Properties();

    for (Iterator iter = userInputComponentsMap.keySet().iterator(); iter.hasNext();) {
        String fieldName = (String) iter.next();
        String fieldValue = null;

        Object component = userInputComponentsMap.get(fieldName);
        if (component instanceof ButtonGroup) {
            ButtonGroup bg = (ButtonGroup) component;
            Enumeration radioEnum = bg.getElements();
            while (radioEnum.hasMoreElements()) {
                JRadioButton button = (JRadioButton) radioEnum.nextElement();
                if (button.isSelected()) {
                    fieldValue = button.getText();
                    break;
                }
            }
        } else if (component instanceof JComboBox) {
            fieldValue = ((JComboBox) component).getSelectedItem().toString();
        } else if (component instanceof JPasswordField) {
            if (hashPasswords) {
                String password = new String(((JPasswordField) component).getPassword());
                try {
                    fieldValue = ServiceUtils
                            .toHex(ServiceUtils.computeMD5Hash(password.getBytes(Constants.DEFAULT_ENCODING)));
                } catch (Exception e) {
                    log.error("Unable to generate hash of password for field named '" + fieldName + "'", e);
                }
            } else {
                fieldValue = new String(((JPasswordField) component).getPassword());
            }
        } else if (component instanceof JTextField) {
            fieldValue = ((JTextField) component).getText();
        } else if (component instanceof JTextArea) {
            fieldValue = ((JTextArea) component).getText();
        } else {
            log.warn("Unrecognised component type for field named '" + fieldName + "': "
                    + component.getClass().getName());
        }

        properties.put(fieldName, fieldValue);
    }
    return properties;
}