Java Code Examples for javax.swing.JList#setListData()
The following examples show how to use
javax.swing.JList#setListData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utility.java From iBioSim with Apache License 2.0 | 6 votes |
/** * Adds a new item to a JList */ public static void add(JList currentList, Object newItem) { Object[] list = new Object[currentList.getModel().getSize() + 1]; int addAfter = currentList.getSelectedIndex(); for (int i = 0; i <= currentList.getModel().getSize(); i++) { if (i <= addAfter) { list[i] = currentList.getModel().getElementAt(i); } else if (i == (addAfter + 1)) { list[i] = newItem; } else { list[i] = currentList.getModel().getElementAt(i - 1); } } currentList.setListData(list); }
Example 2
Source File: PsychoPanel2.java From psychoPATH with GNU General Public License v3.0 | 5 votes |
protected void appendListData(JList list, String[] items) { ArrayList tmp = new ArrayList(); for (int i=0; i < list.getModel().getSize(); i++) { String elem = (String) list.getModel().getElementAt(i); tmp.add(elem); } for(String item: items) { if(!tmp.contains(item)) tmp.add(item); } list.setListData(tmp.toArray()); }
Example 3
Source File: PsychoPanel2.java From psychoPATH with GNU General Public License v3.0 | 5 votes |
private void removeFromListData(JList list, String item) { ArrayList tmp = new ArrayList(); for (int i=0; i < list.getModel().getSize(); i++) { String elem = (String) list.getModel().getElementAt(i); if(!elem.equals(item)) tmp.add(elem); } list.setListData(tmp.toArray()); }
Example 4
Source File: Units.java From iBioSim with Apache License 2.0 | 5 votes |
public Units(BioModel gcm, ModelEditor modelEditor) { super(new BorderLayout()); this.bioModel = gcm; this.modelEditor = modelEditor; Model model = gcm.getSBMLDocument().getModel(); addUnit = new JButton("Add Unit"); removeUnit = new JButton("Remove Unit"); editUnit = new JButton("Edit Unit"); unitDefs = new JList(); ListOf<UnitDefinition> listOfUnits = model.getListOfUnitDefinitions(); String[] units = new String[model.getUnitDefinitionCount()]; for (int i = 0; i < model.getUnitDefinitionCount(); i++) { UnitDefinition unit = listOfUnits.get(i); units[i] = unit.getId(); // GET OTHER THINGS } JPanel addRem = new JPanel(); addRem.add(addUnit); addRem.add(removeUnit); addRem.add(editUnit); addUnit.addActionListener(this); removeUnit.addActionListener(this); editUnit.addActionListener(this); JLabel panelLabel = new JLabel("List of Units:"); JScrollPane scroll = new JScrollPane(); scroll.setMinimumSize(new Dimension(260, 220)); scroll.setPreferredSize(new Dimension(276, 152)); scroll.setViewportView(unitDefs); edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(units); unitDefs.setListData(units); unitDefs.setSelectedIndex(0); unitDefs.addMouseListener(this); this.add(panelLabel, "North"); this.add(scroll, "Center"); this.add(addRem, "South"); }
Example 5
Source File: ToolSelectorPanel.java From chipster with MIT License | 5 votes |
/** * Creates a new ToolSelectorPanel. * * @param parent The ToolPanel, for communication purposes. */ public ToolSelectorPanel(ToolPanel parent, ToolModule toolModule) { super(new GridLayout(1, 2)); this.toolPanel = parent; this.toolModule = toolModule; List<ToolCategory> toolCategories; toolCategories = Collections.list(Collections.enumeration(toolModule.getVisibleCategories())); categoryList = new JList(); categoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); categoryList.addListSelectionListener(this); categoryList.setCellRenderer(new CategoryListRenderer()); categoryList.getInsets().right = 1; categoryList.setName("categoryList"); categoryList.setListData(toolCategories.toArray()); toolList = new JList(); toolList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); toolList.addListSelectionListener(this); toolList.setCellRenderer(new FontSizeFriendlyListRenderer()); toolList.addMouseListener(new MouseClickListener()); toolList.getInsets().right = 1; toolList.setName("toolList"); JScrollPane categoryListScroller = new JScrollPane(categoryList); JScrollPane toolListScroller = new JScrollPane(toolList); //Remove useless borders categoryListScroller.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, VisualConstants.TOOL_LIST_BORDER_COLOR)); toolListScroller.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(categoryListScroller); this.add(toolListScroller); }
Example 6
Source File: FBAObjective.java From iBioSim with Apache License 2.0 | 4 votes |
public FBAObjective(BioModel bioModel) { super(new BorderLayout()); this.bioModel = bioModel; fbc = bioModel.getSBMLFBC(); bigPanel = new JPanel(new BorderLayout()); objectiveStringArray = new String[fbc.getListOfObjectives().size()]; activeObjective = fbc.getListOfObjectives().getActiveObjective(); for (int i = 0; i < fbc.getListOfObjectives().size(); i++) { String objective = ""; Type type = fbc.getObjective(i).getType(); String id = fbc.getObjective(i).getId(); if(activeObjective.equals(id)){ objective = "*"; } if (type.equals(Type.MINIMIZE)) { objective += "Min"; } else { objective += "Max"; } objective += "(" + id + ") = "; boolean first = true; for (int j = 0; j < fbc.getObjective(i).getListOfFluxObjectives().size(); j++) { FluxObjective fluxObjective = fbc.getObjective(i).getListOfFluxObjectives().get(j); String indexStr = SBMLutilities.getIndicesString(fluxObjective, "fbc:reaction"); if (!first) objective += " + "; else first = false; objective += fluxObjective.getCoefficient() + " * " + fluxObjective.getReaction() + indexStr; } objectiveStringArray[i] = objective; } objectives = new JList(); objectiveList = new JList(); JPanel ObjectiveCreationPanel = new JPanel(new BorderLayout()); JPanel buttons = new JPanel(); JButton addObjective = new JButton("Add"); JButton removeObjective = new JButton("Remove"); JButton editObjective = new JButton("Edit"); buttons.add(addObjective); buttons.add(removeObjective); buttons.add(editObjective); addObjective.addActionListener(this); removeObjective.addActionListener(this); editObjective.addActionListener(this); JLabel ObjectiveCreationLabel = new JLabel("List of Objectives:"); objectiveList.removeAll(); objectiveList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(); scroll.setMinimumSize(new Dimension(260, 220)); scroll.setPreferredSize(new Dimension(276, 152)); scroll.setViewportView(objectiveList); edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(objectiveStringArray); objectiveList.setListData(objectiveStringArray); objectiveList.setSelectedIndex(0); objectiveList.addMouseListener(this); ObjectiveCreationPanel.add(ObjectiveCreationLabel, "North"); ObjectiveCreationPanel.add(scroll, "Center"); ObjectiveCreationPanel.add(buttons, "South"); bigPanel.add(ObjectiveCreationPanel, "South"); }
Example 7
Source File: Constraints.java From iBioSim with Apache License 2.0 | 4 votes |
public Constraints(BioModel bioModel, ModelEditor modelEditor) { super(new BorderLayout()); this.bioModel = bioModel; this.modelEditor = modelEditor; Model model = bioModel.getSBMLDocument().getModel(); addConstraint = new JButton("Add Constraint"); removeConstraint = new JButton("Remove Constraint"); editConstraint = new JButton("Edit Constraint"); constraints = new JList(); ListOf<Constraint> listOfConstraints = model.getListOfConstraints(); String[] cons = new String[model.getConstraintCount()]; for (int i = 0; i < model.getConstraintCount(); i++) { Constraint constraint = listOfConstraints.get(i); if (!constraint.isSetMetaId()) { String constraintId = "c0"; int cn = 0; while (bioModel.isSIdInUse(constraintId)) { cn++; constraintId = "c" + cn; } SBMLutilities.setMetaId(constraint, constraintId); } cons[i] = constraint.getMetaId(); cons[i] += SBMLutilities.getDimensionString(constraint); } JPanel addRem = new JPanel(); addRem.add(addConstraint); addRem.add(removeConstraint); addRem.add(editConstraint); addConstraint.addActionListener(this); removeConstraint.addActionListener(this); editConstraint.addActionListener(this); JLabel panelLabel = new JLabel("List of Constraints:"); JScrollPane scroll = new JScrollPane(); scroll.setMinimumSize(new Dimension(260, 220)); scroll.setPreferredSize(new Dimension(276, 152)); scroll.setViewportView(constraints); edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(cons); constraints.setListData(cons); constraints.setSelectedIndex(0); constraints.addMouseListener(this); this.add(panelLabel, "North"); this.add(scroll, "Center"); this.add(addRem, "South"); }
Example 8
Source File: TypesPrecedenceFrame.java From ontopia with Apache License 2.0 | 4 votes |
private void setListData(JList list, Vector vector) { list.setListData(vector); }
Example 9
Source File: GeneralConfigFrame.java From ontopia with Apache License 2.0 | 4 votes |
private void setListDate(JList list, Vector vector) { sortCollection(vector); list.setListData(vector); }