java.awt.event.ItemListener Java Examples

The following examples show how to use java.awt.event.ItemListener. 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: StatisticsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JToggleButton newOptionButton(Icon icon, String tooltip, String accessibleName, final String property) {
JToggleButton newButton = new JToggleButton(icon);
newButton.setToolTipText(tooltip);
newButton.getAccessibleContext().setAccessibleName(accessibleName);
boolean isSelected = NbPreferences.forModule(StatisticsPanel.class).getBoolean(property, false);
newButton.setSelected(isSelected);
newButton.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
	boolean selected;
	switch (e.getStateChange()) {
	    case ItemEvent.SELECTED:
		selected = true;
		break;
	    case ItemEvent.DESELECTED:
		selected = false;
		break;
	    default:
		return;
	}
	ResultWindow.getInstance().updateOptionStatus(property, selected);
    }
});
return newButton;
   }
 
Example #2
Source File: AddPayloadDialog.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
protected JComboBox<String> getPayloadUIHandlersComboBox() {
    if (payloadUIHandlersComboBox == null) {
        payloadUIHandlersComboBox = new JComboBox<>(new SortedComboBoxModel<String>());
        for (String name : payloadGeneratorsUIHandlers.getPayloadUIHandlersNames()) {
            payloadUIHandlersComboBox.addItem(name);
        }

        payloadUIHandlersComboBox.addItemListener(
                new ItemListener() {

                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        if (ItemEvent.SELECTED == e.getStateChange()) {
                            String panelName = (String) e.getItem();

                            currentPanel = payloadGeneratorsUIHandlers.getPanel(panelName);
                            contentsPanelCardLayout.show(contentsPanel, panelName);

                            setHelpTarget(currentPanel.getHelpTarget());
                        }
                    }
                });
    }
    return payloadUIHandlersComboBox;
}
 
Example #3
Source File: ConfigureLogcatFormatDialog.java    From logviewer with Apache License 2.0 6 votes vote down vote up
public ConfigureLogcatFormatDialog(Project project) {
    super(project, false, IdeModalityType.PROJECT);
    init();
    setTitle(AndroidBundle.message("android.configure.logcat.header.title"));
    myPreferences = AndroidLogcatPreferences.getInstance(project);

    myFormatString = myPreferences.LOGCAT_FORMAT_STRING;
    myShowTimeCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%1$s"));
    myShowPidTidCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%2$s"));
    myShowPackageNameCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%3$s"));
    myShowTag.setSelected(myFormatString.isEmpty() || myFormatString.contains("%5$s"));

    ItemListener checkboxListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            rebuildFormatString();
        }
    };
    myShowTimeCheckBox.addItemListener(checkboxListener);
    myShowPidTidCheckBox.addItemListener(checkboxListener);
    myShowPackageNameCheckBox.addItemListener(checkboxListener);
    myShowTag.addItemListener(checkboxListener);

    updateDemoLabel();
}
 
Example #4
Source File: ImportExportPlugIn.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
private ItemListener createItemListener(final JTextField filePathTextField, final JComboBox<String> fileFormatCBox) {
    return new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            final String fp = filePathTextField.getText();
            if(!fp.isEmpty()) {
                if(fp.endsWith("\\") || fp.endsWith("/")) {
                    filePathTextField.setText(fp + "results." + moduleExtensions[fileFormatCBox.getSelectedIndex()]);
                } else {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            int dotpos = fp.lastIndexOf('.');
                            if(dotpos > 0) {
                                filePathTextField.setText(fp.substring(0, dotpos + 1) + moduleExtensions[fileFormatCBox.getSelectedIndex()]);
                            }
                        }
                    });
                }
            }
        }
    };
}
 
