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:org.zaproxy.zap.extension.cmss.CMSSFrame.java

private ArrayList<String> getWhatToFingerprint() {
    ArrayList<String> WhatToFingerprint = new ArrayList<String>();
    for (JCheckBox checkBox : checkBoxesList) {
        if (checkBox.isSelected()) {
            System.out.println("check boxe : " + checkBox.getText());
            WhatToFingerprint.add(checkBox.getText());
        }//from   w ww . j a  v  a  2  s .  c o  m
    }
    return WhatToFingerprint;
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void mouseClicked(MouseEvent event, final StateRenderer2D source) {

    if (event.getButton() == MouseEvent.BUTTON3) {
        final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
        JPopupMenu popup = new JPopupMenu();
        for (String type : positions.keySet()) {
            JMenu menu = new JMenu(type + "s");
            for (final AssetPosition p : positions.get(type)) {

                if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection)
                    continue;

                Color c = cmap.getColor(1 - (p.getAge() / (7200000.0)));
                String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue());
                menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p)
                        + "</font>").addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                source.focusLocation(p.getLoc());
                            }/*w  w  w . j a v  a2 s .  c o  m*/
                        });
            }
            popup.add(menu);
        }

        popup.addSeparator();
        popup.add("Settings").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PluginUtils.editPluginProperties(SituationAwareness.this, true);
            }
        });

        popup.add("Fetch asset properties").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //                    for (AssetTrack track : assets.values()) {
                //                        track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
                //                    }
                fetchAssetProperties();
            }
        });

        popup.add("Select location sources").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (ILocationProvider l : localizers) {
                    JCheckBox check = new JCheckBox(l.getName());
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(updateMethodNames.contains(l.getName()));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> methods = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            methods.add(sel.getText());
                    }
                }
                updateMethods = StringUtils.join(methods, ", ");
                propertiesChanged();
            }
        });

        popup.add("Select hidden positions types").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (String type : positions.keySet()) {
                    JCheckBox check = new JCheckBox(type);
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(hiddenPosTypes.contains(type));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> types = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            types.add(sel.getText());
                    }
                }
                hiddenTypes = StringUtils.join(types, ", ");
                propertiesChanged();
            }
        });

        popup.addSeparator();
        popup.add("Decision Support").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (dialogDecisionSupport == null) {
                    dialogDecisionSupport = new JDialog(getConsole());
                    dialogDecisionSupport.setModal(false);
                    dialogDecisionSupport.setAlwaysOnTop(true);
                    dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                }
                ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>();
                LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
                Vector<AssetPosition> spots = positions.get("SPOT Tag");
                Vector<AssetPosition> argos = positions.get("Argos Tag");
                if (spots != null)
                    tags.addAll(spots);
                if (argos != null)
                    tags.addAll(argos);
                if (!assets.containsKey(getConsole().getMainSystem())) {
                    GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown");
                    return;
                }
                supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags);
                JXTable table = new JXTable(supportTable);
                dialogDecisionSupport.setContentPane(new JScrollPane(table));
                dialogDecisionSupport.invalidate();
                dialogDecisionSupport.validate();
                dialogDecisionSupport.setSize(600, 300);
                dialogDecisionSupport.setTitle("Decision Support Table");
                dialogDecisionSupport.setVisible(true);
                dialogDecisionSupport.toFront();
                GuiUtils.centerOnScreen(dialogDecisionSupport);
            }
        });
        popup.show(source, event.getX(), event.getY());
    }
    super.mouseClicked(event, source);
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

private void jButtonExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportActionPerformed
    if (jTreeResults.getModel().getChildCount(jTreeResults.getModel().getRoot()) == 0) {
        JOptionPane.showMessageDialog(this, "You can't export information without search results.",
                "Lack of Search Results", JOptionPane.INFORMATION_MESSAGE);
        return;/*from   w  ww .  j  a  v  a2  s  .c  o  m*/
    }

    ExportData ed;

    HashMap<String, Boolean> plugins = new HashMap<String, Boolean>();
    for (JCheckBox box : this.ranges) {
        plugins.put(box.getText(), box.isSelected());
    }
    if (!lastQueryAdvanced) {

        ed = new ExportData(lastQueryExecuted, lastQueryKeywords, plugins);
    } else {
        ed = new ExportData(lastQueryExecuted, true, plugins);
    }

    ed.setVisible(true);
    ed.toFront();
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

public void search() {

    Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, "State: " + state);
    if (state == QUERY_STATE.WAITING_FOR_RESULTS) {

        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, "Prunning query");

        pruneQuery();/* w ww .  j  av a  2  s  .  com*/
        return;
    }

    this.jButtonDownload.setEnabled(false);
    lastQueryExecuted = jTextFieldQuery.getText();
    lastQueryKeywords = jCheckBoxKeywords.isSelected();
    lastQueryAdvanced = false;
    HashMap<String, Boolean> plugins = new HashMap<String, Boolean>();
    boolean isSelectedPlugins = false;
    for (JCheckBox box : this.ranges) {
        plugins.put(box.getText(), box.isSelected());
        isSelectedPlugins = isSelectedPlugins || box.isSelected();
    }
    if (!isSelectedPlugins) {
        JOptionPane.showMessageDialog(this, "Please select a source to search", "Missing data source",
                JOptionPane.INFORMATION_MESSAGE);
    } else {
        basicSearch = true;
        searchTree.search(lastQueryExecuted, lastQueryKeywords, plugins);
        state = QUERY_STATE.WAITING_FOR_RESULTS;
        jButtonSearch.setText("Cancel");
        cleanThumbnails();
        QueryHistorySupport.getInstance().saveQueryHistory();
    }

}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

