List of usage examples for javax.swing DefaultListModel addElement
public void addElement(E element)
From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java
private void addVersions(List<JIRAVersionBean> versions) { versionsList.removeAll();//from www. ja v a 2s .com final DefaultListModel listModel = new DefaultListModel(); for (JIRAVersionBean version : versions) { if (version != null && version.getId() != CacheConstants.ANY_ID) { listModel.addElement(new VersionWrapper(version)); } } versionsList.setModel(listModel); versionsList.setEnabled(true); createAction.setEnabled(true); createAndOpenAction.setEnabled(true); }
From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java
private void addFixForVersions(List<JIRAFixForVersionBean> versions) { fixVersionsList.removeAll();/*from ww w. j a v a2 s . c o m*/ final DefaultListModel listModel = new DefaultListModel(); for (JIRAFixForVersionBean version : versions) { if (version != null && version.getId() != CacheConstants.ANY_ID) { listModel.addElement(new VersionWrapper(version)); } } fixVersionsList.setModel(listModel); fixVersionsList.setEnabled(true); getOKAction().setEnabled(true); }
From source file:gtu._work.ui.ExportSVNModificationFilesUI.java
void reflushOutputList() { DefaultListModel model = (DefaultListModel) srcList.getModel(); LineParser lineParser = null;//from w w w.ja v a 2s . c o m OutputFile outputFile = null; List<File> list = new ArrayList<File>(); for (int ii = 0; ii < model.size(); ii++) { lineParser = (LineParser) model.getElementAt(ii); list.add(lineParser.file); } File baseDir = FileUtil.exportReceiveBaseDir(list); Validate.notNull(baseDir, "no common base directory!"); DefaultListModel outputModel = new DefaultListModel(); for (int ii = 0; ii < model.size(); ii++) { lineParser = (LineParser) model.getElementAt(ii); outputFile = new OutputFile(); outputFile.srcFile = lineParser.file; outputFile.destFile = FileUtil.exportFileToTargetPath(lineParser.file, baseDir, outputDir); outputModel.addElement(outputFile); } outPutList.setModel(outputModel); }
From source file:dictionary.GUI.GUI_Main.java
private void initData(ArrayList<String> list) { DefaultListModel<String> model = new DefaultListModel(); System.out.println("\n" + list.size()); list.stream().forEach((list1) -> { model.addElement(list1); });//from ww w . j a v a 2 s . com listEntries.setModel(model); }
From source file:net.linra.AttendanceSystemFrame.java
/** * Creates new form AttendanceSystemFrame *//*from ww w. j a v a 2 s . c om*/ public AttendanceSystemFrame() { initComponents(); DefaultListModel model = (DefaultListModel) jList1.getModel(); String[] strings = { "student1", "student2", "student3", "student4", "student5", "student6", "student7", "student8", "student9", "student10", "student11", "student12", "student13", "student14", "student15", "student16", "student17", "student18", "student19", "student20", "student21", "student22", "student23", "student24", "student25" }; for (String item : strings) { model.addElement(item); } }
From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java
private void addComponents(Collection<JIRAComponentBean> components) { final DefaultListModel listModel = new DefaultListModel(); for (JIRAComponentBean constant : components) { if (constant != null && constant.getId() != CacheConstants.ANY_ID && constant.getId() != CacheConstants.UNKNOWN_COMPONENT_ID) { listModel.addElement(new ComponentWrapper(constant)); }/*w ww. j a v a 2 s . c o m*/ } componentsList.setModel(listModel); if (projectComboBox.getSelectedItem() != null && jiraConfiguration != null && jiraConfiguration.getView() != null && jiraConfiguration.getView().getServerDefaultss() != null && jiraConfiguration.getView().getServerDefaultss().containsKey(jiraServerData.getServerId())) { String selectedProject = ((JIRAProject) projectComboBox.getSelectedItem()).getKey(); String configProject = jiraConfiguration.getView().getServerDefaultss() .get(jiraServerData.getServerId()).getProject(); Collection<Long> configComponents = jiraConfiguration.getView().getServerDefaultss() .get(jiraServerData.getServerId()).getComponents(); // select default components for specified project if (selectedProject.equals(configProject)) { ArrayList<Integer> indexesToSelect = new ArrayList<Integer>( componentsList.getModel().getSize() + 1); for (int i = 0; i < componentsList.getModel().getSize(); ++i) { if (componentsList.getModel().getElementAt(i) instanceof ComponentWrapper) { ComponentWrapper wrapper = (ComponentWrapper) componentsList.getModel().getElementAt(i); if (wrapper.getWrapped() != null) { JIRAComponentBean component = wrapper.getWrapped(); if (configComponents.contains(component.getId())) { indexesToSelect.add(i); } } } } if (indexesToSelect.size() > 0) { componentsList.setSelectedIndices( ArrayUtils.toPrimitive(indexesToSelect.toArray(new Integer[indexesToSelect.size()]))); } } } componentsList.setEnabled(true); getOKAction().setEnabled(true); }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public void loadDocuments(int projectID, Statement stmt) { try {//from ww w. jav a 2 s. com String sql = "SELECT * from doc_info where Project_ID=" + projectID; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { String docPath = URLDecoder.decode(rs.getString("Doc_Path"), "UTF8"); String lang = rs.getString("Language"); String text = URLDecoder.decode(rs.getString("Text"), "UTF8"); DefaultListModel model = (DefaultListModel) inputDocList.getModel(); model.addElement(new Document(lang, new File(docPath), text)); } inputTermSelectionPanel.setInputDocumentListModel(inputDocList.getModel()); } catch (SQLException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public void loadDocuments(File openDir) { File docInfo = new File(openDir, ProjectFileNames.DOC_INFO_FILE); if (!docInfo.exists()) { return;//from w ww. java2 s .co m } BufferedReader reader = null; try { FileInputStream fis = new FileInputStream(docInfo); reader = new BufferedReader(new InputStreamReader(fis, "UTF-8")); while (reader.ready()) { String line = reader.readLine(); String[] info = line.split(","); if (info.length != 3) { continue; } String type = info[0]; String fileName = info[1]; String lang = info[2]; if (type.equals("doc")) { DefaultListModel model = (DefaultListModel) docList.getModel(); model.addElement(new Document(lang, new File(fileName))); } else if (type.equals("inputDoc")) { DefaultListModel model = (DefaultListModel) inputDocList.getModel(); model.addElement(new Document(lang, new File(fileName))); } } inputTermSelectionPanel.setInputDocumentListModel(inputDocList.getModel()); } catch (IOException ioex) { ioex.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException ioe2) { ioe2.printStackTrace(); } } }
From source file:stockit.Trader.java
/** * Creates new form Trader/*from w w w . j av a2 s .c o m*/ */ public Trader() { initComponents(); try { DefaultListModel demoList = new DefaultListModel(); DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT C.Name" + " FROM client as C, trader as t, trader_account as tc, account as a" + " WHERE C.Client_SSN = a.Client_SSN AND " + " tc.Trader_SSN = t.Trader_SSN " + " AND a.Trader_SSN = t.Trader_SSN " + " AND tc.username = \"" + username + "\""); while (rs.next()) { demoList.addElement(rs.getString("Name")); } dbcon.con.close(); listOfClients = new JList(demoList); jScrollPane3.setViewportView(listOfClients); //setUpTable(); } catch (Exception ex) { Logger.getLogger(clientLogin.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java
private void updateVillageList() { List<Tag> selection = getSelectedTags(); DefaultListModel model = new DefaultListModel(); List<Village> villages = new LinkedList<>(); for (Tag t : selection) { for (Integer id : t.getVillageIDs()) { Village v = DataHolder.getSingleton().getVillagesById().get(id); if (v != null && !villages.contains(v)) { villages.add(v);//w w w .jav a 2 s . c o m } } } if (!selection.isEmpty() && !villages.isEmpty()) { Collections.sort(villages); for (Village v : villages) { model.addElement(v); } } jVillageList.setModel(model); }