/** 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 fillList(final HighlightSeverity severity) { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityBasedTextAttributes>(); infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); Collections.sort( infoTypes, new Comparator<SeverityBasedTextAttributes>() { @Override public int compare( SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) { return -mySeverityRegistrar.compare( attributes1.getSeverity(), attributes2.getSeverity()); } }); SeverityBasedTextAttributes preselection = null; for (SeverityBasedTextAttributes type : infoTypes) { model.addElement(type); if (type.getSeverity().equals(severity)) { preselection = type; } } myOptionsList.setModel(model); myOptionsList.setSelectedValue(preselection, true); }
/** 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); } }
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); } }
/** 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]); }
private void getNewDataModel() { if (listModel.size() != 0) listModel.removeAllElements(); if (rssFeed != null) { for (Data row = rssFeed.resetCursor(); row != null; row = rssFeed.next()) listModel.addElement(row.getTitle()); } }
/** 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()); }
@Override public void run() { searchButton.setEnabled(false); listModel.removeAllElements(); if (queryField.getText().trim().length() > 0) { HelpPage[] results; try { results = root.findPagesForTerm(queryField.getText().trim()); } catch (IOException e) { new CrashReporter(e); searchButton.setEnabled(true); return; } if (results.length > 0) { for (HelpPage helpPage : results) { listModel.addElement(helpPage); } } else { listModel.addElement("[No search results]"); } } // This stupid rigmarole is because on OSX the updated list just won't show up for some reason. // Removing the list and re-adding it forces it to // always show up. // It's not even enough to remake the scroll pane. You have to replace the entire JList. remove(resultsScrollPane); revalidate(); resultList = new JList(listModel); resultList.addListSelectionListener(this); resultsScrollPane = new JScrollPane(resultList); add(resultsScrollPane, BorderLayout.CENTER); revalidate(); repaint(); searchButton.setEnabled(true); }
public Frame() throws HeadlessException { setBounds(100, 100, 600, 400); setTitle("Regular 2"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea area = new JTextArea(); area.setText( "05.04.2016 ¤ сделал почти все лабы по программмированию. 04.11.1996 ¤ родилс¤. ”ра-ура!"); DefaultListModel model = new DefaultListModel(); JButton button = new JButton("GO!"); JList list = new JList(model); button.addActionListener( e -> { String text; model.removeAllElements(); text = area.getText(); // Pattern p = Pattern.compile("(((([0][1-9])|([1-2][0-9])|([3][0-1]))" + "[.]" + // "(([0][13578])|([1][0])|([1][2])))" + "|" + "((([0][1-9])|([1-2][0-9])|([3][0]))" + // "[.]" + "(([0][246])|([1][1]))))" + "[.]" + "([0-9]+)"); // Pattern p = Pattern.compile("(" + "((([0][1-9])|([1-2][0-9])|([3][0-1]))" + "[.]" + // "(([0][13578])|([1][0])|([1][2])))" + "|" + "((([0][1-9])|([1-2][0-9])|([3][0]))" + // "[.]" + "(([0][46])|([1][1])))" + "|" + "((([0][1-9])|([1-2][0-8]))" + "[.]" + // "([0][2]))" + ")" + "[.]" + "([0-9]+)"); Pattern p = Pattern.compile( "(" + "((([0][1-9])|([1-2]\\d)|([3][0-1]))" + "[.]" + "(([0][13578])|([1][0])|([1][2])))" + "|" + "((([0][1-9])|([1-2]\\d)|([3][0]))" + "[.]" + "(([0][46])|([1][1])))" + "|" + "((([0][1-9])|([1-2][0-8]))" + "[.]" + "([0][2]))" + ")" + "[.]" + "(\\d+)"); // 135781012 Matcher m = p.matcher(text); if (text.isEmpty()) { JOptionPane.showMessageDialog(null, "Enter the data!"); } // System.out.println(text); while (m.find()) { String string; string = m.group(); model.addElement(string); // System.out.println(string); } }); JPanel contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); contentPane.add(button, BorderLayout.NORTH); contentPane.add(area, BorderLayout.CENTER); contentPane.add(list, BorderLayout.SOUTH); setContentPane(contentPane); setVisible(true); }