private void AdvancedSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdvancedSearchButtonActionPerformed
    lastQueryExecuted = getAdvancedQuery();
    lastQueryAdvanced = true;/*from  w ww. j ava 2s. c  o  m*/
    HashMap<String, Boolean> plugins = new HashMap<String, Boolean>();
    for (JCheckBox box : this.ranges) {
        plugins.put(box.getText(), box.isSelected());
    }
    searchTree.search(lastQueryExecuted, true, plugins);

    cleanThumbnails();
}

From source file:rita.ui.component.DialogSelectEnemies.java

/**
 * Recorre el directorio robots y agrega al panel a todos los robots
 * (.class) instalados/*  w w w . j  a v a  2s.  c  om*/
 * 
 * @throws FileNotFoundException
 *             si no hay .class en el dir File(Settings.getInstallPath(),
 *             "robots")
 */
private void addRobotsToPanel(JPanel panel) throws FileNotFoundException {
    if (Settings.getInstallPath() == null) {
        throw new FileNotFoundException(
                "La carpeta de robots no pudo ser encontrara porque InstallPath no esta definido");
    }
    File robotDir = new File(Settings.getInstallPath(), "robots");
    if (!robotDir.isDirectory() || !robotDir.canRead()) {
        //otra carpeta posible MVN
        robotDir = new File(Settings.getInstallPath() + Settings.getMvnResourcesPath(), "robots");
        if (!robotDir.isDirectory() || !robotDir.canRead())
            throw new FileNotFoundException(
                    "La carpeta de robots " + robotDir + " no existe o no tiene permisos de lectura");
    }
    boolean robotFound = false;
    // recorrer directorio robots y traer todos los robots instalados
    JCheckBox cb;
    JButton buttonPos;

    /*
     * buscar recursivametne a todos los .class en InstallPath() + "robots",
     * excluyendo a las inner clases, porque asumimos que son clases de
     * implementacion. Las reconocemos porque tienen '$' en el nombre de la
     * clase.
     */

    for (File f : FileUtils.listFiles(robotDir, new String[] { "class" }, true)) {
        if (f.getName().endsWith(".class") && f.getName().indexOf('$') == -1) {
            String[] splitPath = f.getParent().split(pattern);
            /*
             * si el path del robot tiene directorio/nombrerobot.class => el
             * nombre del robot es "directorio.nombrerobot", sino es solo
             * "nombrerobot"
             */
            if (splitPath.length > 0) {
                cb = new JCheckBox(splitPath[splitPath.length - 1] + "."
                        + f.getName().substring(0, f.getName().lastIndexOf('.')), false);
            } else {
                cb = new JCheckBox(f.getName().substring(0, f.getName().lastIndexOf('.')), false);
            }

            JPanel panelCheckButton = new JPanel();
            buttonPos = new JButton(icon);
            buttonPos.addActionListener(new PosicionRobotAction(cb.getText()));
            buttonPos.setPreferredSize(new Dimension(30, 30));
            positionComponents.add(buttonPos);

            cb.addActionListener(robotNameClicked);
            cb.setPreferredSize(new Dimension(160, 30));
            panelCheckButton.add(cb);

            panelCheckButton.add(buttonPos);
            panel.add(panelCheckButton);
            robotFound = true;
        }
    }
    if (!robotFound) {
        throw new FileNotFoundException("La carpeta de robots no contiene robots");
    }
}

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java

private void filterCheckBoxList(String text) {
    checkPanel.remove(emptyLabel);//from   w w  w.j  a va 2 s . c o  m

    if (StringUtils.isEmpty(text)) {
        for (JCheckBox item : checkBoxMenuItems) {
            checkPanel.remove(item);//removes item, so no duplicate will occure
            checkPanel.add(item);//add new item
        }

        mainPanel.revalidate();
        mainPanel.repaint();

        popup.revalidate();
        popup.repaint();

        return;
    }
    boolean empty = true;
    for (JCheckBox item : checkBoxMenuItems) {
        checkPanel.remove(item);//removes item, so no duplicate will occure

        if (item.getText().toLowerCase().contains(text.toLowerCase())) {
            empty = false;
            checkPanel.add(item);//add new item
        }
    }
    if (empty) {
        checkPanel.add(emptyLabel);
    }

    mainPanel.revalidate();
    mainPanel.repaint();

    popup.revalidate();
    popup.repaint();
}

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java

/**
 * returns labels of all selected JCheckBoxMenuItem
 *
 * @return//from w ww  .  ja  v a  2  s  .  c o m
 */
public List<String> getSelectedCheckBoxItems() {
    List<String> list = new LinkedList<String>();
    for (JCheckBox item : checkBoxMenuItems) {
        if (item.isSelected()) {
            list.add(item.getText());
        }
    }
    return list;
}

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java

public void removeCheckBoxMenuItem(TopologyVertex deletedVertex) {
    for (JCheckBox check : checkBoxMenuItems) {
        if (check.getText().equals(deletedVertex.getName())) {
            checkPanel.remove(check);/*from  w  ww.ja  v a2 s  . c  o m*/
            return;
        }
    }
    throw new IllegalStateException("unknown checkbox to delete: " + deletedVertex.getName());
}