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:com.nikonhacker.gui.EmulatorUI.java

private void dumpOptionCheckboxes(List<JCheckBox> outputOptionsCheckBoxes, Set<OutputOption> outputOptions) {
    for (JCheckBox checkBox : outputOptionsCheckBoxes) {
        try {/*  w  w w.  ja v a2 s  .  c  o m*/
            OutputOption.setOption(outputOptions, checkBox.getText(), checkBox.isSelected());
        } catch (ParsingException e) {
            e.printStackTrace();
        }
    }
}

From source file:nl.tudelft.goal.SimpleIDE.FilePanel.java

/**
 * Helper method for {@link #handleFileRename(File, File)}. Asks the user
 * which of the given list of file references should be renamed. Returns a
 * new list of nodes that the user has selected. The given list is not
 * altered./*from www.  j av a  2 s  .c  o m*/
 */
private List<FileNode> filterFiles(List<FileNode> nodes) {

    ArrayList<FileNode> filteredFiles = new ArrayList<FileNode>();

    // show requester which files to change.
    // we can not dump an array of checkboxes into the showOptionDialog
    // because it will show them next to each oter instead of below each
    // other.
    // and because it does not show the OK and Cancel buttons. So we use
    // ConfirmDialog isntead
    JPanel choicespanel = new JPanel();
    choicespanel.setLayout(new BoxLayout(choicespanel, BoxLayout.Y_AXIS));
    choicespanel.add(new JLabel("There are multiple mas's using the renamed file.\n" //$NON-NLS-1$
            + "Please select which ones have to be renamed")); //$NON-NLS-1$
    ArrayList<JCheckBox> choices = new ArrayList<JCheckBox>();
    for (FileNode n : nodes) {
        JCheckBox checkbox = new JCheckBox("" //$NON-NLS-1$
                + ((FileNode) n.getParent()).getFilename());
        choices.add(checkbox);
        choicespanel.add(checkbox);
    }

    int choice = JOptionPane.showConfirmDialog(this, choicespanel, "Select files to rename", //$NON-NLS-1$
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (choice == JOptionPane.CANCEL_OPTION) {
        return null;
    }
    // and finally copy the requested filenames to array
    for (JCheckBox c : choices) {
        if (c.isSelected()) {
            for (FileNode n : nodes) {
                if (c.getText().equals(((FileNode) n.getParent()).getFilename())) {
                    filteredFiles.add(n);
                    break;
                }
            }
        }
    }

    return filteredFiles;
}

From source file:nz.govt.natlib.ndha.manualdeposit.StructMapFileDescMgmtPresenter.java

private HashMap<String, String> convertExtraLayersToStrings() {
    HashMap<String, String> extraLayersToStrings = new HashMap<String, String>();
    for (Entry<String, JComponent> attr : extraLayers.entrySet()) {
        // If JComponent is a checkbox
        if (attr.getKey().startsWith("Allow")) {
            JCheckBox field = (JCheckBox) attr.getValue();
            extraLayersToStrings.put(attr.getKey(), String.valueOf(field.isSelected()));
        }//from w w w.ja  va 2 s  .c om
        // Else it is a text field
        else {
            JTextField field = (JTextField) attr.getValue();
            extraLayersToStrings.put(attr.getKey(), field.getText());
        }
    }
    return extraLayersToStrings;
}

From source file:nz.govt.natlib.ndha.manualdeposit.StructMapFileDescMgmtPresenter.java

private boolean valuesChangedExtraLayers(HashMap<String, String> extraLayers) {
    for (Entry<String, JComponent> attr : this.extraLayers.entrySet()) {
        String value = extraLayers.get(attr.getKey());
        // If JComponent is a checkbox
        if (attr.getKey().startsWith("Allow")) {
            JCheckBox field = (JCheckBox) attr.getValue();
            if (value == null) {
                if (field.isSelected())
                    return true;
            } else {
                if (Boolean.parseBoolean(value) != field.isSelected())
                    return true;
            }/*from w w  w  . j a  va 2 s . c  o m*/
        }
        // Else it is a text field
        else {
            JTextField field = (JTextField) attr.getValue();
            if (value == null) {
                if (!field.getText().equals(""))
                    return true;
            } else {
                if (!value.equals(field.getText()))
                    return true;
            }
        }
    }
    return false;
}

From source file:org.accretegb.modules.phenotype.PhenotypeInfoPanel.java

public ArrayList<String> getSelectedParameters() {
    ArrayList<String> parameters = new ArrayList<String>();
    for (JCheckBox b : parametersCheckBoxes) {
        if (b.isSelected()) {
            parameters.add(b.getText());
        }/*from  ww w . java2 s  .com*/
    }
    return parameters;
}

From source file:org.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(ComponentBuilder componentBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(componentBuilder, propertyDescriptor);
    // setBorder(WidgetUtils.BORDER_LIST_ITEM);
    _checkBoxes = new LinkedHashMap<>();
    _checkBoxDecorations = new IdentityHashMap<>();
    _firstUpdate = true;/*from   w  ww  .ja v a  2 s .  c o  m*/
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().addSourceColumnChangeListener(this);
    getAnalysisJobBuilder().addTransformerChangeListener(this);

    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(
            new CompoundBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.contains(text));
                }
            }
        }
    });

    if (_dataType == null || _dataType == Object.class) {
        _notAvailableCheckBox = new DCCheckBox<>(
                "<html><font color=\"gray\">- no columns available -</font></html>", false);
    } else {
        _notAvailableCheckBox = new DCCheckBox<>("<html><font color=\"gray\">- no <i>"
                + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    }
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION);

    JButton selectAllButton = WidgetFactory.createDefaultButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = WidgetFactory.createDefaultButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.MODEL_COLUMN_EXPRESSION);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REORDER_COLUMNS);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.eobjects.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(AbstractBeanJobBuilder<?, ?, ?> beanJobBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(beanJobBuilder, propertyDescriptor);
    setBorder(new EtchedBorder(EtchedBorder.LOWERED));
    _checkBoxes = new LinkedHashMap<InputColumn<?>, DCCheckBox<InputColumn<?>>>();
    _checkBoxDecorations = new IdentityHashMap<DCCheckBox<InputColumn<?>>, JComponent>();
    _firstUpdate = true;//from www  .ja  va 2s. c  o  m
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().getSourceColumnListeners().add(this);
    getAnalysisJobBuilder().getTransformerChangeListeners().add(this);
    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(new CompoundBorder(_indentBorder, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.indexOf(text) != -1);
                }
            }
        }
    });

    _notAvailableCheckBox = new DCCheckBox<InputColumn<?>>("<html><font color=\"gray\">- no <i>"
            + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(_indentBorder);

    JButton selectAllButton = new JButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = new JButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.BUTTON_EXPRESSION_COLUMN_IMAGEPATH);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory
                .createSmallButton(IconUtils.BUTTON_REORDER_COLUMN_IMAGEPATH);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.ut.biolab.medsavant.client.view.dialog.SavantExportForm.java