Example #5
Source File: GUIOptionListenPortDialog.java    From PacketProxy with Apache License 2.0 6 votes vote down vote up
private JComponent createTypeSetting() {
	type_combo.addItem("HTTP_PROXY");
	type_combo.addItem("FORWARDER");
	type_combo.addItem("SSL_FORWARDER");
	type_combo.addItem("SSL_TRANSPARENT_PROXY");
	type_combo.addItem("HTTP_TRANSPARENT_PROXY");
	type_combo.addItem("UDP_FORWARDER");
	type_combo.setEnabled(true);
	type_combo.setMaximumRowCount(6);
	type_combo.addItemListener(new ItemListener(){
		@Override
		public void itemStateChanged(ItemEvent event) {
			try {
				if (event.getStateChange() != ItemEvent.SELECTED)
					return;
				updateNextHopList((String)event.getItem());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
	return label_and_object("Type:", type_combo);
}
 
Example #6
Source File: CustomerForm.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 6 votes vote down vote up
private ItemListener changeTitleListener() {
	final ItemListener listener = new ItemListener() {
		
		@Override
		public void itemStateChanged(ItemEvent e) {
			final String title = titleComboBox.getSelectedItem().toString();
			
			if(title.equalsIgnoreCase("Mr")) {
				genderComboBox.setSelectedIndex(0);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
			
			else {
				genderComboBox.setSelectedIndex(1);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
		}
	};
	return listener;
}
 
Example #7
Source File: RefreshServiceDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private RefreshServiceDialog(boolean downloadWsdl, String implClass, String url) {
    this.downloadWsdl=downloadWsdl;
    this.implClass = implClass;
    this.url=url;
    initComponents();
    // display the delete_wsdl checkbox only if wsdl exists
    if (!downloadWsdl) {
        downloadWsdlCheckBox.setVisible(false);
        jLabel1.setVisible(false);
        jTextField1.setVisible(false);
    } else {
        jTextField1.setText(url);
        downloadWsdlCheckBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (((javax.swing.JCheckBox)e.getSource()).isSelected())
                    jTextField1.setEditable(true);
                else 
                    jTextField1.setEditable(false);
            }

        });            
    }
}
 
Example #8
Source File: MemSearchDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Container buildCodeUnitTypesPanel() {
	final JCheckBox instructionsCheckBox = new GCheckBox("Instructions", true);
	final JCheckBox definedCheckBox = new GCheckBox("Defined Data", true);
	final JCheckBox undefinedCheckBox = new GCheckBox("Undefined Data", true);

	ItemListener stateListener = e -> validate();

	codeUnitTypesList = new ArrayList<>();
	codeUnitTypesList.add(instructionsCheckBox);
	codeUnitTypesList.add(definedCheckBox);
	codeUnitTypesList.add(undefinedCheckBox);

	instructionsCheckBox.addItemListener(stateListener);
	definedCheckBox.addItemListener(stateListener);
	undefinedCheckBox.addItemListener(stateListener);

	JPanel codeUnitTypePanel = new JPanel();
	codeUnitTypePanel.setLayout(new BoxLayout(codeUnitTypePanel, BoxLayout.Y_AXIS));
	codeUnitTypePanel.add(instructionsCheckBox);
	codeUnitTypePanel.add(definedCheckBox);
	codeUnitTypePanel.add(undefinedCheckBox);
	codeUnitTypePanel.setBorder(BorderFactory.createTitledBorder(CODE_UNIT_SCOPE_NAME));

	return codeUnitTypePanel;
}
 
Example #9
Source File: NbEditorKit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
    
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(
        NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
        toolbarVisible);
    
    item.addItemListener( new ItemListener() {
        public @Override void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    
    return item;
}
 
Example #10
Source File: CodeSnifferOptionsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "CodeSnifferOptionsPanel.hint=Full path of Code Sniffer script (typically {0} or {1}).",
})
private void initCodeSniffer(DocumentListener defaultDocumentListener) {
    codeSnifferHintLabel.setText(Bundle.CodeSnifferOptionsPanel_hint(CodeSniffer.NAME, CodeSniffer.LONG_NAME));
    codeSnifferStandardComboBox.setModel(codeSnifferStandardsModel);

    // listeners
    codeSnifferTextField.getDocument().addDocumentListener(defaultDocumentListener);
    codeSnifferTextField.getDocument().addDocumentListener(new CodeSnifferPathDocumentListener());
    final ItemListener defaultItemListener = new DefaultItemListener();
    codeSnifferStandardsModel.fetchStandards(codeSnifferStandardComboBox, new Runnable() {
        @Override
        public void run() {
            // #232279
            codeSnifferStandardComboBox.addItemListener(defaultItemListener);
        }
    });
}
 
Example #11
Source File: ConnectionPanel.java    From Ardulink-2 with Apache License 2.0 6 votes vote down vote up
private JComboBox createURICombo() {
	JComboBox uris = new JComboBox();
	uris.setRenderer(new DefaultListCellRenderer() {

		private static final long serialVersionUID = 2756587449741341859L;

		@Override
		public Component getListCellRendererComponent(JList list,
				Object value, int index, boolean isSelected,
				boolean cellHasFocus) {
			return value == null ? null : super.getListCellRendererComponent(list,
					extractNameFromURI(URIs.newURI((String) value)), index,
					isSelected, cellHasFocus);
		}
	});
	uris.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent event) {
			if (event.getStateChange() == SELECTED) {
				replaceSubpanel();
			}
		}
	});
	return uris;
}
 
