Java Code Examples for javax.swing.JCheckBox#addChangeListener()
The following examples show how to use
javax.swing.JCheckBox#addChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TradesFrameHandler.java From ib-controller with GNU General Public License v3.0 | 6 votes |
private void monitorAllTradesCheckbox(Window window, String text) { final JCheckBox check = SwingUtils.findCheckBox(window, text); if (check != null) check.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent ce) { Utils.logToConsole("Checkbox: " + check.getText() + "; selected=" + check.isSelected()); if (!check.isSelected()) { GuiDeferredExecutor.instance().execute(new Runnable() { @Override public void run(){ Utils.logToConsole("Checkbox: " + check.getText() + "; setting selected"); if (!check.isSelected()) check.doClick(); } }); } } }); }
Example 2
Source File: CollapsiblePanel.java From beautyeye with Apache License 2.0 | 6 votes |
protected Component createCollapseControl(String title, String tooltip) { // Add upper panel to hold collapse control Box box = Box.createHorizontalBox(); expandCheckBox = new JCheckBox(title); expandCheckBox.setBorder(new EmptyBorder(0,4,0,0)); expandCheckBox.setToolTipText(tooltip); expandCheckBox.setHorizontalTextPosition(JCheckBox.RIGHT); expandCheckBox.setSelectedIcon(new ArrowIcon(ArrowIcon.SOUTH)); expandCheckBox.setIcon(new ArrowIcon(ArrowIcon.EAST)); expandCheckBox.setSelected(isExpanded()); expandCheckBox.addChangeListener(new CollapseListener()); box.add(expandCheckBox); return box; }
Example 3
Source File: CollapsiblePanel.java From littleluck with Apache License 2.0 | 6 votes |
protected Component createCollapseControl(String title, String tooltip) { // Add upper panel to hold collapse control Box box = Box.createHorizontalBox(); expandCheckBox = new JCheckBox(title); expandCheckBox.setOpaque(false); expandCheckBox.setBorder(new EmptyBorder(0,4,0,0)); expandCheckBox.setToolTipText(tooltip); expandCheckBox.setHorizontalTextPosition(JCheckBox.RIGHT); expandCheckBox.setSelectedIcon(new ArrowIcon(ArrowIcon.SOUTH)); expandCheckBox.setIcon(new ArrowIcon(ArrowIcon.EAST)); expandCheckBox.setSelected(isExpanded()); expandCheckBox.addChangeListener(new CollapseListener()); box.add(expandCheckBox); return box; }
Example 4
Source File: KwikiDateModesSelectorPanel.java From ET_Redux with Apache License 2.0 | 6 votes |
private void SetupSliderLockCheckBox () { ChangeListener sliderLockChangeListener = new ChangeListener() { public void stateChanged ( ChangeEvent changeEvent ) { propertySupport.firePropertyChange(// SLIDER_LOCK_PROPERTY, "", String.valueOf( ((JCheckBox) changeEvent.getSource()).isSelected() ) ); } }; sliderLockCheckBox = new JCheckBox( "Lock Uncertainties" ); sliderLockCheckBox.setOpaque( false ); sliderLockCheckBox.setForeground( new java.awt.Color( 204, 0, 0 ) ); sliderLockCheckBox.setFont( new Font( "SansSerif", Font.BOLD, 9 ) ); sliderLockCheckBox.setBounds( 1, 60, 120, 15 ); sliderLockCheckBox.addChangeListener( sliderLockChangeListener ); add( sliderLockCheckBox, javax.swing.JLayeredPane.DEFAULT_LAYER ); }
Example 5
Source File: ScoreGraph.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public JComponent getGUIComponent() { JComponent selectionPanel = Box.createVerticalBox(); final XYItemRenderer renderer = ((XYPlot)chart.getPlot()).getRenderer(); for (SeriesInfo next : allSeries) { final ScoreFunction f = next.function; final int index = next.index; final JCheckBox checkBox = new JCheckBox(f.getName(), true); selectionPanel.add(checkBox); checkBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { boolean selected = checkBox.isSelected(); renderer.setSeriesVisible(index, selected); } }); } JPanel result = new JPanel(); result.add(new ChartPanel(chart), BorderLayout.CENTER); result.add(selectionPanel, BorderLayout.EAST); return result; }
Example 6
Source File: VisiblePanel.java From Gaalop with GNU Lesser General Public License v3.0 | 6 votes |
/** * Sets all objects * @param names The names of the objects * @param renderingExpressions The expressions of the objects */ public void setObjects(Set<String> names, HashMap<String, Expression> renderingExpressions) { panel.removeAll(); panel.setSize(panel.getWidth(),25*names.size()); panel.setLayout(new GridLayout((names.size() < 8) ? 8-names.size(): names.size(), 1, 5, 5)); boxes.clear(); for (String input: names) { JCheckBox box = (input.endsWith("_S")) ? new JCheckBox(renderingExpressions.get(input.substring(0, input.length()-2)).toString(), true) : new JCheckBox(renderingExpressions.get(input).toString()); box.addChangeListener(this); boxes.put(box, input); panel.add(box); } }
Example 7
Source File: HintsPanelLogic.java From netbeans with Apache License 2.0 | 6 votes |
void connect( JTree errorTree, DefaultTreeModel errModel, JComboBox severityComboBox, JCheckBox tasklistCheckBox, JPanel customizerPanel, JEditorPane descriptionTextArea) { this.errorTree = errorTree; this.errModel = errModel; this.severityComboBox = severityComboBox; this.tasklistCheckBox = tasklistCheckBox; this.customizerPanel = customizerPanel; this.descriptionTextArea = descriptionTextArea; valueChanged( null ); errorTree.addKeyListener(this); errorTree.addMouseListener(this); errorTree.getSelectionModel().addTreeSelectionListener(this); severityComboBox.addActionListener(this); tasklistCheckBox.addChangeListener(this); }
Example 8
Source File: HintsPanelLogic.java From netbeans with Apache License 2.0 | 6 votes |
void connect( JTree errorTree, JComboBox severityComboBox, JCheckBox tasklistCheckBox, JPanel customizerPanel, JEditorPane descriptionTextArea) { this.errorTree = errorTree; this.severityComboBox = severityComboBox; this.tasklistCheckBox = tasklistCheckBox; this.customizerPanel = customizerPanel; this.descriptionTextArea = descriptionTextArea; valueChanged( null ); errorTree.addKeyListener(this); errorTree.addMouseListener(this); errorTree.getSelectionModel().addTreeSelectionListener(this); severityComboBox.addActionListener(this); tasklistCheckBox.addChangeListener(this); }
Example 9
Source File: MarkOccurencesPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void addListeners() { ChangeListener cl = new CheckChangeListener(); for( JCheckBox box : boxes ) { box.addChangeListener(cl); } }
Example 10
Source File: PageableTable.java From jdal with Apache License 2.0 | 5 votes |
/** * @param cd */ public VisibilityItem(ColumnDescriptor cd) { this.cd = cd; BoxLayout layout = new BoxLayout(this, BoxLayout.LINE_AXIS); setLayout(layout); this.setAlignmentX(0f); check = new JCheckBox(cd.getDisplayName(), cd.isVisible()); check.setAlignmentX(0f); add(check); check.addChangeListener(this); refresh(); }
Example 11
Source File: TradesFrameHandler.java From IBC with GNU General Public License v3.0 | 5 votes |
private void monitorAllTradesCheckbox(Window window, String text) { final JCheckBox check = SwingUtils.findCheckBox(window, text); if (check != null) check.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent ce) { Utils.logToConsole("Checkbox: " + check.getText() + "; selected=" + check.isSelected()); if (!check.isSelected()) { GuiDeferredExecutor.instance().execute(() -> { Utils.logToConsole("Checkbox: " + check.getText() + "; setting selected"); if (!check.isSelected()) check.doClick(); }); } } }); }
Example 12
Source File: BiomeExporterDialog.java From amidst with GNU General Public License v3.0 | 5 votes |
private JCheckBox createFullResCheckbox() { JCheckBox newCheckBox = new JCheckBox("Full Resolution"); newCheckBox.addChangeListener(e -> { renderPreview(); }); return newCheckBox; }
Example 13
Source File: NewGameDialog.java From lizzie with GNU General Public License v3.0 | 5 votes |
private void initContentPanel() { GridLayout gridLayout = new GridLayout(5, 2, 4, 4); contentPanel.setLayout(gridLayout); checkBoxPlayerIsBlack = new JCheckBox(resourceBundle.getString("NewGameDialog.PlayBlack"), true); checkBoxPlayerIsBlack.addChangeListener(evt -> togglePlayerIsBlack()); textFieldWhite = new JTextField(); textFieldBlack = new JTextField(); textFieldKomi = new JFormattedTextField(FORMAT_KOMI); textFieldHandicap = new JFormattedTextField(FORMAT_HANDICAP); textFieldHandicap.setEnabled(false); textFieldHandicap.addPropertyChangeListener(evt -> modifyHandicap()); contentPanel.add(checkBoxPlayerIsBlack); chkNewGame = new JCheckBox(resourceBundle.getString("NewGameDialog.NewGame"), false); chkNewGame.addChangeListener(evt -> toggleNewGame()); contentPanel.add(chkNewGame); contentPanel.add(new JLabel(resourceBundle.getString("NewGameDialog.Black"))); contentPanel.add(textFieldBlack); contentPanel.add(new JLabel(resourceBundle.getString("NewGameDialog.White"))); contentPanel.add(textFieldWhite); contentPanel.add(new JLabel(resourceBundle.getString("NewGameDialog.Komi"))); contentPanel.add(textFieldKomi); contentPanel.add(new JLabel(resourceBundle.getString("NewGameDialog.Handicap"))); contentPanel.add(textFieldHandicap); textFieldKomi.setEnabled(true); dialogPane.add(contentPanel, BorderLayout.CENTER); }
Example 14
Source File: BiomeExporterDialog.java From amidst with GNU General Public License v3.0 | 5 votes |
private JCheckBox createFullResCheckbox() { JCheckBox newCheckBox = new JCheckBox("Full Resolution"); newCheckBox.addChangeListener(e -> { renderPreview(); }); return newCheckBox; }
Example 15
Source File: TestbedSidePanel.java From jbox2d with BSD 2-Clause "Simplified" License | 5 votes |
private void addSettings(JPanel argPanel, TestbedSettings argSettings, SettingType argIgnore) { for (TestbedSetting setting : argSettings.getSettings()) { if (setting.settingsType == argIgnore) { continue; } switch (setting.constraintType) { case RANGE: JLabel text = new JLabel(setting.name + ": " + setting.value); JSlider slider = new JSlider(setting.min, setting.max, setting.value); slider.setMaximumSize(new Dimension(200, 20)); slider.addChangeListener(this); slider.setName(setting.name); slider.putClientProperty(SETTING_TAG, setting); slider.putClientProperty(LABEL_TAG, text); argPanel.add(text); argPanel.add(slider); break; case BOOLEAN: JCheckBox checkbox = new JCheckBox(setting.name); checkbox.setSelected(setting.enabled); checkbox.addChangeListener(this); checkbox.putClientProperty(SETTING_TAG, setting); argPanel.add(checkbox); break; } } }
Example 16
Source File: ControlPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 4 votes |
public SnifferControl() { super(); setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0)); _hostIpTextField = new JTextField(17); _hostIpTextField.setText(Resources.getLabel("sniffer.host.tooltip")); final FirstInputListener listener = new FirstInputListener(_hostIpTextField); _hostIpTextField.addMouseListener(listener); _hostIpTextField.addKeyListener(listener); _hostIpTextField.setToolTipText(Resources.getLabel("sniffer.host.tooltip")); add(_hostIpTextField); final JLabel protocolLabel = new JLabel(Resources.getLabel("protocol.label")); protocolLabel.setToolTipText(Resources.getLabel("protocol.desc")); add(protocolLabel); for (final Protocol type : Protocol.values()) { if (type == Protocol.OTHER) { continue; } final JCheckBox check = new JCheckBox(type.name(), type == Protocol.TCP); _packets.put(type, check); add(check); } final JLabel portLabel = new JLabel(Resources.getLabel("port.label")); portLabel.setToolTipText(Resources.getLabel("port.desc")); _allPortCheck = new JCheckBox(Resources.getLabel("all.port.label")); _allPortCheck.setToolTipText(Resources.getLabel("all.port.desc")); _allPortCheck.setSelected(false); add(_allPortCheck); _portTF = new JFormattedTextField(); _portTF.setText("80,443"); _portTF.setColumns(15); // _portTF.setMaximumSize(new Dimension(30, _portTF.getPreferredSize().height)); add(portLabel); add(_portTF); _portTF.setEnabled(true); _allPortCheck.addChangeListener(e -> _portTF.setEnabled(!_allPortCheck.isSelected())); _filterPacketLengthCheck = new JCheckBox(Resources.getLabel("filter.length")); _filterPacketLengthCheck.setToolTipText(Resources.getLabel("filter.length.desc")); _filterPacketLengthCheck.setSelected(false); add(_filterPacketLengthCheck); _filterLengthTF = new JFormattedTextField(new NumberFormatterFactory()); _filterLengthTF.setText("128"); _filterLengthTF.setColumns(5); add(_filterLengthTF); _filterPacketLengthCheck.addChangeListener(e -> _filterLengthTF.setEnabled(_filterPacketLengthCheck.isEnabled() && _filterPacketLengthCheck.isSelected())); _capturePeriod = new JFormattedTextField(new NumberFormatterFactory()); _capturePeriod.setText("0"); _capturePeriod.setColumns(5); add(new JLabel(Resources.getLabel("capture.period"))); add(_capturePeriod); _captureButton = new JButton(GO_IMG); _captureButton.setToolTipText(Resources.getLabel("capture.packet.start")); add(_captureButton); _captureButton.addActionListener(arg0 -> start()); }
Example 17
Source File: ControllerModule.java From DeconvolutionLab2 with GNU General Public License v3.0 | 4 votes |
@Override public JPanel buildExpandedPanel() { chkTime = new JCheckBox(""); chkResidu = new JCheckBox(""); txtResidu = new JTextField("0.01"); txtTime = new JTextField("3600"); txtIterations = new JTextField("Iteration max (mandatory)"); txtIterations.setEditable(false); cmbMonitor = new JComboBox<String>(new String[] {"console table", "console", "table", "no" }); cmbVerbose = new JComboBox<String>(new String[] {"log", "quiet", "mute", "prolix" }); cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray()); cmbStats = new JComboBox<String>(new String[] {"no", "show", "show + save", "save"}); GridPanel pn = new GridPanel(true, 2); pn.place(0, 0, "monitor"); pn.place(0, 2, cmbMonitor); pn.place(0, 3, "Monitoring message"); pn.place(1, 0, "verbose"); pn.place(1, 2, cmbVerbose); pn.place(1, 3, ""); pn.place(3, 0, "stats"); pn.place(3, 2, cmbStats); pn.place(3, 3, "Signal's statistics"); pn.place(4, 0, "constraint"); pn.place(4, 2, cmbConstraint); pn.place(4, 3, "Additional constraint"); pn.place(5, 0, "residu"); pn.place(5, 1, chkResidu); pn.place(5, 2, txtResidu); pn.place(5, 3, "Additional stopping criteria"); pn.place(6, 0, "time"); pn.place(6, 1, chkTime); pn.place(6, 2, txtTime); pn.place(6, 3, "Additional stopping criteria"); JScrollPane scroll = new JScrollPane(pn); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); JPanel panel = new JPanel(new BorderLayout()); panel.add(scroll, BorderLayout.CENTER); Config.register(getName(), "residu.enable", chkResidu, false); Config.register(getName(), "time.enable", chkTime, false); Config.register(getName(), "residu.value", txtResidu, "0.01"); Config.register(getName(), "time.value", txtTime, "3600"); Config.register(getName(), "constraint", cmbConstraint, cmbConstraint.getItemAt(0)); Config.register(getName(), "stats", cmbStats, cmbStats.getItemAt(0)); Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0)); Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0)); chkResidu.addChangeListener(this); chkTime.addChangeListener(this); txtResidu.addKeyListener(this); txtTime.addKeyListener(this); cmbConstraint.addActionListener(this); cmbMonitor.addActionListener(this); cmbVerbose.addActionListener(this); getActionButton().addActionListener(this); return panel; }
Example 18
Source File: TableDemo.java From littleluck with Apache License 2.0 | 4 votes |
protected JPanel createControlPanel() { JPanel controlPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); controlPanel.setLayout(gridbag); c.gridx = 0; c.gridy = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 0, 10); c.anchor = GridBagConstraints.SOUTHWEST; JLabel searchLabel = new JLabel(getString("TableDemo.searchLabel", "Search Titles and Recipients")); controlPanel.add(searchLabel, c); c.gridx = 0; c.gridy = 2; c.weightx = 1.0; c.insets.top = 0; c.insets.bottom = 12; c.anchor = GridBagConstraints.SOUTHWEST; //c.fill = GridBagConstraints.HORIZONTAL; filterField = new JTextField(24); filterField.getDocument().addDocumentListener(new SearchFilterListener()); controlPanel.add(filterField, c); c.gridx = 1; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; //c.insets.right = 24; //c.insets.left = 12; c.weightx = 0.0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; winnersCheckbox = new JCheckBox(getString("TableDemo.winnersLabel", "Show Only Winners")); winnersCheckbox.addChangeListener(new ShowWinnersListener()); controlPanel.add(winnersCheckbox, c); return controlPanel; }
Example 19
Source File: TableDemo.java From beautyeye with Apache License 2.0 | 4 votes |
protected JPanel createControlPanel() { JPanel controlPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); controlPanel.setLayout(gridbag); c.gridx = 0; c.gridy = 1; c.gridheight = 1; c.insets = new Insets(20, 10, 0, 10); c.anchor = GridBagConstraints.SOUTHWEST; JLabel searchLabel = new JLabel(getString("TableDemo.searchLabel", "Search Titles and Recipients")); controlPanel.add(searchLabel, c); c.gridx = 0; c.gridy = 2; c.weightx = 1.0; c.insets.top = 0; c.insets.bottom = 12; c.anchor = GridBagConstraints.SOUTHWEST; // c.fill = GridBagConstraints.HORIZONTAL; filterField = new JTextField(24); filterField.getDocument().addDocumentListener( new SearchFilterListener()); controlPanel.add(filterField, c); c.gridx = 1; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; // c.insets.right = 24; // c.insets.left = 12; c.weightx = 0.0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; winnersCheckbox = new JCheckBox(getString("TableDemo.winnersLabel", "Show Only Winners")); winnersCheckbox.addChangeListener(new ShowWinnersListener()); controlPanel.add(winnersCheckbox, c); return controlPanel; }
Example 20
Source File: CustomizePage.java From arcusplatform with Apache License 2.0 | 4 votes |
private Component createFavoritePanel(PairingCustomizationStep step) { JCheckBox box = new JCheckBox("Favorite"); box.addChangeListener((e) -> controller().customizeFavorite(input.getPairingDevice(), box.isSelected())); return box; }