List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java
private void loadDCXsiValues() { DefaultListModel model = new DefaultListModel(); model.addElement("dcterms:URI"); model.addElement("dcterms:ISBN"); model.addElement("dcterms:ISMN"); model.addElement("dcterms:ISSN"); theDcXsiList.setModel(model);// ww w . ja v a 2s. c om }
From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java
private void loadDCTermsValues() { DefaultListModel model = new DefaultListModel(); model.addElement("bibliographicCitation"); model.addElement("issued"); model.addElement("available"); model.addElement("isbn"); model.addElement("issn"); model.addElement("ismn"); model.addElement("url"); model.addElement("accrualPeriodicity"); model.addElement("created"); model.addElement("alternative"); theDcTermsTypeList.setModel(model);//from ww w .j a va 2 s . c o m }
From source file:ome.formats.importer.gui.HistoryDB.java
public DefaultListModel getBaseTableDataByDate(Date start, Date end) { ResultSet rs;/*w ww . ja v a 2 s . c om*/ try { rs = getQueryResults("SELECT * FROM import_table" + " WHERE date BETWEEN '" + sqlDateFormat.format(end) + "' AND '" + sqlDateFormat.format(start) + "'"); String icon; DefaultListModel list = new DefaultListModel(); for (; rs.next();) { if (rs.getString("status").equals("complete")) icon = "gfx/import_done_16.png"; else icon = "gfx/warning_msg16.png"; String dayString = day.format(rs.getObject("date")); String hourString = hour.format(rs.getObject("date")); if (day.format(new Date()).equals(dayString)) dayString = "Today"; if (day.format(getYesterday()).equals(dayString)) { dayString = "Yesterday"; } ImportEntry entry = new ImportEntry(dayString + " " + hourString, icon, rs.getInt("uID")); list.addElement(entry); } return list; } catch (SQLException e) { String s = String.format("Error retrieving import list from %s to %s.", start.toString(), end.toString()); log.error(s, e); } return null; }
From source file:ome.formats.importer.gui.HistoryTableStore.java
public DefaultListModel getBaseTableDataByDate(Date start, Date end) { try {// w w w . j a v a2 s . c o m // Format the current time. String dayString, hourString, status; long uid = 0L, importTime = 0L; String icon; DefaultListModel list = new DefaultListModel(); String searchString = "(DateTime>=" + start.getTime() + ") & (DateTime<=" + end.getTime() + ")"; long[] ids = baseTable.getWhereList(searchString, null, 0, baseTable.getNumberOfRows(), 1); int returnedRows = ids.length; if (DEBUG) log.debug("getBaseTableDataByDate returned rows: " + returnedRows); Data d = getBaseTableData(); if (d == null) { log.error("Error retrieving base table data."); return new DefaultListModel(); } LongColumn uids = (LongColumn) d.columns[BASE_UID_COLUMN]; LongColumn importTimes = (LongColumn) d.columns[BASE_DATETIME_COLUMN]; StringColumn statuses = (StringColumn) d.columns[BASE_STATUS_COLUMN]; for (int h = 0; h < returnedRows; h++) { int i = (int) ids[h]; try { uid = uids.values[i]; importTime = importTimes.values[i]; status = statuses.values[i].trim(); } catch (ArrayIndexOutOfBoundsException e) { System.err.println("ids[" + h + "] not found in dataset."); continue; } if (status.equals("complete")) icon = "gfx/import_done_16.png"; else icon = "gfx/warning_msg16.png"; dayString = day.format(new Date(importTime)); hourString = hour.format(new Date(importTime)); if (day.format(new Date()).equals(dayString)) dayString = "Today"; if (day.format(getYesterday()).equals(dayString)) { dayString = "Yesterday"; } ImportEntry entry = new ImportEntry(dayString + " " + hourString, icon, (int) uid); list.addElement(entry); } return list; } catch (Exception e) { String s = String.format("Error retrieving base list from %s to %s.", start.toString(), end.toString()); log.error(s, e); } return new DefaultListModel(); // return empty defaultlist }
From source file:op.care.info.DlgDiag.java
private void reloadTable() { if (txtSuche.getText().isEmpty()) { lstDiag.setModel(new DefaultListModel()); return;/*from w ww. java 2 s . co m*/ } EntityManager em = OPDE.createEM(); Query query = em.createQuery( "SELECT i FROM ICD i WHERE i.icd10 LIKE :icd10 OR i.text like :text ORDER BY i.icd10 "); String suche = "%" + txtSuche.getText() + "%"; query.setParameter("icd10", suche); query.setParameter("text", suche); lstDiag.setModel(SYSTools.list2dlm(query.getResultList())); em.close(); lstDiag.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); }
From source file:op.care.med.structure.PnlMed.java
private void txtSucheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSucheActionPerformed // treeMed.setCellRenderer(new DefaultTreeCellRenderer()); treeMed.setModel(new DefaultTreeModel(new DefaultMutableTreeNode())); // treeMed.setVisible(false); if (txtSuche.getText().isEmpty()) { lstPraep.setModel(new DefaultListModel()); } else {// www . j a v a 2s.co m EntityManager em = OPDE.createEM(); Query query = em .createQuery("SELECT m FROM MedProducts m WHERE m.text LIKE :bezeichnung ORDER BY m.text"); query.setParameter("bezeichnung", "%" + txtSuche.getText() + "%"); lstPraep.setModel(SYSTools.list2dlm(query.getResultList())); em.close(); } }
From source file:op.care.med.structure.PnlMed.java
private java.util.List<Component> addFilters() { java.util.List<Component> list = new ArrayList<Component>(); tbIDs = GUITools.getNiceToggleButton("misc.msg.showIDs"); tbIDs.addItemListener(new ItemListener() { @Override/* ww w .j a v a 2s .com*/ public void itemStateChanged(ItemEvent e) { reload(); } }); tbIDs.setHorizontalAlignment(SwingConstants.LEFT); list.add(tbIDs); txtSuche = new JXSearchField("Suchen"); txtSuche.setFont(SYSConst.ARIAL14); txtSuche.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { txtSucheActionPerformed(actionEvent); } }); txtSuche.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent focusEvent) { SYSTools.markAllTxt(txtSuche); } }); list.add(txtSuche); lstPraep = new JList(new DefaultListModel()); lstPraep.setCellRenderer(MedProductsTools.getMedProdukteRenderer()); lstPraep.setFont(SYSConst.ARIAL14); lstPraep.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { lstPraepValueChanged(listSelectionEvent); } }); lstPraep.setFixedCellWidth(200); list.add(new JScrollPane(lstPraep)); return list; }
From source file:op.tools.SYSTools.java
public static DefaultListModel list2dlm(List list) { DefaultListModel dlm = new DefaultListModel(); if (list != null) { for (Object o : list) { dlm.addElement(o);/* w ww .j ava 2 s . com*/ } } return dlm; }
From source file:op.tools.SYSTools.java
public static DefaultListModel cmb2lst(DefaultComboBoxModel dcbm) { DefaultListModel dlm = new DefaultListModel(); for (int i = 0; i < dcbm.getSize(); i++) { dlm.addElement(dcbm.getElementAt(i)); }/*ww w.j av a 2 s. co m*/ return dlm; }
From source file:org.apache.commons.jelly.demos.HomepageBuilder.java
public HomepageBuilder() { System.out.println("Starting Homepage Builder"); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS)); leftPanel.add(new JLabel("Name:")); nameField = new JTextField("James Bond"); leftPanel.add(nameField);/*from ww w . j ava2 s .c o m*/ leftPanel.add(new JLabel("Favorite Color:")); colorField = new JTextField("#007007"); leftPanel.add(colorField); leftPanel.add(new JLabel("Picture URL:")); urlField = new JTextField("http://www.ianfleming.org/007news/images3/c2002_pierce1.jpg"); leftPanel.add(urlField); leftPanel.add(new JLabel("Choose template:")); templateList = new JComboBox(new String[] { "template1.jelly", "template2.jelly" }); leftPanel.add(templateList); // JPanel rightPanel = new JPanel(); // rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS)); leftPanel.add(new JLabel("Add a Hobby:")); addField = new JTextField(); leftPanel.add(addField); JButton addButton = new JButton("Add >>>"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listModel.addElement(addField.getText()); } }); leftPanel.add(addButton); listModel = new DefaultListModel(); listModel.addElement("Killing bad guys"); listModel.addElement("Wrecking cars"); listModel.addElement("Eating jelly"); interestList = new JList(listModel); JButton submit = new JButton("Build and preview your page!"); submit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { buildPage(templateList.getSelectedItem().toString(), new JellyContext()); showPage(); } }); // Layout the demo setLayout(new BorderLayout()); add(submit, BorderLayout.SOUTH); add(leftPanel, BorderLayout.WEST); add(new JScrollPane(interestList), BorderLayout.EAST); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }