Example usage for javax.swing JCheckBox getText

List of usage examples for javax.swing JCheckBox getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Returns the button's text.

Usage

From source file:MessageDigestTest.java

public MessageDigestFrame() {
    setTitle("MessageDigestTest");
    setSize(400, 200);//from w w  w  .  j a  v  a 2s. c o m
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    JPanel panel = new JPanel();
    ButtonGroup group = new ButtonGroup();
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JCheckBox b = (JCheckBox) event.getSource();
            setAlgorithm(b.getText());
        }
    };
    addCheckBox(panel, "SHA-1", group, true, listener);
    addCheckBox(panel, "MD5", group, false, listener);

    Container contentPane = getContentPane();

    contentPane.add(panel, "North");
    contentPane.add(new JScrollPane(message), "Center");
    contentPane.add(digest, "South");
    digest.setFont(new Font("Monospaced", Font.PLAIN, 12));

    setAlgorithm("SHA-1");

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem fileDigestItem = new JMenuItem("File digest");
    fileDigestItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            loadFile();
        }
    });
    menu.add(fileDigestItem);
    JMenuItem textDigestItem = new JMenuItem("Text area digest");
    textDigestItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String m = message.getText();
            computeDigest(m.getBytes());
        }
    });
    menu.add(textDigestItem);
    menuBar.add(menu);
    setJMenuBar(menuBar);
}

From source file:com.eviware.soapui.utils.ContainerWalker.java

public AbstractButton findCheckBoxWithLabel(String labelText) {
    for (Component component : containedComponents) {
        if (component instanceof JCheckBox) {
            JCheckBox checkBox = (JCheckBox) component;
            if (String.valueOf(checkBox.getText()).equals(labelText)) {
                return checkBox;
            }//w  ww  .  j  a  va 2 s .c  om
        }
    }
    throw new NoSuchElementException("No checkbox found with label " + labelText);
}

From source file:CheckBoxNodeTreeSample.java

public Object getCellEditorValue() {
    JCheckBox checkbox = renderer.getLeafRenderer();
    CheckBoxNode checkBoxNode = new CheckBoxNode(checkbox.getText(), checkbox.isSelected());
    return checkBoxNode;
}

From source file:com.excilys.ebi.gatling.recorder.ui.component.ConfigurationValidatorListener.java

