List of usage examples for java.awt.event ItemEvent DESELECTED
int DESELECTED
To view the source code for java.awt.event ItemEvent DESELECTED.
Click Source Link
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 ww w . j a va2 s . co m }
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"); }//w ww . j a va 2s. c o m }); Container contentPane = this.getContentPane(); contentPane.add(seasons, BorderLayout.CENTER); }
From source file:Main.java
public void itemStateChanged(ItemEvent evt) { JComboBox cb = (JComboBox) evt.getSource(); Object item = evt.getItem();//from w w w. j av a 2 s. co m if (evt.getStateChange() == ItemEvent.SELECTED) { // Item was just selected } else if (evt.getStateChange() == ItemEvent.DESELECTED) { // Item is no longer selected } }
From source file:Main.java
void fireItemEvent(Object item, boolean sel) { ItemEvent evt = new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, item, sel ? ItemEvent.SELECTED : ItemEvent.DESELECTED); Object[] listeners = listenerList.getListenerList(); for (int i = 0; i < listeners.length - 2; i += 2) { if (listeners[i] == ItemListener.class) { ((ItemListener) listeners[i + 1]).itemStateChanged(evt); }//from w w w .j a va2s. co m } }
From source file:ItemEventComponent.java
public void processEvent(AWTEvent e) { if (e.getID() == MouseEvent.MOUSE_PRESSED) { if (itemListener != null) { selected = !selected;/*w ww. j a v a 2s . c o m*/ i++; itemListener.itemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, getSelectedObjects(), (selected ? ItemEvent.SELECTED : ItemEvent.DESELECTED))); } } }
From source file:mulavito.gui.control.CountingPickedState.java
@Override public boolean pick(T v, boolean b) { boolean prior_state = picked.contains(v); if (b) {/*from w w w.j a va2 s . c o m*/ if (prior_state == false) fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, v, ItemEvent.SELECTED)); picked.add(v); } else { if (prior_state == true) { picked.remove(v, 1); if (!picked.contains(v)) fireItemStateChanged( new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, v, ItemEvent.DESELECTED)); } } return prior_state; }
From source file:com.ibm.bluej.commonutil.visualization.PrintableVisualizationViewer.java
protected void setStandardOptions() { PluggableRenderer r = (PluggableRenderer) this.getRenderer(); r.setVertexStringer(new StringVertexStringer()); r.setEdgeStringer(new StringEdgeStringer()); r.setEdgeShapeFunction(new SpacedCurve()); r.setVertexPaintFunction(new SmartVertexPaintFunction(r, callbacks)); r.setEdgeLabelClosenessFunction(new ConstantEdgeValue(.5)); r.setEdgePaintFunction(new SmartEdgePaintFunction(r, callbacks)); r.setEdgeFontFunction(new FontHandler()); this.setDoubleBuffered(true); DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); this.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); this.getPickedState().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getItem() instanceof LabeledDirectedSparseVertex) { LabeledDirectedSparseVertex v = (LabeledDirectedSparseVertex) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) v.marked); return; }/*from w w w . j ava2 s. co m*/ if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) v.marked); return; } System.err.println(e.toString()); System.err.println(e.getItem().toString()); } else { LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { callbacks.picked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } if (e.getStateChange() == ItemEvent.DESELECTED) { callbacks.unpicked((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); return; } System.out.println("Edge pick"); System.out.println(e.getItem().getClass().getName()); System.out.println(e.getStateChange()); } } }); setToolTipFunction(new DefaultToolTipFunction() { public String getToolTipText(Vertex v) { return callbacks.getToolTip((T) ((LabeledDirectedSparseVertex) v).marked); } /* public String getToolTipText(Edge edge) { edu.uci.ics.jung.utils.Pair accts = edge.getEndpoints(); Vertex v1 = (Vertex) accts.getFirst(); Vertex v2 = (Vertex) accts.getSecond(); return v1 + " -- " + v2; } */ }); Predicate p = new Predicate() { public boolean evaluate(Object arg0) { if (!(arg0 instanceof LabeledDirectedSparseEdge)) { System.err.println("Unexpected: " + arg0); return false; } LabeledDirectedSparseEdge edge = (LabeledDirectedSparseEdge) arg0; return callbacks.shouldShowEdge((T) edge.getFrom(), edge.getLabel(), (T) edge.getTo()); } }; r.setEdgeIncludePredicate(p); this.setPickSupport(new ShapePickSupport(4)); //System.out.println(getPickSupport().getClass().getName()); }
From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java
public ConsolePanel(PluginDelegate service) { super(service); setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]")); JComboBox comboBox = new JComboBox(); comboBox.setToolTipText("Log Level"); comboBox.setMaximumRowCount(6);/* w w w.j av a 2s .c o m*/ comboBox.setModel( new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" })); comboBox.setSelectedIndex(5); add(comboBox, "cell 1 0,growx"); JButton btnC = new JButton(""); btnC.setToolTipText("Clear Buffer"); btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png"))); btnC.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { logPangrams(); } }); add(btnC, "cell 2 0,wmax 24,hmax 26"); tglbtnV = new JToggleButton(""); tglbtnV.setToolTipText("Auto Scroll"); tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png"))); tglbtnV.setSelected(true); tglbtnV.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { _table.setAutoScroll(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { _table.setAutoScroll(false); } } }); add(tglbtnV, "cell 3 0,wmax 24,hmax 26"); scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { // TODO figure out what to do with this event? } }); add(scrollPane, "cell 0 1 4 1,grow"); _table = new JLogTable("Time", "Source", "Message"); _table.getColumnModel().getColumn(0).setMinWidth(50); _table.getColumnModel().getColumn(0).setPreferredWidth(50); _table.getColumnModel().getColumn(0).setMaxWidth(100); _table.getColumnModel().getColumn(1).setMinWidth(50); _table.getColumnModel().getColumn(1).setPreferredWidth(50); _table.getColumnModel().getColumn(1).setMaxWidth(100); _table.getColumnModel().getColumn(2).setMinWidth(50); _table.getColumnModel().getColumn(2).setWidth(255); _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollPane.setViewportView(_table); _appender = new JLogTableAppender(); _appender.setThreshold(Level.ALL); Logger.getRootLogger().addAppender(_appender); }
From source file:CheckBoxDemo.java
/** Listens to the check boxes. */ public void itemStateChanged(ItemEvent e) { int index = 0; char c = '-'; Object source = e.getItemSelectable(); if (source == chinButton) { index = 0;//from w w w . j a v a2s. c o m c = 'c'; } else if (source == glassesButton) { index = 1; c = 'g'; } else if (source == hairButton) { index = 2; c = 'h'; } else if (source == teethButton) { index = 3; c = 't'; } // Now that we know which button was pushed, find out // whether it was selected or deselected. if (e.getStateChange() == ItemEvent.DESELECTED) { c = '-'; } // Apply the change to the string. choices.setCharAt(index, c); updatePicture(); }
From source file:com.tiempometa.muestradatos.JProgramTags.java
private void checkBox2ItemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { accessPasswordTextField.setEnabled(true); killPasswordTextField.setEnabled(true); } else if (e.getStateChange() == ItemEvent.DESELECTED) { accessPasswordTextField.setEnabled(false); killPasswordTextField.setEnabled(false); }/*from w ww .j a v a 2s. c o m*/ }