Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

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

Prototype

public JCheckBox(String text, Icon icon) 

Source Link

Document

Creates an initially unselected check box with the specified text and icon.

Usage

From source file:net.atomique.ksar.graph.Graph.java

public Graph(kSar hissar, GraphConfig g, String Title, String hdrs, int firstdatacolumn, SortedTreeNode pp) {
    mysar = hissar;//  w  w w .j  av a2  s  .  co  m
    graphtitle = Title;
    graphconfig = g;
    printCheckBox = new JCheckBox(graphtitle, printSelected);
    printCheckBox.addItemListener((ItemEvent evt) -> {

        if (evt.getSource() == printCheckBox) {
            printSelected = printCheckBox.isSelected();
        }

    });
    firstDataColumn = firstdatacolumn;
    if (pp != null) {
        TreeNodeInfo infotmp = new TreeNodeInfo(Title, this);
        SortedTreeNode nodetmp = new SortedTreeNode(infotmp);
        mysar.add2tree(pp, nodetmp);
    }
    HeaderStr = hdrs.split("\\s+");
    create_DataStore();
}

From source file:net.sourceforge.doddle_owl.ui.GeneralOntologySelectionPanel.java

public GeneralOntologySelectionPanel(NameSpaceTable nsTable) {
    nameSpaceTable = nsTable;/* w w w.  ja  v  a  2  s  . c om*/
    edrCheckBox = new JCheckBox(Translator.getTerm("GenericEDRCheckBox"), false);
    edrCheckBox.addActionListener(this);
    edrtCheckBox = new JCheckBox(Translator.getTerm("TechnicalEDRCheckBox"), false);
    edrtCheckBox.addActionListener(this);
    wnCheckBox = new JCheckBox(Translator.getTerm("WordNetCheckBox"), false);
    wnCheckBox.addActionListener(this);
    wnVersionSelectionPanel = new JPanel();
    wn30RadioButton = new JRadioButton("3.0");
    wn30RadioButton.addChangeListener(this);
    wn31RadioButton = new JRadioButton("3.1");
    wn31RadioButton.setSelected(true);
    wn31RadioButton.addChangeListener(this);
    ButtonGroup group = new ButtonGroup();
    group.add(wn30RadioButton);
    group.add(wn31RadioButton);
    wnVersionSelectionPanel.add(wnCheckBox);
    wnVersionSelectionPanel.add(wn30RadioButton);
    wnVersionSelectionPanel.add(wn31RadioButton);
    JPanel borderPanel = new JPanel();
    borderPanel.setLayout(new BorderLayout());
    borderPanel.add(wnVersionSelectionPanel, BorderLayout.WEST);

    jpnWnCheckBox = new JCheckBox(Translator.getTerm("JpnWordNetCheckBox"), false);
    jpnWnCheckBox.addActionListener(this);
    jwoCheckBox = new JCheckBox(Translator.getTerm("JWOCheckBox"), false);
    jwoCheckBox.addActionListener(this);
    JPanel checkPanel = new JPanel();
    checkPanel.add(borderPanel);
    checkPanel.add(jpnWnCheckBox);
    checkPanel.add(jwoCheckBox);
    checkPanel.add(edrCheckBox);
    checkPanel.add(edrtCheckBox);
    setLayout(new BorderLayout());
    add(checkPanel, BorderLayout.WEST);

    generalOntologyDirLabel = new JLabel(Utils.TEMP_DIR);
    removeGeneralOntologyDirButton = new JButton(Translator.getTerm("RemoveGeneralOntologyDirectoryButton"));
    removeGeneralOntologyDirButton.addActionListener(this);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(generalOntologyDirLabel, BorderLayout.CENTER);
    buttonPanel.add(removeGeneralOntologyDirButton, BorderLayout.WEST);
    add(buttonPanel, BorderLayout.SOUTH);
}

From source file:org.jax.bham.test.PhenotypeEffectPlotPanel.java

/**
 * Constructor//from w w  w.  j av  a 2 s  .c  o m
 * @param phenotypeDataSource
 *          the phenotype data source
 * @param strainGroups
 *          the strain groupings
 */
public PhenotypeEffectPlotPanel(PhenotypeDataSource phenotypeDataSource,
        Map<String, ? extends Collection<String>> strainGroups) {
    super(new BorderLayout());

    this.chartPanel = new ChartPanel(null, true);
    this.showIndividualStrainEffectsCheckBox = new JCheckBox("Show Individual Strain Effects", false);
    this.phenotypeDataSource = phenotypeDataSource;
    this.phenotypeData = phenotypeDataSource.getPhenotypeData();
    this.strainGroups = strainGroups;

    this.updateChart();

    JToolBar toolBar = new JToolBar();
    toolBar.add(this.showIndividualStrainEffectsCheckBox);
    this.showIndividualStrainEffectsCheckBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            PhenotypeEffectPlotPanel.this.updateChart();
        }
    });

    this.add(toolBar, BorderLayout.PAGE_START);
    this.add(this.chartPanel, BorderLayout.CENTER);
}

From source file:MessageDigestTest.java

