/** * Returns the code for the selected object, or {@code null} if none. * @return */ public String getSelectedCode() { final Code code = (Code) liste.getSelectedValue(); return (code != null) ? code.code : null; }
@SuppressWarnings("unchecked") public T getValue() { return canceled != true ? (T) iconList.getSelectedValue() : null; }
protected String getSelectedUser() { JLabel label = (JLabel) participantsList.getSelectedValue(); if (label != null) { return label.getText(); } return null; }
final JXList list = new JXList(AncientSwingTeam.createNamedColorListModel()); JXTable table = new JXTable(new AncientSwingTeam()); final ColorHighlighter highlighter = new ColorHighlighter( HighlightPredicate.NEVER, Color.YELLOW, null); list.addHighlighter(highlighter); table.addHighlighter(highlighter); ListSelectionListener l = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; highlighter.setHighlightPredicate( createPredicate(list.getSelectedValue())); } private HighlightPredicate createPredicate(Object selectedValue) { if (selectedValue == null) return HighlightPredicate.NEVER; return new HighlightPredicate.EqualsHighlightPredicate(selectedValue); } }; list.getSelectionModel().addListSelectionListener(l);
/** * Selects the specified object from the list, taking into account * sorting and filtering. * * @param anObject the object to select * @param shouldScroll {@code true} if the list should scroll to display * the selected object, if one exists; otherwise {@code false} */ @Override public void setSelectedValue(Object anObject,boolean shouldScroll) { // Note: this method is a copy of JList.setSelectedValue, // including comments. It simply usues getElementCount() and getElementAt() // instead of the model. if(anObject == null) setSelectedIndex(-1); else if(!anObject.equals(getSelectedValue())) { int i,c; for(i=0,c=getElementCount();i<c;i++) if(anObject.equals(getElementAt(i))){ setSelectedIndex(i); if(shouldScroll) ensureIndexIsVisible(i); repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ return; } setSelectedIndex(-1); } repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ }
/** * Selects the specified object from the list, taking into account * sorting and filtering. * * @param anObject the object to select * @param shouldScroll {@code true} if the list should scroll to display * the selected object, if one exists; otherwise {@code false} */ @Override public void setSelectedValue(Object anObject,boolean shouldScroll) { // Note: this method is a copy of JList.setSelectedValue, // including comments. It simply usues getElementCount() and getElementAt() // instead of the model. if(anObject == null) setSelectedIndex(-1); else if(!anObject.equals(getSelectedValue())) { int i,c; for(i=0,c=getElementCount();i<c;i++) if(anObject.equals(getElementAt(i))){ setSelectedIndex(i); if(shouldScroll) ensureIndexIsVisible(i); repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ return; } setSelectedIndex(-1); } repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ }
/** * Selects the specified object from the list, taking into account * sorting and filtering. * * @param anObject the object to select * @param shouldScroll {@code true} if the list should scroll to display * the selected object, if one exists; otherwise {@code false} */ @Override public void setSelectedValue(Object anObject,boolean shouldScroll) { // Note: this method is a copy of JList.setSelectedValue, // including comments. It simply usues getElementCount() and getElementAt() // instead of the model. if(anObject == null) setSelectedIndex(-1); else if(!anObject.equals(getSelectedValue())) { int i,c; for(i=0,c=getElementCount();i<c;i++) if(anObject.equals(getElementAt(i))){ setSelectedIndex(i); if(shouldScroll) ensureIndexIsVisible(i); repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ return; } setSelectedIndex(-1); } repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ }
/** * Selects the specified object from the list, taking into account * sorting and filtering. * * @param anObject the object to select * @param shouldScroll {@code true} if the list should scroll to display * the selected object, if one exists; otherwise {@code false} */ @Override public void setSelectedValue(Object anObject,boolean shouldScroll) { // Note: this method is a copy of JList.setSelectedValue, // including comments. It simply usues getElementCount() and getElementAt() // instead of the model. if(anObject == null) setSelectedIndex(-1); else if(!anObject.equals(getSelectedValue())) { int i,c; for(i=0,c=getElementCount();i<c;i++) if(anObject.equals(getElementAt(i))){ setSelectedIndex(i); if(shouldScroll) ensureIndexIsVisible(i); repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ return; } setSelectedIndex(-1); } repaint(); /** FIX-ME setSelectedIndex does not redraw all the time with the basic l&f**/ }
itemModel.removePropertyChangeListener(Item.PROPERTY_SANE, saneChanged); }); String selectedKey = (String) list.getSelectedValue(); Item itemModel = get(selectedKey); if (itemModel != null) {
private void globalListActionPerformed(MouseEvent e) { if (e.getClickCount() == 1) { final String selected = (String) globalList.getSelectedValue(); Color newColor = CyColorChooser.showDialog(this, "Choose new color.", Color.white); try { Cytoscape.getVisualMappingManager().getVisualStyle().getGlobalAppearanceCalculator() .setDefaultColor(selected, newColor); Cytoscape.getVisualMappingManager().applyGlobalAppearances(); } catch (Exception e1) { logger.warn("Unable to set default color!", e1); } buildList(); Cytoscape.getVisualMappingManager().getNetworkView().redrawGraph(false, true); if (selected.equals("Background Color")) { Cytoscape.getVisualMappingManager().applyGlobalAppearances(); mainView.updateBackgroungColor(newColor); } mainView.updateView(); mainView.repaint(); } }