List of usage examples for java.awt.event ItemEvent getStateChange
public int getStateChange()
From source file:Main.java
public void itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox) ie.getItem(); int state = ie.getStateChange(); if (state == ItemEvent.DESELECTED) { System.out.println(cb.getText() + " DESELECTED"); }/*from w ww .j a v a2 s. c o m*/ }
From source file:Main.java
public void itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox) ie.getItem(); int state = ie.getStateChange(); if (state == ItemEvent.SELECTED) { System.out.println(cb.getText() + " selected"); } else {/*w w w. j a v a2 s . c o m*/ System.out.println(cb.getText() + " cleared"); } }
From source file:Main.java
public Main() { this.setDefaultCloseOperation(EXIT_ON_CLOSE); String[] sList = new String[] { "Spring", "Summer", "Fall", "Winter" }; JComboBox<String> seasons = new JComboBox<>(sList); seasons.addItemListener((ItemEvent e) -> { Object item = e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { // Item has been selected System.out.println(item + " has been selected"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { // Item has been deselected System.out.println(item + " has been deselected"); }//from w ww. j ava2 s . c om }); Container contentPane = this.getContentPane(); contentPane.add(seasons, BorderLayout.CENTER); }
From source file:SystemColorChooserPanel.java
public void itemStateChanged(ItemEvent itemEvent) { int state = itemEvent.getStateChange(); if (state == ItemEvent.SELECTED) { int position = findColorLabel(itemEvent.getItem()); if ((position != NOT_FOUND) && (position != labels.length - 1)) { ColorSelectionModel selectionModel = getColorSelectionModel(); selectionModel.setSelectedColor(colors[position]); }/*w w w . jav a2s . c om*/ } }
From source file:Main.java
public void itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox) ie.getItem(); int state = ie.getStateChange(); if (state == ItemEvent.SELECTED) System.out.println(cb.getText() + " selected"); else/*from w w w . j a v a 2 s . co m*/ System.out.println(cb.getText() + " cleared"); }
From source file:Main.java
public void itemStateChanged(ItemEvent evt) { JComboBox cb = (JComboBox) evt.getSource(); Object item = evt.getItem();//from w w w. j a v a 2s . c o m if (evt.getStateChange() == ItemEvent.SELECTED) { // Item was just selected } else if (evt.getStateChange() == ItemEvent.DESELECTED) { // Item is no longer selected } }
From source file:layout.BoxLayoutDemo2.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { restrictSize = true;// w ww. j a v a 2 s.c o m } else { restrictSize = false; } notifyBLDComponents(); }
From source file:Main.java
public void itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox) ie.getItem(); if (ie.getStateChange() == ItemEvent.SELECTED) System.out.println(cb.getText() + " selected."); else/*from w w w. j a v a 2 s.c om*/ System.out.println(cb.getText() + " cleared."); if (jcbOption1.isSelected()) System.out.println("1"); else if (jcbOption2.isSelected()) System.out.println("2"); else if (jcbOption3.isSelected()) System.out.println("3"); else System.out.println("None"); }
From source file:MainClass.java
public void itemStateChanged(ItemEvent itemEvent) { int state = itemEvent.getStateChange(); if (state == ItemEvent.SELECTED) { int position = findColorLabel(itemEvent.getItem()); if ((position != -1) && (position != labels.length - 1)) { ColorSelectionModel selectionModel = getColorSelectionModel(); selectionModel.setSelectedColor(colors[position]); }/* ww w . j a v a 2 s. com*/ } }
From source file:components.ScrollDemo.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { //Turn it to metric. rowView.setIsMetric(true);//from www. j ava 2 s. c o m columnView.setIsMetric(true); } else { //Turn it to inches. rowView.setIsMetric(false); columnView.setIsMetric(false); } picture.setMaxUnitIncrement(rowView.getIncrement()); }