public void addCheckBox(Container c, String name, ButtonGroup g, boolean selected, ActionListener listener) {
    JCheckBox b = new JCheckBox(name, selected);
    c.add(b);/*from  w ww. j  a  v a2 s.co  m*/
    g.add(b);
    b.addActionListener(listener);
}

From source file:com.emental.mindraider.ui.dialogs.NewRdfModelJDialog.java

/**
 * Constructor./*from w  w w. ja  va  2 s .  c  om*/
 */
public NewRdfModelJDialog() {

    super(Messages.getString("NewRdfModelJDialog.title"));

    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridLayout(3, 1));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(Messages.getString("NewRdfModelJDialog.subject")));

    subjectNs = new JTextField(30);
    subjectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    p.add(subjectNs);
    p.add(new JLabel("#"));

    subjectLocalName = new JTextField(15);
    p.add(subjectLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox literalCheckBox = new JCheckBox("literal", false);
    p.add(literalCheckBox);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton(Messages.getString("NewRdfModelJDialog.create"));
    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createModel(literalCheckBox);
        }
    });

    JButton cancelButton = new JButton(Messages.getString("NewRdfModelJDialog.cancel"));
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            NewRdfModelJDialog.this.dispose();
        }
    });
    framePanel.add(p);

    subjectLocalName.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                createModel(literalCheckBox);
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);

    addWindowListener(new WindowAdapter() {

        public void windowActivated(WindowEvent e) {
            subjectLocalName.requestFocusInWindow();
        }
    });
}

From source file:ComponentEventDemo.java

public ComponentEventDemo() {
    super(new BorderLayout());

    display = new JTextArea();
    display.setEditable(false);/*from   w w w. j  a va  2 s. com*/
    JScrollPane scrollPane = new JScrollPane(display);
    scrollPane.setPreferredSize(new Dimension(350, 200));

    JPanel panel = new JPanel(new BorderLayout());
    label = new JLabel("This is a label", JLabel.CENTER);
    label.addComponentListener(this);
    panel.add(label, BorderLayout.CENTER);

    JCheckBox checkbox = new JCheckBox("Label visible", true);
    checkbox.addItemListener(this);
    checkbox.addComponentListener(this);
    panel.add(checkbox, BorderLayout.PAGE_END);
    panel.addComponentListener(this);

    add(scrollPane, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
    frame.addComponentListener(this);
}

From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java

public CheapTimePanel() {
    setLayout(new BorderLayout());
    groupByMachineCheckBox = new JCheckBox("Group by assigned machine", false);
    groupByMachineCheckBox.setHorizontalAlignment(SwingConstants.RIGHT);
    groupByMachineCheckBox.addActionListener(new ActionListener() {
        @Override//  ww w . j ava2s  .c  o m
        public void actionPerformed(ActionEvent e) {
            updatePanel(solutionBusiness.getSolution());
            validate();
        }
    });
}

From source file:net.pms.encoders.AviSynthMEncoder.java

@Override
public JComponent config() {
    FormLayout layout = new FormLayout("left:pref, 0:grow",
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 12dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.EMPTY);/*from  w ww  .jav  a  2 s.  co m*/
    builder.opaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(2, 1, 1));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"),
            configuration.getAvisynthMultiThreading());
    multithreading.setContentAreaFilled(false);
    multithreading.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthMultiThreading((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3));

    interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"),
            configuration.getAvisynthInterFrame());
    interframe.setContentAreaFilled(false);
    interframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            configuration.setAvisynthInterFrame(interframe.isSelected());
            if (configuration.getAvisynthInterFrame()) {
                JOptionPane.showMessageDialog(
                        SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()),
                        Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"),
                        JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5));

    interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"),
            configuration.getAvisynthInterFrameGPU());
    interframegpu.setContentAreaFilled(false);
    interframegpu.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7));

    convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"), configuration.getAvisynthConvertFps());
    convertfps.setContentAreaFilled(false);
    convertfps.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9));

    String aviSynthScriptInstructions = Messages.getString("AviSynthMEncoder.4")
            + Messages.getString("AviSynthMEncoder.5") + Messages.getString("AviSynthMEncoder.6")
            + Messages.getString("AviSynthMEncoder.7") + Messages.getString("AviSynthMEncoder.8");
    JTextArea aviSynthScriptInstructionsContainer = new JTextArea(aviSynthScriptInstructions);
    aviSynthScriptInstructionsContainer.setEditable(false);
    aviSynthScriptInstructionsContainer.setBorder(BorderFactory.createEtchedBorder());
    aviSynthScriptInstructionsContainer.setBackground(new Color(255, 255, 192));
    aviSynthScriptInstructionsContainer.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)),
                    BorderFactory.createEmptyBorder(3, 5, 3, 5)));
    builder.add(aviSynthScriptInstructionsContainer, cc.xy(2, 11));

    String clip = configuration.getAvisynthScript();
    if (clip == null) {
        clip = "";
    }
    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(clip, PMS.AVS_SEPARATOR);
    int i = 0;
    while (st.hasMoreTokens()) {
        if (i > 0) {
            sb.append("\n");
        }
        sb.append(st.nextToken());
        i++;
    }
    textArea = new JTextArea(sb.toString());
    textArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            StringBuilder sb = new StringBuilder();
            StringTokenizer st = new StringTokenizer(textArea.getText(), "\n");
            int i = 0;
            while (st.hasMoreTokens()) {
                if (i > 0) {
                    sb.append(PMS.AVS_SEPARATOR);
                }
                sb.append(st.nextToken());
                i++;
            }
            configuration.setAvisynthScript(sb.toString());
        }
    });

    JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(new Dimension(500, 350));
    builder.add(pane, cc.xy(2, 13));

    configuration.addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            if (event.getPropertyName() == null) {
                return;
            }
            if ((!event.isBeforeUpdate())
                    && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) {
                interframegpu.setEnabled(configuration.isGPUAcceleration());
            }
        }
    });

    return builder.getPanel();
}