private void export() throws InterruptedException, IOException, SQLException, RemoteException {
    try {//from ww w . j a  va2  s  .c  om
        //get selected DNA IDs
        List<String> selectedIds = new ArrayList<String>();
        for (JCheckBox box : checkBoxes) {
            if (box.isSelected()) {
                selectedIds.add(box.getText());
            }
        }
        if (selectedIds.isEmpty()) {
            progressLabel.setText("No individuals selected");
            progressDialog.setVisible(false);
            this.setVisible(true);
            return;
        }

        //get bookmarks
        Map<String, List<String>> map = MedSavantClient.VariantManager.getSavantBookmarkPositionsForDNAIDs(
                LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(),
                ReferenceController.getInstance().getCurrentReferenceID(),
                FilterController.getInstance().getAllFilterConditions(), selectedIds, -1);

        //get BAM files
        Collection<String> bamFiles = MedSavantClient.PatientManager.getValuesFromDNAIDs(
                LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(),
                BasicPatientColumns.BAM_URL.getColumnName(), selectedIds).values();

        //genome version
        String genomeName = ReferenceController.getInstance().getCurrentReferenceName();
        String genomeUrl = ReferenceController.getInstance().getCurrentReferenceUrl();

        //create file
        BufferedWriter out = new BufferedWriter(new FileWriter(outputFile));

        out.write("<?xml version=\"1.0\" ?>\n" + "<savant version=\"1\" range=\"chr1:1-1000\">\n");

        if (genomeUrl != null) {
            out.write(" <genome name=\"" + genomeName + "\" uri=\"" + genomeUrl + "\" />\n");
        } else {
            out.write(" <genome name=\"" + genomeName + "\" >\n");
            for (Chromosome c : ReferenceController.getInstance().getChromosomes()) {
                out.write("   <reference name=\"" + c.getName() + "\" length=\"" + c.getLength() + "\" />\n");
            }
            out.write(" </genome>\n");
        }

        for (String path : bamFiles) {
            out.write("  <track uri=\"" + path + "\"/>\n");
        }

        Object[] keys = map.keySet().toArray();
        for (Object keyObject : keys) {
            String key = (String) keyObject;
            List<String> positions = map.get(key);
            for (String p : positions) {
                out.write("  <bookmark range=\"" + p + "\">" + key + "</bookmark>\n");
            }
        }

        out.write("</savant>\n");

        //out.write(s);
        out.close();

        progressDialog.setVisible(false);
        setVisible(false);
        progressDialog.dispose();
        dispose();
    } catch (SessionExpiredException ex) {
        MedSavantExceptionHandler.handleSessionExpiredException(ex);
        return;
    }
}