public void actionPerformed(ActionEvent e) {

    boolean hasError = false;
    Border defaultBorder = frame.txtProxyHost.getBorder();

    Configuration config = Configuration.getInstance();

    if (frame.txtProxyHost.getText().equals(frame.txtProxyHost.getName()))
        frame.txtProxyHost.setText(EMPTY);
    if (frame.txtProxyPort.getText().equals(frame.txtProxyPort.getName()))
        frame.txtProxyPort.setText(EMPTY);
    if (frame.txtProxySslPort.getText().equals(frame.txtProxySslPort.getName()))
        frame.txtProxySslPort.setText(EMPTY);

    frame.tblFilters.validateCells();/*from  www.  ja v  a  2  s . c o m*/

    // Parse local proxy port
    try {
        config.setPort(Integer.parseInt(frame.txtPort.getText()));
        frame.txtPort.setBorder(defaultBorder);
    } catch (NumberFormatException nfe) {
        logger.error("Error, while parsing proxy port...");
        frame.txtPort.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
        hasError = true;
    }

    config.getProxy().setHost(StringUtils.trimToNull(frame.txtProxyHost.getText()));

    // Parse local ssl proxy port
    try {
        config.setSslPort(Integer.parseInt(frame.txtSslPort.getText()));
        frame.txtSslPort.setBorder(defaultBorder);
    } catch (NumberFormatException nfe) {
        logger.error("Error, while parsing proxy SSL port...");
        frame.txtSslPort.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
        hasError = true;
    }

    config.getProxy().setHost(StringUtils.trimToNull(frame.txtProxyHost.getText()));

    // Parse outgoing proxy port
    if (!StringUtils.isEmpty(config.getProxy().getHost())) {
        try {
            config.getProxy().setPort(Integer.parseInt(frame.txtProxyPort.getText()));
            frame.txtProxyPort.setBorder(defaultBorder);
        } catch (NumberFormatException nfe) {
            logger.error("Error, while parsing outgoing proxy port... !");
            frame.txtProxyPort.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
            hasError = true;
        }
    }

    // Parse outgoing ssl proxy port
    if (!StringUtils.isEmpty(config.getProxy().getHost())) {
        try {
            config.getProxy().setSslPort(Integer.parseInt(frame.txtProxySslPort.getText()));
            frame.txtProxySslPort.setBorder(defaultBorder);
        } catch (NumberFormatException nfe) {
            logger.error("Error, while parsing outgoing proxy SSL port... !");
            frame.txtProxySslPort.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
            hasError = true;
        }
    }

    config.setFilterStrategy((FilterStrategy) frame.cbFilterStrategies.getSelectedItem());
    // Set urls filters into a list
    config.setPatterns(new ArrayList<Pattern>());
    for (int i = 0; i < frame.tblFilters.getRowCount(); i++)
        config.getPatterns().add((Pattern) frame.tblFilters.getPattern(i));

    // Check if a directory was entered
    config.setOutputFolder(StringUtils.trimToNull(frame.txtOutputFolder.getText()));
    if (config.getOutputFolder() == null) {
        logger.error("Error, no directory selected for results.");
        frame.txtOutputFolder.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red));
        hasError = true;
    } else
        frame.txtOutputFolder.setBorder(defaultBorder);

    // Set selected results type into a list
    config.setResultTypes(new ArrayList<ResultType>());
    boolean tmp = false;
    for (JCheckBox cb : frame.resultTypes) {
        if (cb.isSelected()) {
            tmp = true;
            config.getResultTypes().add(ResultType.getByLabel(cb.getText()));
        }
    }

    config.setSaveConfiguration(frame.chkSavePref.isSelected());

    // set selected encoding
    config.setEncoding(Charset.class.cast(frame.cbOutputEncoding.getSelectedItem()).name());

    // If nothing was selected we add by default 'text'
    if (!tmp)
        config.getResultTypes().add(ResultType.TEXT);

    if (hasError)
        return;

    if (frame.chkSavePref.isSelected())
        ConfigurationHelper.saveToDisk();

    logConfiguration();

    getEventBus().post(new ShowRunningFrameEvent());
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private List<JCheckBox> cbFilter(String group, String text) {
    ArrayList<JCheckBox> ret = new ArrayList<>();
    for (JCheckBox cb : chkBoxesMap.get(group)) {
        if (text == null || cb.getText().toLowerCase().contains(text)) {
            ret.add(cb);/*from   ww  w.  j  a v  a2 s  .  c o  m*/
        }
    }
    return ret;
}

From source file:fll.scheduler.SchedulerUI.java

/**
 * Prompt the user for which columns represent subjective categories.
 * /*from w  w w .  j  a  v  a  2 s  .  c o  m*/
 * @param parentComponent the parent for the dialog
 * @param columnInfo the column information
 * @return the list of subjective information the user choose
 */
public static List<SubjectiveStation> gatherSubjectiveStationInformation(final Component parentComponent,
        final ColumnInformation columnInfo) {
    final List<String> unusedColumns = columnInfo.getUnusedColumns();
    final List<JCheckBox> checkboxes = new LinkedList<JCheckBox>();
    final List<JFormattedTextField> subjectiveDurations = new LinkedList<JFormattedTextField>();
    final Box optionPanel = Box.createVerticalBox();

    optionPanel.add(new JLabel("Specify which columns in the data file are for subjective judging"));

    final JPanel grid = new JPanel(new GridLayout(0, 2));
    optionPanel.add(grid);
    grid.add(new JLabel("Data file column"));
    grid.add(new JLabel("Duration (minutes)"));

    for (final String column : unusedColumns) {
        if (null != column && column.length() > 0) {
            final JCheckBox checkbox = new JCheckBox(column);
            checkboxes.add(checkbox);
            final JFormattedTextField duration = new JFormattedTextField(
                    Integer.valueOf(SchedParams.DEFAULT_SUBJECTIVE_MINUTES));
            duration.setColumns(4);
            subjectiveDurations.add(duration);
            grid.add(checkbox);
            grid.add(duration);
        }
    }
    final List<SubjectiveStation> subjectiveHeaders;
    if (!checkboxes.isEmpty()) {
        JOptionPane.showMessageDialog(parentComponent, optionPanel, "Choose Subjective Columns",
                JOptionPane.QUESTION_MESSAGE);
        subjectiveHeaders = new LinkedList<SubjectiveStation>();
        for (int i = 0; i < checkboxes.size(); ++i) {
            final JCheckBox box = checkboxes.get(i);
            final JFormattedTextField duration = subjectiveDurations.get(i);
            if (box.isSelected()) {
                subjectiveHeaders
                        .add(new SubjectiveStation(box.getText(), ((Number) duration.getValue()).intValue()));
            }
        }
    } else {
        subjectiveHeaders = Collections.emptyList();
    }

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Subjective headers selected: " + subjectiveHeaders);
    }
    return subjectiveHeaders;
}