Example #12
Source File: SymbolTypeFilter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected void createCheckBoxInfos() {
	ItemListener listener = new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			fireStatusChanged(getFilterStatus());
		}
	};

	SourceType[] values = SourceType.values();
	for (SourceType type : values) {
		GCheckBox checkBox = new GCheckBox(type.getDisplayString(), true);
		checkBox.addItemListener(listener);
		CheckBoxInfo<VTMatch> info = new SymbolTypeCheckBoxInfo(checkBox, type);
		checkBoxInfos.add(info);
	}

	GCheckBox nullSymbolCheckbox = new GCheckBox("<No Symbol>", true);
	nullSymbolCheckbox.addItemListener(listener);
	checkBoxInfos.add(new NullSymbolCheckBoxInfo(nullSymbolCheckbox));
}
 
Example #13
Source File: ComboBoxBuilder.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
public JComboBox<T> create() {
   JComboBox<T> combo = new JComboBox<T>(model);
   combo.setEditable(editable);
   if(listRenderer != null) {
      combo.setRenderer(listRenderer);
   }
   if(editable && editor != null) {
      combo.setEditor(editor);
   }
   if(listeners != null) {
      final List<Listener<? super T>> l = ImmutableList.copyOf(listeners);
      combo.addItemListener(new ItemListener() {

         @Override
         public void itemStateChanged(ItemEvent e) {
            if(e.getStateChange() == ItemEvent.SELECTED) {
               for(Listener<? super T> listener: l) {
                  listener.onEvent((T) e.getItem());
               }
            }
         }
      });
   }
   return combo;
}
 
Example #14
Source File: RefreshWsDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private RefreshWsDialog(boolean downloadWsdl, String implClass, String url) {
    this.downloadWsdl=downloadWsdl;
    this.implClass = implClass;
    this.url=url;
    initComponents();
    // display the delete_wsdl checkbox only if wsdl exists
    if (!downloadWsdl) {
        downloadWsdlCheckBox.setVisible(false);
        jLabel1.setVisible(false);
        jTextField1.setVisible(false);
    } else {
        jTextField1.setText(url);
        downloadWsdlCheckBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (((javax.swing.JCheckBox)e.getSource()).isSelected())
                    jTextField1.setEditable(true);
                else 
                    jTextField1.setEditable(false);
            }

        });            
    }
}
 
Example #15
Source File: CheckboxMenuItem.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException
{
  s.defaultReadObject();

  Object keyOrNull;
  while(null != (keyOrNull = s.readObject())) {
    String key = ((String)keyOrNull).intern();

    if (itemListenerK == key)
      addItemListener((ItemListener)(s.readObject()));

    else // skip value for unrecognized key
      s.readObject();
  }
}
 
Example #16
Source File: FlutterLogFilterPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) {
  this.onFilterListener = onFilterListener;
  final ItemListener listener = e -> doFilter();
  matchCaseCheckBox.addItemListener(listener);
  regexCheckBox.addItemListener(listener);
  final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values())
    .collect(Collectors.toList());
  logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels));
  logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE);
  logLevelComboBox.addActionListener(event -> doFilter());
  logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list,
                                         FlutterLog.Level value,
                                         int index,
                                         boolean selected,
                                         boolean hasFocus) {
      // When NONE is selected, show an empty string in the combo selector.
      final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString();
      append(label);
    }
  });
}
 
Example #17
Source File: ItemEventTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void testItemListener() {
    list.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent ie) {
            actualSelectionOrder.append(ie.getItem());
        }
    });
    performTest();
}
 
Example #18
Source File: DefaultSuiteProjectDeletePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void attachListeners() {
    this.deleteModulesCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if(deleteModulesCheckBox.isSelected() && hasSourcesToDelete) {
                deleteSourcesCheckBox.setEnabled(true);
            }
            else {
                deleteSourcesCheckBox.setEnabled(false);
            }
        }

    });
}
 
