List of usage examples for javax.swing JList setUI
@BeanProperty(hidden = true, visualUpdate = true, description = "The UI object that implements the Component's LookAndFeel.") public void setUI(ListUI ui)
From source file:Main.java
public static JList generateListFor(Object... objs) { Container c = search(objs, Container.class); String[] name_value = search(objs, String[].class); ListModel model = search(objs, ListModel.class); Object[] dataObjects = search(objs, Object[].class); Vector dataVector = search(objs, Vector.class); ListSelectionListener selectionListener = search(objs, ListSelectionListener.class); ListUI ui = search(objs, ListUI.class); ListSelectionModel selectionModel = search(objs, ListSelectionModel.class); ListCellRenderer cellRenderer = search(objs, ListCellRenderer.class); JList list = model == null ? (dataObjects == null ? (dataVector == null ? new JList() : new JList(dataVector)) : new JList(dataObjects)) : new JList(model); list.setName(name_value == null ? "" : name_value[0]); if (selectionListener != null) list.addListSelectionListener(selectionListener); if (ui != null) list.setUI(ui); if (selectionModel != null) list.setSelectionModel(selectionModel); if (cellRenderer != null) list.setCellRenderer(cellRenderer); addJContainerListeners(list, objs);/*from w ww .j a va 2 s. c om*/ if (c != null) addToContainer(c, list); return list; }
From source file:com.projity.pm.graphic.chart.ChartLegend.java
JList getListInstance(boolean cost) { final JList list = new JList() { // do not want to update the UI. see below also private static final long serialVersionUID = 1L; public void updateUI() { if (!Environment.isNewLook()) super.updateUI(); }//from w w w .j a v a2s . c o m }; if (Environment.isNewLook()) // The PLAF can override the custom renderer. This avoids that list.setUI(new BasicListUI()); list.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setCellRenderer(new ListRenderer()); setListFields(list, cost); if (!simple) { list.setSelectedIndex(0); // start off with first choice selected list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (chartInfo.isRestoring()) // don't want to listen if updating from workspace return; if (e.getValueIsAdjusting() == false) { chartInfo.setTraces(list.getSelectedValues()); } } }); } return list; }