private void updateButtons() { int index = list.getSelectedIndex(); remove.setEnabled(index != -1 && listModel.getSize() != 0); moveUp.setEnabled(index > 0); moveDown.setEnabled(index != -1 && index != listModel.getSize() - 1); edit.setEnabled(index != -1); }
/** Fetch movie names from the database and display them in the name list. */ private void fillNameList() { nameListModel.removeAllElements(); ArrayList<String> list = db.getMovies(); for (String s : list) { nameListModel.addElement(s); } }
/** Description of the Method */ public void removeAllElements() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.stopMonitor(); } listModel.removeAllElements(); }
private void populateActiveKitList() { // populate the active kits list with the current kits available in the factory listModel.removeAllElements(); for (Integer i : kits.keySet()) { Kits currentKit = kits.get(i); listModel.addElement(currentKit); } }
public List<BufferedImage> getExamples() { List<BufferedImage> list = new ArrayList<BufferedImage>(); for (int i = 0; i < model.size(); i++) { Example example = (Example) model.get(i); list.add(example.getBufferedImage()); } return list; }
/** * Adds the given Bean to the collection of Beans with preferences editors. When the dialog box is * opened, the editor associated with the Bean will be included in the GUI. */ public void addPrefsBean(BeanPreferences bean) { mPrefsBeans.add(bean); mTabbedViewPane.add(new JScrollPane(bean.getEditor()), bean.getEditorName()); bean.initPrefsGUI(); mTabbedViewPane.revalidate(); DefaultListModel model = (DefaultListModel) mListViewBeans.getModel(); model.addElement(bean.getEditorName()); }
/** List results by alphabetical name */ private void listByProgramName() { int nresult = datasets.size(); String res[] = new String[nresult]; for (int i = 0; i < nresult; i++) res[i] = (String) datasets.getElementAt(i); Arrays.sort(res); datasets.removeAllElements(); for (int i = 0; i < nresult; i++) datasets.addElement(res[i]); }
/** Fetch performance dates from the database and display them in the date list. */ private void fillDateList(String movieName) { dateListModel.removeAllElements(); /* --- insert own code here --- */ ArrayList<String> list = db.getShowdates(movieName); for (String s : list) { dateListModel.addElement(s); } }
/** * List results by date * * @param reslist result list * @param ldisp */ private void listByDateRun(ResultList reslist, boolean ldisp) { StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n"); Vector vdata = new Vector(); while (tokenizer.hasMoreTokens()) { String data = convertToPretty(tokenizer.nextToken()); if (datasets.contains(data) || ldisp) vdata.add(data); } datasets.removeAllElements(); Enumeration en = vdata.elements(); while (en.hasMoreElements()) datasets.addElement(en.nextElement()); }
/** * Rebuild the parent view after a directory has been loaded. * * @param node * @param path * @param directory */ public void directoryLoaded(Object node, String path, java.util.List<VFSFile> directory) { // {{{ If reloading root, update parent directory list if (node == null) { DefaultListModel parentList = new DefaultListModel(); String parent = path; for (; ; ) { VFS _vfs = VFSManager.getVFSForPath(parent); VFSFile file = null; if (_vfs instanceof FileVFS) { Object session = _vfs.createVFSSession(path, browser); try { file = _vfs._getFile(session, parent, browser); if (file != null) { file.setName(_vfs.getFileName(parent)); } } catch (IOException e) { Log.log(Log.ERROR, this, e, e); } } if (file == null) { // create a DirectoryEntry manually // instead of using _vfs._getFile() // since so many VFS's have broken // implementations of this method file = new VFSFile(_vfs.getFileName(parent), parent, parent, VFSFile.DIRECTORY, 0L, false); } /*parentList.insertElementAt(new VFSFile( _vfs.getFileName(parent), parent,parent, VFSFile.DIRECTORY, 0L,false),0);*/ parentList.insertElementAt(file, 0); String newParent = _vfs.getParentOfPath(parent); if (newParent == null || MiscUtilities.pathsEqual(parent, newParent)) break; else parent = newParent; } parentDirectories.setModel(parentList); int index = parentList.getSize() - 1; parentDirectories.setSelectedIndex(index); parentDirectories.ensureIndexIsVisible(index); } // }}} table.setDirectory(VFSManager.getVFSForPath(path), node, directory, tmpExpanded); } // }}}
/** * Removes a <tt>ConfigurationForm</tt> from this list. * * @param configForm The <tt>ConfigurationForm</tt> to remove. */ public void removeConfigForm(ConfigurationForm configForm) { DefaultListModel listModel = (DefaultListModel) configList.getModel(); for (int count = listModel.getSize(), i = count - 1; i >= 0; i--) { ConfigurationForm form = (ConfigurationForm) listModel.get(i); if (form.equals(configForm)) { listModel.remove(i); /* * TODO We may just consider not allowing duplicates on addition * and then break here. */ } } }
/** * Adds a new <tt>ConfigurationForm</tt> to this list. * * @param configForm The <tt>ConfigurationForm</tt> to add. */ public void addConfigForm(ConfigurationForm configForm) { if (configForm == null) throw new IllegalArgumentException("configForm"); DefaultListModel listModel = (DefaultListModel) configList.getModel(); int i = 0; int count = listModel.getSize(); int configFormIndex = configForm.getIndex(); for (; i < count; i++) { ConfigurationForm form = (ConfigurationForm) listModel.get(i); if (configFormIndex < form.getIndex()) break; } listModel.add(i, configForm); }
public void updateClientList() { Iterator i = clients.iterator(); DefaultListModel model = new DefaultListModel(); EditorClient placebo = new EditorClient(self, 0, " ", 0, 0, ""); model.addElement(placebo); while (i.hasNext()) { EditorClient c = (EditorClient) i.next(); model.addElement(c); } lstClients.setModel(model); lstClients.setSelectedValue(currClient, true); }
/** * Sets the valueAt attribute of the BPMsList object * * @param aValue The new valueAt value * @param row The new valueAt value * @param column The new valueAt value */ public void setValueAt(Object aValue, int row, int column) { if (column == 1) { BPM_Element elm = listModel.elementAt(row); elm.setActive(!elm.isActive()); fireTableCellUpdated(row, column); } }
/** * Returns the valueAt attribute of the BPMsList object * * @param row The Parameter * @param column The Parameter * @return The valueAt value */ public Object getValueAt(int row, int column) { BPM_Element elm = listModel.elementAt(row); if (column == 0) { return elm.getName(); } return elm.isActiveObj(); }
private void initFrame() { this.setLocationRelativeTo(null); try { if (!Files.exists(saveName)) Files.createFile(saveName); laden(saveName); } catch (IOException e) { e.printStackTrace(); } nUebSchr.setSelected(true); if (!quellListModel.isEmpty()) quellJList.setSelectedIndex(0); if (!zielListModel.isEmpty()) zielJList.setSelectedIndex(0); starteLaufwerkspruefung(); }
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); loadButton = new JButton(loadString); loadButton.setActionCommand(loadString); loadButton.addActionListener(new loadListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name; if (listModel.size() > 0) { name = listModel.getElementAt(list.getSelectedIndex()).toString(); } // Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(loadButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
private void laden(Path saveName) throws IOException { Properties prop = new Properties(); FileInputStream in = new FileInputStream(saveName.toString()); prop.load(in); for (int i = 0; prop.containsKey(String.format("quellMenu%d", i)); i++) quellListModel.addElement( new ListItem( Paths.get(prop.getProperty(String.format("quellMenu%d", i))), Paths.get(prop.getProperty(String.format("quellMenu%d", i))))); for (int i = 0; prop.containsKey(String.format("zielMenu%d", i)); i++) zielListModel.addElement( new ListItem( Paths.get(prop.getProperty(String.format("zielMenu%d", i))), Paths.get(prop.getProperty(String.format("zielMenu%d", i))))); in.close(); }
/** * Returns the bPM attribute of the BPMsTable object * * @param name The Parameter * @return The bPM value */ public BPM_Element getBPM(String name) { BPM_Element bpmElm = null; Enumeration<BPM_Element> bpm_enum = listModel.elements(); while (bpm_enum.hasMoreElements()) { BPM_Element bpmElm1 = bpm_enum.nextElement(); if (bpmElm1.getName().equals(name)) { bpmElm = bpmElm1; } } return bpmElm; }
private void listOfNamesValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: int index = listOfNames.getSelectedIndex(); // System.out.println(index); listModel3.clear(); listModel4.clear(); for (int i = 0; i < 5; i++) { listModel3.addElement((answers.get(index))[i]); } answerList.setModel(listModel3); for (int i = 0; i < 5; i++) { if ((answers.get(index))[i] == correct[i]) { listModel4.addElement("2/2"); } else { listModel4.addElement("0/2"); } } pointList.setModel(listModel4); }
/** Creates new form NewJFrame */ public GraderUI() { initComponents(); listModel = new DefaultListModel(); listModel2 = new DefaultListModel(); listModel3 = new DefaultListModel(); listModel4 = new DefaultListModel(); names.add("Kevin Pham"); names.add("RJ Almada"); names.add("Alvin Lam"); names.add("Neil Nordhof"); names.add("Grant Pickett"); names.add("Yuliya Levitskaya"); answers.add(kevinAns); answers.add(RJAns); answers.add(alvinAns); answers.add(neilAns); answers.add(grantAns); answers.add(yuliyaAns); questions.add("True or False: A function cannot be defined inside another function. (2 pts)"); questions.add("True or False: Functions cannot return more than one value at a time. (2 pts)"); questions.add( "True or False: If return type for a function is not specified, it defaults to int. (2 pts)"); questions.add("True or False: Functions can be called either by value or reference. (2 pts)"); questions.add( "True or False: A function may have any number of return statements each returning different values. (2 pts)"); for (int i = 0; i < names.size(); i++) { listModel.addElement(names.get(i)); } for (int i = 0; i < 5; i++) { listModel2.addElement("Question " + (i + 1)); } listOfNames.setModel(listModel); listOfQuestions.setModel(listModel2); listOfNames.setSelectedIndex(0); listOfQuestions.setSelectedIndex(0); setVisible(true); }
/** Constructor for the BPMsList object */ public BPMsTable() { listModel.addListDataListener( new ListDataListener() { public void contentsChanged(ListDataEvent e) { fireTableDataChanged(); } public void intervalAdded(ListDataEvent e) { fireTableDataChanged(); } public void intervalRemoved(ListDataEvent e) { fireTableDataChanged(); } }); }
public void setMap( HashMap map, JTextArea textArea, JTextField[] textFields, JLabel[] labels, JLabel actionLabel) { this.map = map; this.textArea = textArea; this.textFields = textFields; this.labels = labels; this.table = table; this.action = actionLabel; int index = 0; for (Object o : map.keySet().toArray()) { listModel.add(index, o.toString()); index++; } }
private void speichern(Path saveName) { Properties prop = new Properties(); if (!quellListModel.isEmpty()) for (int i = 0; i < quellListModel.getSize(); i++) prop.setProperty( String.format("quellMenu%d", i), quellListModel.getElementAt(i).getValueMember().toString()); if (!zielListModel.isEmpty()) for (int i = 0; i < zielListModel.getSize(); i++) prop.setProperty( String.format("zielMenu%d", i), zielListModel.getElementAt(i).getValueMember().toString()); try { FileOutputStream out = new FileOutputStream(saveName.toString()); prop.store(out, null); out.close(); } catch (Exception e) { e.printStackTrace(); } }
/** * Returns the rowCount attribute of the BPMsList object * * @return The rowCount value */ public int getRowCount() { return listModel.getSize(); }
public ListDataEventDemo() { super(new BorderLayout()); // Create and populate the list model. listModel = new DefaultListModel(); listModel.addElement("Whistler, Canada"); listModel.addElement("Jackson Hole, Wyoming"); listModel.addElement("Squaw Valley, California"); listModel.addElement("Telluride, Colorado"); listModel.addElement("Taos, New Mexico"); listModel.addElement("Snowbird, Utah"); listModel.addElement("Chamonix, France"); listModel.addElement("Banff, Canada"); listModel.addElement("Arapahoe Basin, Colorado"); listModel.addElement("Kirkwood, California"); listModel.addElement("Sun Valley, Idaho"); listModel.addListDataListener(new MyListDataListener()); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); // Create the list-modifying buttons. addButton = new JButton(addString); addButton.setActionCommand(addString); addButton.addActionListener(new AddButtonListener()); deleteButton = new JButton(deleteString); deleteButton.setActionCommand(deleteString); deleteButton.addActionListener(new DeleteButtonListener()); ImageIcon icon = createImageIcon("Up16"); if (icon != null) { upButton = new JButton(icon); upButton.setMargin(new Insets(0, 0, 0, 0)); } else { upButton = new JButton("Move up"); } upButton.setToolTipText("Move the currently selected list item higher."); upButton.setActionCommand(upString); upButton.addActionListener(new UpDownListener()); icon = createImageIcon("Down16"); if (icon != null) { downButton = new JButton(icon); downButton.setMargin(new Insets(0, 0, 0, 0)); } else { downButton = new JButton("Move down"); } downButton.setToolTipText("Move the currently selected list item lower."); downButton.setActionCommand(downString); downButton.addActionListener(new UpDownListener()); JPanel upDownPanel = new JPanel(new GridLayout(2, 1)); upDownPanel.add(upButton); upDownPanel.add(downButton); // Create the text field for entering new names. nameField = new JTextField(15); nameField.addActionListener(new AddButtonListener()); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); nameField.setText(name); // Create a control panel, using the default FlowLayout. JPanel buttonPane = new JPanel(); buttonPane.add(nameField); buttonPane.add(addButton); buttonPane.add(deleteButton); buttonPane.add(upDownPanel); // Create the log for reporting list data events. log = new JTextArea(10, 20); JScrollPane logScrollPane = new JScrollPane(log); // Create a split pane for the log and the list. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, listScrollPane, logScrollPane); splitPane.setResizeWeight(0.5); // Put everything together. add(buttonPane, BorderLayout.PAGE_START); add(splitPane, BorderLayout.CENTER); }
// Swap two elements in the list. private void swap(int a, int b) { Object aObject = listModel.getElementAt(a); Object bObject = listModel.getElementAt(b); listModel.set(a, bObject); listModel.set(b, aObject); }
/** Description of the Method */ public void startMonitor() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.startMonitor(); } }
myjava.gui.syntax.Painter getPainter() { // update painter first this.painter = TypeColorEntry.toPainter(this.painter.getName(), Collections.list(listModel.elements())); return this.painter; }
/** * Show the results sent to a batch queue. * * @param mysettings jemboss settings * @param epr pending results * @throws JembossSoapException when server connection fails */ public ShowSavedResults(final JembossParams mysettings, final PendingResults epr) throws JembossSoapException { this("Current Sessions Results"); Dimension d = new Dimension(270, 100); ss.setPreferredSize(d); // ss.setMaximumSize(d); JMenu resFileMenu = new JMenu("File"); resMenu.add(resFileMenu); JButton refresh = new JButton(rfii); refresh.setMargin(new Insets(0, 1, 0, 1)); refresh.setToolTipText("Refresh"); resMenu.add(refresh); refresh.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setCursor(cbusy); epr.updateStatus(); setCursor(cdone); datasets.removeAllElements(); Enumeration enumer = epr.descriptionHash().keys(); while (enumer.hasMoreElements()) { String image = convertToPretty((String) enumer.nextElement()); datasets.addElement(image); } } }); JMenuItem resFileMenuExit = new JMenuItem("Close"); resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK)); resFileMenuExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); resFileMenu.add(resFileMenuExit); setJMenuBar(resMenu); // set up the results list in the gui Enumeration enumer = epr.descriptionHash().keys(); while (enumer.hasMoreElements()) datasets.addElement(convertToPretty((String) enumer.nextElement())); final JList st = new JList(datasets); st.setCellRenderer(new TabListCellRenderer()); st.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; JList theList = (JList) e.getSource(); if (!theList.isSelectionEmpty()) { int index = theList.getSelectedIndex(); String thisdata = convertToOriginal(datasets.elementAt(index)); aboutRes.setText((String) epr.descriptionHash().get(thisdata)); aboutRes.setCaretPosition(0); aboutRes.setEditable(false); } } }); st.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { try { setCursor(cbusy); String project = convertToOriginal(st.getSelectedValue()); ResultList thisres = new ResultList(mysettings, project, "show_saved_results"); setCursor(cdone); if (thisres.getStatus().equals("0")) new ShowResultSet(thisres.hash(), project, mysettings); else JOptionPane.showMessageDialog( null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE); } catch (JembossSoapException eae) { AuthPopup ap = new AuthPopup(mysettings, null); ap.setBottomPanel(); ap.setSize(380, 170); ap.pack(); ap.setVisible(true); } } } }); sp.add(st); // display retrieves all the files and shows them in a window JPanel resButtonPanel = new JPanel(); JButton showResButton = new JButton("Display"); showResButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (st.getSelectedValue() != null) { try { setCursor(cbusy); String project = convertToOriginal(st.getSelectedValue()); ResultList thisres = new ResultList(mysettings, project, "show_saved_results"); setCursor(cdone); if (thisres.getStatus().equals("0")) new ShowResultSet(thisres.hash(), project, mysettings); else JOptionPane.showMessageDialog( null, thisres.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE); } catch (JembossSoapException eae) { setCursor(cdone); AuthPopup ap = new AuthPopup(mysettings, null); ap.setBottomPanel(); ap.setSize(380, 170); ap.pack(); ap.setVisible(true); } } } }); // delete removes the file on the server and edits the list JButton delResButton = new JButton("Delete"); delResButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Object sel[] = st.getSelectedValues(); if (sel != null) { String selList = new String(""); for (int i = 0; i < sel.length; i++) selList = selList.concat(sel[i] + "\n"); int ok = JOptionPane.OK_OPTION; if (sel.length > 1) ok = JOptionPane.showConfirmDialog( null, "Delete the following results:\n" + selList, "Confirm Deletion", JOptionPane.YES_NO_OPTION); if (ok == JOptionPane.OK_OPTION) { try { setCursor(cbusy); selList = convertToOriginal(selList); new ResultList(mysettings, selList, "delete_saved_results"); setCursor(cdone); for (int i = 0; i < sel.length; i++) { JembossProcess jp = epr.getResult(convertToOriginal(sel[i])); epr.removeResult(jp); datasets.removeElement(sel[i]); // amend the list } statusField.setText("Deleted " + sel.length + " result(s)"); aboutRes.setText(""); st.setSelectedIndex(-1); } catch (JembossSoapException eae) { // shouldn't happen AuthPopup ap = new AuthPopup(mysettings, null); ap.setBottomPanel(); ap.setSize(380, 170); ap.pack(); ap.setVisible(true); } } } } }); resButtonPanel.add(delResButton); resButtonPanel.add(showResButton); resButtonStatus.add(resButtonPanel, BorderLayout.CENTER); resButtonStatus.add(statusField, BorderLayout.SOUTH); Container c = getContentPane(); c.add(ss, BorderLayout.WEST); c.add(aboutScroll, BorderLayout.CENTER); c.add(resButtonStatus, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setVisible(true); // add in automatic updates String freq = (String) AdvancedOptions.jobMgr.getSelectedItem(); int ind = freq.indexOf(" "); new ResultsUpdateTimer(Integer.parseInt(freq.substring(0, ind)), datasets, this); statusField.setText("Window refresh rate " + freq); }