Example #19
Source File: PayloadPreviewPanel.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private static JPanel createSplitPanel(
        JPanel leftPanel,
        JPanel rightPanel,
        final SyncScrollBarsAdjustmentListener syncScrollPanes) {
    JPanel panel = new JPanel();

    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateGaps(true);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
    splitPane.setDividerLocation(0.5D);
    splitPane.setResizeWeight(0.5D);

    JCheckBox syncScrollBarsCheckbox = new JCheckBox(LOCK_SCROLL_BARS_BUTTON_LABEL);
    syncScrollBarsCheckbox.setSelected(true);
    syncScrollBarsCheckbox.addItemListener(
            new ItemListener() {

                @Override
                public void itemStateChanged(ItemEvent e) {
                    syncScrollPanes.setSync(e.getStateChange() == ItemEvent.SELECTED);
                }
            });

    layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(splitPane)
                    .addComponent(syncScrollBarsCheckbox));
    layout.setVerticalGroup(
            layout.createSequentialGroup()
                    .addComponent(splitPane)
                    .addComponent(syncScrollBarsCheckbox));

    return panel;
}
 
Example #20
Source File: SmartyCustomizerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
    enabledCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setFieldsEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    setFieldsEnabled(enabledCheckBox.isSelected());
}
 
Example #21
Source File: ArrangementComboBoxUiComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ArrangementComboBoxUiComponent(@Nonnull List<ArrangementSettingsToken> tokens) {
  super(tokens);
  ArrangementSettingsToken[] tokensArray = tokens.toArray(new ArrangementSettingsToken[tokens.size()]);
  Arrays.sort(tokensArray, new Comparator<ArrangementSettingsToken>() {
    @Override
    public int compare(ArrangementSettingsToken t1, ArrangementSettingsToken t2) {
      return t1.getRepresentationValue().compareTo(t2.getRepresentationValue());
    }
  });
  myComboBox = new JComboBox(tokensArray);
  myComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setText(((ArrangementSettingsToken)value).getRepresentationValue());
    }
  });
  myComboBox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        fireStateChanged();
      }
    }
  });
  int minWidth = 0;
  ListCellRenderer renderer = myComboBox.getRenderer();
  JBList dummyList = new JBList();
  for (int i = 0, max = myComboBox.getItemCount(); i < max; i++) {
    Component rendererComponent = renderer.getListCellRendererComponent(dummyList, myComboBox.getItemAt(i), i, false, true);
    minWidth = Math.max(minWidth, rendererComponent.getPreferredSize().width);
  }
  myComboBox.setPreferredSize(new Dimension(minWidth * 5 / 3, myComboBox.getPreferredSize().height));
}
 
Example #22
Source File: EditTeamService.java    From Shuffle-Move with GNU General Public License v3.0 5 votes vote down vote up
private void addActionListeners() {
   MultiListener listener = new MultiListener(this);
   typeChooser.addItemListener(listener);
   textField.getDocument().addDocumentListener(listener);
   levelSpinner.getModel().addChangeListener(listener);
   megaFilter.addItemListener(listener);
   effectFilter.addItemListener(listener);
   survivalMode.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent e) {
         updateTeamPanel();
      }
   });
}
 
Example #23
Source File: CreateTraitDialog.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CreateTraitDialog(final BeautiFrame frame) {
        this.frame = frame;

        nameField = new JTextField("untitled_trait");
        nameField.setColumns(20);

//        nameCombo = new JComboBox(TraitData.Traits.values());
        typeCombo = new JComboBox(TraitData.TraitType.values());

        optionPanel = new OptionsPanel(12, 12);

        ButtonGroup group = new ButtonGroup();
        group.add(createRadio);
        group.add(importRadio);
        ItemListener listener = new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                nameField.setEnabled(createRadio.isSelected());
                typeCombo.setEnabled(createRadio.isSelected());
                exampleButton.setEnabled(importRadio.isSelected());
            }
        };
        createRadio.addItemListener(listener);
        importRadio.addItemListener(listener);

        exampleButton.setEnabled(false);
        exampleButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JScrollPane scrollPane = TextUtil.createHTMLScrollPane(EXAMPLE_FORMAT, new Dimension(400,300));

                JOptionPane.showMessageDialog(frame, scrollPane,
                        "Example of mapping file format",
                        JOptionPane.PLAIN_MESSAGE);
            }
        });
    }
 
