Java Code Examples for javax.swing.JCheckBox#addFocusListener()
The following examples show how to use
javax.swing.JCheckBox#addFocusListener() .
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: ViewElementBoolean.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
public ViewElementBoolean(RobotOverlord ro,BooleanEntity e) { super(ro); this.e=e; e.addObserver(this); field = new JCheckBox(); field.setSelected(e.get()); field.addItemListener(this); field.setBorder(new EmptyBorder(0,0,0,0)); field.addFocusListener(this); JLabel label=new JLabel(e.getName(),SwingConstants.LEFT); label.setLabelFor(field); panel.setLayout(new BorderLayout()); panel.add(label,BorderLayout.LINE_START); panel.add(field,BorderLayout.LINE_END); }
Example 2
Source File: ListDemo.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Adds the prefix. * * @param prefix the prefix * @param selected the selected */ public void addPrefix(String prefix, boolean selected) { if(prefixAction == null) { prefixAction = new UpdatePrefixListAction(listModel); } final JCheckBox cb = (JCheckBox) prefixList.add(new JCheckBox(prefix)); cb.setOpaque(false);//* add by jb2011 checkboxes.addElement(cb); cb.setSelected(selected); cb.addActionListener(prefixAction); if(selected) { listModel.addPrefix(prefix); } cb.addFocusListener(listFocusListener); }
Example 3
Source File: ListDemo.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Adds the suffix. * * @param suffix the suffix * @param selected the selected */ public void addSuffix(String suffix, boolean selected) { if(suffixAction == null) { suffixAction = new UpdateSuffixListAction(listModel); } final JCheckBox cb = (JCheckBox) suffixList.add(new JCheckBox(suffix)); cb.setOpaque(false);//* add by jb2011 checkboxes.addElement(cb); cb.setSelected(selected); cb.addActionListener(suffixAction); if(selected) { listModel.addSuffix(suffix); } cb.addFocusListener(listFocusListener); }
Example 4
Source File: MultipleSelectionInputComponent.java From chipster with MIT License | 5 votes |
protected MultipleSelectionInputComponent(EnumParameter param, ParameterPanel parameterPanel) { super(parameterPanel); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.param = param; // Generate a list of checkboxes representing available choices boolean selected; for (Object choice : param.getOptions()) { SelectionOption option = (SelectionOption) choice; // Select default values selected = false; if (param.getSelectedOptions().contains(option)) { selected = true; } // Create the component JCheckBox checkbox = new JCheckBox(option.toString(), selected); checkbox.setName(option.getValue()); checkbox.addActionListener(this); checkbox.addFocusListener(this); // Add checkbox to lists checkboxes.add(checkbox); this.add(checkbox); } this.getComponent(0); }
Example 5
Source File: SlowPanel.java From VanetSim with GNU General Public License v3.0 | 4 votes |
/** * Constructor, creating GUI items. */ public SlowPanel(){ setLayout(new GridBagLayout()); // global layout settings GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.gridwidth = 2; c.gridwidth = 1; c.insets = new Insets(5,5,5,5); c.gridx = 0; timeToPseudonymChangeLabel_ = new JLabel(Messages.getString("SlowPanel.timeToPseudonymChange")); //$NON-NLS-1$ ++c.gridy; add(timeToPseudonymChangeLabel_,c); timeToPseudonymChange_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); timeToPseudonymChange_.setValue(3000); timeToPseudonymChange_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; timeToPseudonymChange_.addFocusListener(this); add(timeToPseudonymChange_,c); c.gridx = 0; slowSpeedLimitLabel_ = new JLabel(Messages.getString("SlowPanel.speedLimit")); //$NON-NLS-1$ ++c.gridy; add(slowSpeedLimitLabel_,c); slowSpeedLimit_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); slowSpeedLimit_.setValue(30); slowSpeedLimit_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; slowSpeedLimit_.addFocusListener(this); add(slowSpeedLimit_,c); c.gridx = 0; enableSlowLabel_ = new JLabel(Messages.getString("SlowPanel.enable")); //$NON-NLS-1$ ++c.gridy; add(enableSlowLabel_,c); enableSlow_ = new JCheckBox(); enableSlow_.setSelected(false); enableSlow_.setActionCommand("enableSlow"); //$NON-NLS-1$ c.gridx = 1; enableSlow_.addFocusListener(this); add(enableSlow_,c); enableSlow_.addActionListener(this); //to consume the rest of the space c.weighty = 1.0; ++c.gridy; JPanel space = new JPanel(); space.setOpaque(false); add(space, c); }
Example 6
Source File: SilentPeriodPanel.java From VanetSim with GNU General Public License v3.0 | 4 votes |
/** * Constructor, creating GUI items. */ public SilentPeriodPanel(){ setLayout(new GridBagLayout()); // global layout settings GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.gridwidth = 2; c.gridwidth = 1; c.insets = new Insets(5,5,5,5); c.gridx = 0; silentPeriodDurationLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.duration")); //$NON-NLS-1$ ++c.gridy; add(silentPeriodDurationLabel_,c); silentPeriodDuration_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); silentPeriodDuration_.setValue(3000); silentPeriodDuration_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; silentPeriodDuration_.addFocusListener(this); add(silentPeriodDuration_,c); c.gridx = 0; silentPeriodFrequencyLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.frequency")); //$NON-NLS-1$ ++c.gridy; add(silentPeriodFrequencyLabel_,c); silentPeriodFrequency_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); silentPeriodFrequency_.setValue(10000); silentPeriodFrequency_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; silentPeriodFrequency_.addFocusListener(this); add(silentPeriodFrequency_,c); c.gridx = 0; enableSilentPeriodsLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.enable")); //$NON-NLS-1$ ++c.gridy; add(enableSilentPeriodsLabel_,c); enableSilentPeriods_ = new JCheckBox(); enableSilentPeriods_.setSelected(false); enableSilentPeriods_.setActionCommand("enableSilentPeriods"); //$NON-NLS-1$ c.gridx = 1; enableSilentPeriods_.addFocusListener(this); add(enableSilentPeriods_,c); enableSilentPeriods_.addActionListener(this); //to consume the rest of the space c.weighty = 1.0; ++c.gridy; JPanel space = new JPanel(); space.setOpaque(false); add(space, c); }