From source file:com.romraider.logger.ecu.ui.handler.graph.GraphUpdateHandler.java

public GraphUpdateHandler(final JPanel panel) {
    this.graphPanel = new JPanel(new SpringLayout());
    final JCheckBox combinedCheckbox = new JCheckBox("Combine Graphs", combinedChart);
    combinedCheckbox.addActionListener(new CombinedActionListener(combinedCheckbox));
    JToggleButton playPauseButton = new JToggleButton("Pause Graphs");
    playPauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            paused = !paused;//from   w  w w . j ava 2s.co m
            if (paused) {
                pauseStartTime = System.currentTimeMillis();
            } else {
                startTime = startTime + (System.currentTimeMillis() - pauseStartTime);
            }
        }
    });
    panel.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(getKeyStroke("F12"), "toggleCombineGraphs");
    panel.getActionMap().put("toggleCombineGraphs", new AbstractAction() {
        private static final long serialVersionUID = 1540427179539775534L;

        public void actionPerformed(ActionEvent e) {
            combinedCheckbox.doClick();
        }
    });
    JPanel controlPanel = new JPanel();
    controlPanel.add(combinedCheckbox);
    controlPanel.add(playPauseButton);
    panel.add(controlPanel, NORTH);
    panel.add(this.graphPanel, CENTER);
}

From source file:es.uvigo.ei.sing.adops.views.TextFileViewer.java

public TextFileViewer(final File file) {
    super(new BorderLayout());

    this.file = file;

    // TEXT AREA//  ww w. j a  v a2s. c  o m
    this.textArea = new JTextArea(TextFileViewer.loadFile(file));
    this.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, this.textArea.getFont().getSize()));
    this.textArea.setLineWrap(true);
    this.textArea.setWrapStyleWord(true);
    this.textArea.setEditable(false);

    this.highlightPatiner = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);

    // OPTIONS PANEL
    final JPanel panelOptions = new JPanel(new BorderLayout());
    final JPanel panelOptionsEast = new JPanel(new FlowLayout());
    final JPanel panelOptionsWest = new JPanel(new FlowLayout());
    final JCheckBox chkLineWrap = new JCheckBox("Line wrap", true);
    final JButton btnChangeFont = new JButton("Change Font");

    final JLabel lblSearch = new JLabel("Search");
    this.txtSearch = new JTextField();
    this.chkRegularExpression = new JCheckBox("Reg. exp.", true);
    final JButton btnSearch = new JButton("Search");
    final JButton btnClear = new JButton("Clear");
    this.txtSearch.setColumns(12);
    // this.txtSearch.setOpaque(true);

    panelOptionsEast.add(btnChangeFont);
    panelOptionsEast.add(chkLineWrap);
    panelOptionsWest.add(lblSearch);
    panelOptionsWest.add(this.txtSearch);
    panelOptionsWest.add(this.chkRegularExpression);
    panelOptionsWest.add(btnSearch);
    panelOptionsWest.add(btnClear);

    if (FastaUtils.isFasta(file)) {
        panelOptionsWest.add(new JSeparator());

        final JButton btnExport = new JButton("Export...");

        panelOptionsWest.add(btnExport);

        btnExport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new ExportDialog(file).setVisible(true);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(Workbench.getInstance().getMainFrame(),
                            "Error reading fasta file: " + e1.getMessage(), "Export Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }

    panelOptions.add(panelOptionsWest, BorderLayout.WEST);
    panelOptions.add(panelOptionsEast, BorderLayout.EAST);

    this.fontChooser = new JFontChooser();

    this.add(new JScrollPane(this.textArea), BorderLayout.CENTER);
    this.add(panelOptions, BorderLayout.NORTH);

    chkLineWrap.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            textArea.setLineWrap(chkLineWrap.isSelected());
        }
    });

    btnChangeFont.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            changeFont();
        }
    });

    this.textArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }
    });

    this.textArea.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (TextFileViewer.this.wasModified) {
                try {
                    FileUtils.write(TextFileViewer.this.file, TextFileViewer.this.textArea.getText());
                    TextFileViewer.this.wasModified = false;
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    final ActionListener alSearch = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateSearch();
        }
    };
    txtSearch.addActionListener(alSearch);
    btnSearch.addActionListener(alSearch);

    btnClear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSearch();
        }
    });
}