Example #24
Source File: MultipleChangeListBrowser.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ChangeListChooser() {
  super(new BorderLayout(4, 2));
  myChooser = new ComboBox();
  //noinspection unchecked
  myChooser.setRenderer(new ColoredListCellRendererWrapper<LocalChangeList>() {
    @Override
    protected void doCustomize(JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        String name = StringUtil.shortenTextWithEllipsis(value.getName().trim(), MAX_LEN, 0);

        append(name, value.isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });

  myChooser.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        final LocalChangeList changeList = (LocalChangeList)myChooser.getSelectedItem();
        setSelectedList(changeList);
        myChooser.setToolTipText(changeList == null ? "" : (changeList.getName()));
      }
    }
  });

  myChooser.setEditable(false);
  add(myChooser, BorderLayout.CENTER);

  JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label"));
  label.setLabelFor(myChooser);
  add(label, BorderLayout.WEST);
}
 
Example #25
Source File: PreferencePanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a {@link JCheckBox} suitable for use within the preference panel.
 *
 * @param title   The title to use.
 * @param tooltip The tooltip to use.
 * @param checked Whether the initial state should be checked.
 * @return The newly created {@link JCheckBox}.
 */
protected JCheckBox createCheckBox(String title, String tooltip, boolean checked) {
    JCheckBox checkbox = new JCheckBox(title, checked);
    checkbox.setOpaque(false);
    checkbox.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    if (this instanceof ItemListener) {
        checkbox.addItemListener((ItemListener) this);
    }
    add(checkbox);
    return checkbox;
}
 
Example #26
Source File: ArrayElementPropertyEditor.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Component buildEditor() {
	// we want to have a panel with our options so that we may group them together
	JPanel panel = new JPanel(new VerticalLayout(3));

	// the namespace checkbox will disable the text field options when it is not used
	groupElementsCheckBox = new GCheckBox(SHOW_MULTI_ELEMENTS_LABEL);
	groupElementsCheckBox.setSelected(true);
	groupElementsCheckBox.setToolTipText(SHOW_MULTI_ELEMENTS_TOOLTIP);

	panel.add(groupElementsCheckBox);

	elementsPerLineField =
		createLocalPrefixTextField(GROUP_SIZE_LABEL, GROUP_SIZE_LABEL_TOOLTIP, panel);
	elementsLabel.setToolTipText(GROUP_SIZE_LABEL_TOOLTIP);

	groupElementsCheckBox.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			boolean enabled = groupElementsCheckBox.isSelected();
			// only enable the text field if we are showing namespaces AND we are 
			// overriding the display value
			elementsPerLineField.setEnabled(enabled);
			elementsLabel.setEnabled(enabled);
			firePropertyChange();
		}
	});
	panel.setBorder(BorderFactory.createCompoundBorder(
		BorderFactory.createEmptyBorder(10, 0, 10, 0), new TitledBorder("Grouping")));

	return panel;
}
 
Example #27
Source File: GuiShowGovernanceAction.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addComboBoxListener(JComboBox<Integer> comboBox, int numberOfOwnedBuildings, JLabel buildingIncome) {
	comboBox.addItemListener(new ItemListener() {
		
		@Override
		public void itemStateChanged(ItemEvent e) {
			buildingIncome.setText(Integer.toString(numberOfOwnedBuildings * (Integer)comboBox.getSelectedItem()));				
		}
	});
	buildingIncome.setText(Integer.toString(numberOfOwnedBuildings * (Integer)comboBox.getSelectedItem()));
}
 
Example #28
Source File: UserPreferences.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public static void track(final JRadioButton button) {
  final Preferences prefs = node().node("Buttons");
  boolean selected = prefs.getBoolean(button.getName() + ".selected", button
      .isSelected());
  ((DefaultButtonModel) button.getModel()).getGroup().setSelected(
      button.getModel(), selected);// .setSelected(selected);
  button.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      prefs.putBoolean(button.getName() + ".selected", button.isSelected());
    }
  });
}
 
Example #29
Source File: Tools.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
    ItemListener defaultItemListener = new DefaultItemListener();
    packageJsonCheckBox.addItemListener(defaultItemListener);
    bowerJsonCheckBox.addItemListener(defaultItemListener);
    gruntfileCheckBox.addItemListener(defaultItemListener);
    gulpfileCheckBox.addItemListener(defaultItemListener);
}
 
Example #30
Source File: AgeCalculator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
FieldGroup(ItemListener listener, String checkboxText, int fieldType) {
    iCheckbox = new JCheckBox(checkboxText, true);
    iCheckbox.addItemListener(listener);
    iResult = new JTextField();
    iResult.setEditable(false);
    iFieldType = fieldType;
}