From source file:org.yccheok.jstock.gui.StockJDialog.java

public java.util.List<StockInfo> buildSelectedStockInfos() {
    java.util.List<StockInfo> selectedStockInfos = new java.util.ArrayList<StockInfo>();

    JStock m = JStock.instance();/*w w  w .  jav  a  2 s.  c o  m*/

    StockInfoDatabase stock_info_database = m.getStockInfoDatabase();
    if (stock_info_database == null) {
        log.error("Unable to locate MainFrame");
        return null;
    }

    if (jRadioButton2.isSelected()) {
        selectedStockInfos.addAll(stock_info_database.getStockInfos());
        return selectedStockInfos;
    }

    if (jRadioButton3.isSelected()) {
        for (JCheckBox checkBox : boardCheckBoxes) {
            if (checkBox.isSelected() == false)
                continue;

            final Board board = this.checkBoxToBoard.get(checkBox);

            if (board == null) {
                log.error("Wrong text in JCheckBox GUI : " + checkBox.getText());
                continue;
            }

            selectedStockInfos.addAll(stock_info_database.getStockInfos(board));
        }

        return selectedStockInfos;
    }

    if (jRadioButton4.isSelected()) {
        for (JCheckBox checkBox : industryCheckBoxes) {
            if (checkBox.isSelected() == false)
                continue;

            final Industry industry = this.checkBoxToIndustry.get(checkBox);

            if (industry == null) {
                log.error("Wrong text in JCheckBox GUI : " + checkBox.getText());
                continue;
            }

            selectedStockInfos.addAll(stock_info_database.getStockInfos(industry));
        }

        return selectedStockInfos;
    }

    return null;
}

From source file:org.yccheok.jstock.gui.WizardSelectStockJPanel.java

public boolean buildSelectedStockCodes() {
    selectedStockInfos.clear();// w w w  .java2s.  c  o  m

    JStock m = JStock.instance();
    StockInfoDatabase stock_info_database = m.getStockInfoDatabase();
    if (stock_info_database == null) {
        log.error("Unable to locate MainFrame");
        return false;
    }

    if (jRadioButton1.isSelected()) {
        selectedStockInfos.addAll(stock_info_database.getStockInfos());
        return true;
    }

    if (jRadioButton2.isSelected()) {
        for (JCheckBox checkBox : boardCheckBoxes) {
            if (checkBox.isSelected() == false)
                continue;

            final Board board = this.checkBoxToBoard.get(checkBox);

            if (board == null) {
                log.error("Wrong text in JCheckBox GUI : " + checkBox.getText());
                continue;
            }

            selectedStockInfos.addAll(stock_info_database.getStockInfos(board));
        }

        return true;
    }

    if (jRadioButton3.isSelected()) {
        for (JCheckBox checkBox : industryCheckBoxes) {
            if (checkBox.isSelected() == false)
                continue;

            final Industry industry = this.checkBoxToIndustry.get(checkBox);

            if (industry == null) {
                log.error("Wrong text in JCheckBox GUI : " + checkBox.getText());
                continue;
            }

            selectedStockInfos.addAll(stock_info_database.getStockInfos(industry));
        }

        return true;
    }

    if (jRadioButton4.isSelected()) {
        java.util.List<Stock> stocks = m.getStocks();
        for (Stock stock : stocks) {
            selectedStockInfos.add(StockInfo.newInstance(stock));
        }

        return true;
    }

    return false;
}