List of usage examples for java.awt.event ItemEvent getItem
public Object getItem()
From source file:Main.java
public void itemStateChanged(ItemEvent e) { String size = (String) e.getItem(); if (size.equals("small")) { component.setSize(75, 20);/*from w w w . ja va2 s . c om*/ } else if (size.equals("medium")) { component.setSize(100, 50); } else if (size.equals("large")) { component.setSize(150, 75); } }
From source file:Main.java
public void itemStateChanged(ItemEvent evt) { JComboBox cb = (JComboBox) evt.getSource(); Object item = evt.getItem(); if (evt.getStateChange() == ItemEvent.SELECTED) { // Item was just selected } else if (evt.getStateChange() == ItemEvent.DESELECTED) { // Item is no longer selected }//from w w w. j a v a2 s . c om }
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 www.ja v a 2s . com*/ 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:layout.CardLayoutDemo.java
public void itemStateChanged(ItemEvent evt) { CardLayout cl = (CardLayout) (cards.getLayout()); cl.show(cards, (String) evt.getItem()); }
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]); }/*from w w w . j a v a2 s . c o m*/ } }
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]); }/*w w w . j a v a2 s. c o m*/ } }
From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.support.FileSelectionComponent.java
private void createComponent(Predicate projectFilter) { projectsCombobox = new JComboBox(projectList(projectFilter)); new ComboBoxAutoCompletion(projectsCombobox); model = new DefaultListModel(); list = new JList(model); list.setPreferredSize(new Dimension(150, 150)); projectsCombobox.addItemListener(new ItemListener() { @Override// w ww. j a v a2 s .c o m public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateList(e.getItem()); } } }); setLayout(new BorderLayout()); add(projectsCombobox, BorderLayout.NORTH); add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:com.eviware.soapui.impl.rest.panels.mock.RestMockResponseDesktopPanel.java
private JComponent createMediaTypeCombo() { MediaTypeComboBox mediaTypeComboBox = new MediaTypeComboBox(this.getModelItem()); mediaTypeComboBox.addItemListener(new ItemListener() { @Override// www .ja v a 2 s . co m public void itemStateChanged(ItemEvent e) { setMediaType(getResponseEditor().getInputArea(), e.getItem().toString()); } }); JComponent innerPanel = createPanelWithLabel("Content | Media type: ", mediaTypeComboBox); JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(innerPanel); outerPanel.add(Box.createHorizontalGlue()); outerPanel .add(UISupport.createFormButton(new ShowOnlineHelpAction(HelpUrls.REST_MOCK_RESPONSE_EDITOR_BODY))); return outerPanel; }
From source file:iqq.app.ui.module.UILoginModule.java
/** * ??/* w w w .jav a2s.c o m*/ */ private void initAccount() { WebComboBox accoutCbx = (WebComboBox) getValue("account"); final WebPasswordField passwordFld = (WebPasswordField) getValue("password"); StatusPopup statusPopup = (StatusPopup) getValue("status"); WebCheckBox rePwdCkb = (WebCheckBox) getValue("rememberPwd"); // ? rePwdCkb.setSelected(true); statusPopup.setCurrentStatus(QQStatus.ONLINE); accoutCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getItem() instanceof UserListElement) { UserListElement userElt = (UserListElement) e.getItem(); QQAccount account = (QQAccount) userElt.getUserNamed().getEntity(); passwordFld.setText(account.getPassword()); } else { passwordFld.clear(); } } }); }
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 ww w. j a va 2 s. c om 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()); }