From source file:LicenseGenerator.java

private void checkAdapter(JCheckBox chk, JTextField txt, int[] adapterFlag, String[] adapterDate) {
    if (chk.isSelected()) {
        String name = chk.getText();

        int i;//from w  w  w .j a va 2  s.  c  om
        i = (name.substring(0, name.lastIndexOf('.')).hashCode() & 0x7fffffff) % 64;
        if (name.endsWith(".s"))
            i += 64;

        System.out.println("adapter = " + name + " id = " + i + " limit = " + txt.getText());

        adapterFlag[i] = 1;
        adapterDate[i] = txt.getText();
    }
}

From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java

private boolean alreadyFileExists() {
    JCheckBox[] checkBoxes = { checkBoxMdpi, checkBoxHdpi, checkBoxXhdpi, checkBoxXxhdpi, checkBoxXxxhdpi };

    for (JCheckBox checkBox : checkBoxes) {
        if (checkBox.isSelected()) {
            File copyFile = new File(model.getCopyPath(project, checkBox.getText()));
            if (copyFile.exists() && copyFile.isFile()) {
                return true;
            }/*from ww  w.  j a  v  a 2s  . com*/
        }
    }
    return false;
}

From source file:utilities.GraphViewer.java

public void actionPerformed(ActionEvent e) {
    // Evenement button parcourir
    if (e.getSource() == this.parcourir) {

        JFileChooser fileopen = new JFileChooser();
        FiltreSimple filter = new FiltreSimple("Fichier res", "res");
        fileopen.addChoosableFileFilter(filter);
        int ret = fileopen.showDialog(null, "Open file");
        if (ret == JFileChooser.APPROVE_OPTION) {
            File file = fileopen.getSelectedFile();
            System.out.println(file.getPath());
            this.addSensor(file.getPath());

        }/*  ww w.j  a  v a  2 s . c o  m*/

    } else {

        JCheckBox check;
        for (int i = 0; i < this.sensors.size(); i++) {
            check = sensors.get(i);
            if (e.getSource() == check) {
                if (check.isSelected()) {
                    if (!this.isExist(check)) {
                        String s = check.getText();
                        s = s.substring(1);
                        ajouterFichier(this.db.getPath(check.getText()));
                        sensors1.addLast(check);
                        this.graphe.revalidate();
                    }

                } else {
                    this.removeSerie(check.getText());
                    sensors1.remove(check);
                    this.graphe.revalidate();

                }
                break;
            }
        }

    }

}

From source file:greenfoot.gui.export.ExportPublishPane.java

private void setTags(List<String> tags) {
    StringBuilder newTags = new StringBuilder();
    boolean isFirstNewTag = true;
    for (Iterator<String> iterator = tags.iterator(); iterator.hasNext();) {
        String tag = iterator.next();
        if (WITH_SOURCE_TAG.equals(tag)) {
            // we never want the with-source tag to show up.
            continue;
        }//w ww.  j  av a  2s .  co  m
        boolean isPopTag = false;
        for (int i = 0; i < popTags.length; i++) {
            JCheckBox popTag = popTags[i];
            if (popTag.getText().equals(tag)) {
                popTag.setSelected(true);
                isPopTag = true;
                break;
            }
        }
        if (!isPopTag) {
            if (!isFirstNewTag) {
                // Only insert newline if it is not the first new tag
                newTags.append(System.getProperty("line.separator"));
            }
            isFirstNewTag = false;
            newTags.append(tag);
        }
    }
    tagArea.setText(newTags.toString());
}