List of usage examples for javax.swing DefaultListModel removeAllElements
public void removeAllElements()
From source file:misc.TextBatchPrintingDemo.java
/** * Print all selected pages in separate threads, one thread per page. *//* w w w. ja v a 2s .co m*/ void printSelectedPages() { DefaultListModel pages = (DefaultListModel) selectedPages.getModel(); int n = pages.getSize(); if (n < 1) { messageArea.setText("No pages selected"); return; } if (printService == null) { messageArea.setText("No print service"); return; } for (int i = 0; i < n; i++) { final PageItem item = (PageItem) pages.getElementAt(i); // This method is called from EDT. Printing is a time-consuming // task, so it should be done outside EDT, in a separate thread. Runnable printTask = new Runnable() { public void run() { try { item.print( // Two "false" args mean "no print dialog" and // "non-interactive" (ie, batch-mode printing). null, null, false, printService, null, false); } catch (PrinterException pe) { JOptionPane.showMessageDialog(null, "Error printing " + item.getPage() + "\n" + pe, "Print Error", JOptionPane.WARNING_MESSAGE); } } }; new Thread(printTask).start(); } pages.removeAllElements(); messageArea.setText(n + (n > 1 ? " pages" : " page") + " printed"); }
From source file:GUI.MainWindow.java
/** * This wipes out the UNDO list and clears the interface from previous * selections. It should be called when no vulns are in the tree. *//*from ww w .ja v a2 s . co m*/ private void clearGUI() { undo_manager.setLimit(-1); this.VulnTitleTextField.setText(""); this.VulnDescriptionTextPane.setText(""); this.VulnRecommendationTextPane.setText(""); this.VulnCVSSVectorTextField.setText(""); this.VulnScore.setText(""); this.VulnRiskCategory.setText(""); // TODO clear references. DefaultListModel dlm = (DefaultListModel) this.VulnReferencesList.getModel(); dlm.removeAllElements(); DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel(); // Clear the existing table dtm.setRowCount(0); }
From source file:GUI.MainWindow.java
private void showVulnerability(Vulnerability vulnerability) { // Unmap document listeners IF at all possible removeDocumentListeners();//from ww w.j a va 2s.c om this.VulnTitleTextField.setText(vulnerability.getTitle()); if (vulnerability.isIs_custom_risk() == true) { this.VulnCVSSVectorTextField.setText("NO CVSS VECTOR"); } else { this.VulnCVSSVectorTextField.setText(vulnerability.getCvss_vector_string()); } // Set vuln category this.VulnRiskCategory.setText(vulnerability.getRisk_category()); this.VulnScore.setText("" + vulnerability.getRiskScore()); this.VulnDescriptionTextPane.setText(vulnerability.getDescription()); this.VulnRecommendationTextPane.setText(vulnerability.getRecommendation()); // clear old references DefaultListModel ref_model = (DefaultListModel) this.VulnReferencesList.getModel(); ref_model.removeAllElements(); // add in the new references Enumeration ref_enums = vulnerability.getReferences().elements(); while (ref_enums.hasMoreElements()) { Reference ref = (Reference) ref_enums.nextElement(); ref_model.addElement(ref); } // Now setup undo listeners setupUndoListeners(); setupDocumentListeners(); DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel(); // Clear the existing table dtm.setRowCount(0); // Set affected hosts into table Enumeration enums = vulnerability.getAffectedHosts().elements(); while (enums.hasMoreElements()) { Object obj = enums.nextElement(); if (obj instanceof Host) { Host host = (Host) obj; Vector row = host.getAsVector(); // Gets the first two columns from the host dtm.addRow(row); } } }
From source file:imageuploader.ImgWindow.java
private void generatedImages(String code, File[] files) throws IOException, IllegalStateException, FTPIllegalReplyException, FTPException, FtpException { int ubicacion; File directory = new File(code); ArrayList<File> imageList = new ArrayList(); DefaultListModel mod = (DefaultListModel) jL_Info.getModel(); if (!directory.exists()) { boolean result = directory.mkdir(); if (!result) { JOptionPane.showMessageDialog(rootPane, "Directory -- Error"); } else {//from w ww. java 2s.c om File dir, img; boolean rst; FileChannel source = null; FileChannel dest = null; FtpCredentials.getInstancia().connect(); for (int i = 0; i < files.length; i++) { int val = 1 + i; //Create the Angle directory dir = new File(directory, "Angle" + val); rst = dir.mkdir(); //Copy Images //DefaultListModel mod = (DefaultListModel)jL_Info.getModel(); for (int j = 0; j < mod.getSize(); j++) { img = new File(dir, code + "~" + mod.getElementAt(j).toString() + ".jpg"); rst = img.createNewFile(); imageList.add(img); source = new RandomAccessFile(files[i], "rw").getChannel(); dest = new RandomAccessFile(img, "rw").getChannel(); long position = 0; long count = source.size(); source.transferTo(position, count, dest); if (source != null) { source.close(); } if (dest != null) { dest.close(); } } ubicacion = i + 1; /*Using the private library */ if (jCHBox_MY.isSelected()) { FtpCredentials.getInstancia().getClient().setDir("/Myron/angle" + ubicacion + "Flash"); FtpCredentials.getInstancia().copyImage(imageList); } if (jCHB_CA.isSelected()) { FtpCredentials.getInstancia().getClient().setDir("/canada/angle" + ubicacion + "Flash"); FtpCredentials.getInstancia().copyImage(imageList); } if (jCHB_AZ.isSelected()) { FtpCredentials.getInstancia().getClient().setDir("/australia/angle" + ubicacion + "Flash"); FtpCredentials.getInstancia().copyImage(imageList); } imageList.clear(); } mod.removeAllElements(); jTF_StyleCode.setText(""); //jL_Info.removeAll(); //list.removeAllElements(); JOptionPane.showMessageDialog(rootPane, "Images uploaded"); } } else { JOptionPane.showMessageDialog(rootPane, "There is a folder with the same name in the same location"); } }
From source file:src.gui.ItSIMPLE.java
public void setStateMachineList(Element project) { if (project != null) { stateMachinesList.clear();/*from w ww. j a v a 2 s .c o m*/ DefaultListModel model = (DefaultListModel) stateMachineJList.getModel(); model.removeAllElements(); List<?> stateMachines = project.getChild("diagrams").getChild("stateMachineDiagrams") .getChildren("stateMachineDiagram"); Iterator<?> stateMachinesIter = stateMachines.iterator(); while (stateMachinesIter.hasNext()) { Element stateMachine = (Element) stateMachinesIter.next(); model.addElement(stateMachine.getChildText("name")); stateMachinesList.add((Element) stateMachine.clone()); } } }