List of usage examples for javax.swing DefaultListModel addElement
public void addElement(E element)
From source file:dbseer.gui.actions.ExplainChartAction.java
private void updateExplanations() { JTextField confidenceThresholdTextField = panel.getControlPanel().getConfidenceThresholdTextField(); if (!UserInputValidator.validateNumber(confidenceThresholdTextField.getText().trim(), "Confidence Threshold", true)) { return;/*w w w. j a va2 s . co m*/ } confidenceThreshold = Double.parseDouble(confidenceThresholdTextField.getText().trim()); if (confidenceThreshold < 0 || confidenceThreshold > 100) { JOptionPane.showMessageDialog(null, "Confidence threshold must be between 1 and 100.", "Warning", JOptionPane.WARNING_MESSAGE); return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DefaultListModel explanationListModel = panel.getControlPanel().getExplanationListModel(); explanationListModel.clear(); int rank = 1; for (DBSeerCausalModel explanation : explanations) { if (explanation.getConfidence() > confidenceThreshold) { String output = String.format("%d. %s\n", rank++, explanation.toString()); explanationListModel.addElement(output); } } } }); }
From source file:gtu.zcognos.DimensionUI.java
private void initGUI() { try {//from ww w .ja v a 2 s.co m final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); { GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane()); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { projectId = new JTextField(); } { jLabel1 = new JLabel(); jLabel1.setText("PROJECT_ID"); } { create = new JButton(); create.setText("create"); create.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("create.actionPerformed", evt); } }); } { reportId = new JTextField(); } { jLabel8 = new JLabel(); jLabel8.setText("report id"); } { addDimensionFromDb = new JButton(); addDimensionFromDb.setText("add from db"); addDimensionFromDb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("addFromDb.actionPerformed", evt); } }); } { dataSourceTable = new JTextField(); dataSourceTable.setText("rscdpg0901"); } { jLabel7 = new JLabel(); jLabel7.setText("data source table"); } { addDimension = new JButton(); addDimension.setText("add"); addDimension.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("add.actionPerformed", evt); } }); } { dimensionName = new JTextField(); } { jLabel6 = new JLabel(); jLabel6.setText("dimension chinese name"); } { jLabel5 = new JLabel(); jLabel5.setText("rscdzzzz id index"); } { String[] idx = new String[20]; for (int ii = 0; ii < idx.length; ii++) { idx[ii] = "id" + (ii + 1); } ComboBoxModel rscdzzzzIdIndexModel = new DefaultComboBoxModel(idx); rscdzzzzIdIndex = new JComboBox(); rscdzzzzIdIndex.setModel(rscdzzzzIdIndexModel); } { jLabel3 = new JLabel(); jLabel3.setText("Dimension"); } { jScrollPane1 = new JScrollPane(); { DefaultListModel dimensionListModel = new DefaultListModel(); dimensionList = new JList(); jScrollPane1.setViewportView(dimensionList); dimensionList.setModel(dimensionListModel); dimensionList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(dimensionList).defaultJListKeyPressed(evt); } }); } } { exportDir = new JButton(); exportDir.setText("export dir"); exportDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("exportDir.actionPerformed", evt); } }); } { category = new JTextField(); } { jLabel4 = new JLabel(); jLabel4.setText("category"); } { tableName = new JTextField(); } { jLabel2 = new JLabel(); jLabel2.setText("merge table name"); } thisLayout .setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12) .addGroup(thisLayout.createParallelGroup() .addComponent(jLabel3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addGroup(thisLayout.createSequentialGroup().addGap(19).addGroup(thisLayout .createParallelGroup().addGroup(thisLayout.createSequentialGroup() .addComponent(exportDir, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent( addDimension, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup().addComponent( addDimensionFromDb, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE) .addGroup(thisLayout.createSequentialGroup().addGap( 88) .addComponent(create, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE)))) .addGroup(thisLayout.createSequentialGroup().addGroup(thisLayout .createParallelGroup() .addComponent(jLabel6, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)) .addGap(39) .addGroup(thisLayout.createParallelGroup() .addComponent(dimensionName, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(rscdzzzzIdIndex, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(category, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(reportId, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(tableName, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(dataSourceTable, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE) .addComponent(projectId, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 436, GroupLayout.PREFERRED_SIZE)))) .addContainerGap(11, 11)); thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(projectId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(dataSourceTable, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(tableName, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(reportId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(category, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup() .addComponent(jLabel5, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(rscdzzzzIdIndex, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(dimensionName, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(addDimension, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(exportDir, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(addDimensionFromDb, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 269, GroupLayout.PREFERRED_SIZE) .addGap(12).addComponent(create, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(9, 9)); } this.setSize(513, 632); swingUtil.addAction("exportDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file != null) { baseDir = file; } } }); swingUtil.addAction("addFromDb.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { String project = projectId.getText(); Validate.notEmpty(project, "projectId is null"); Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null"); DefaultListModel model = (DefaultListModel) dimensionList.getModel(); for (Dimension_ ddd : InformixDbConn.queryGetDaminsion(dataSourceTable.getText(), project)) { model.addElement(ddd); } } }); swingUtil.addAction("add.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { // Validate.notEmpty(tableName.getText(), // "tableName is null"); Validate.notEmpty(category.getText(), "category is null"); Validate.notEmpty(dimensionName.getText(), "dimensionName is null"); Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null"); // Validate.notEmpty(reportId.getText(), // "reportId is null"); String report_id = StringUtils.defaultString(reportId.getText(), projectId.getText()); String tName = tableName.getText(); if (StringUtils.isEmpty(tName)) { tName = randomTableName(); } DefaultListModel model = (DefaultListModel) dimensionList.getModel(); model.addElement(new Dimension_(dataSourceTable.getText(), tName, category.getText(), (String) rscdzzzzIdIndex.getSelectedItem(), dimensionName.getText(), report_id)); } }); swingUtil.addAction("create.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { String project = projectId.getText(); Validate.notEmpty(project, "projectId is null"); Validate.notNull(baseDir, "exportDir is null"); File destDir = new File(baseDir, project); Map<String, Object> map = new HashMap<String, Object>(); List<Map<String, String>> llist = new ArrayList<Map<String, String>>(); int idx = 2; int categoryId = 1; DefaultListModel model = (DefaultListModel) dimensionList.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { Dimension_ di = (Dimension_) enu.nextElement(); Map mmm = new HashMap(); mmm.put("rscdpg0901", di.dataSourceTable);// mmm.put("rscdpg0901a", di.tableName);// mmm.put("rscdpg0901a_category", di.category);// mmm.put("rscdpg0901a_report_id", di.reportId);// mmm.put("rscdzzzz_id", di.idIndex);// mmm.put("rscdpg0901a_dname", di.dimensionName);// llist.add(mmm); } map.put("PROJECT_ID", project); map.put("RSCDPG0901", llist); map.put("rscdpg0901", dataSourceTable.getText()); ConfigCopy.getInstance().applyBaseDir(baseDir).applyProjectId(project).execute(); Dimension.getInstance()// .applyDestDir(destDir.getAbsolutePath())// .applyParameter(map)// .execute(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog(project + " create completed!!\r\n dir : " // + destDir.getAbsolutePath(), project); Desktop.getDesktop().open(destDir); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:gtu._work.ui.TextScanUI.java
private void jTextField2filterAgain(boolean resetGroupListModel) { try {//from w ww . j a v a2 s .co m Pattern pat = Pattern.compile(contentFilter.getText()); Matcher matcher = null; DefaultListModel listModel = new DefaultListModel(); Set<String> set = new HashSet<String>(); boolean setGroupListModel = false; for (String str : contentSet) { matcher = pat.matcher(replaceNewLineChar(str)); if (contextFilter.getSelectedItem().equals("All")) { if (matcher.find()) { listModel.addElement(str); } } else if (contextFilter.getSelectedItem().equals("Match")) { List<String> mlist = new ArrayList<String>(); while (matcher.find()) { for (int ii = 0; ii <= matcher.groupCount(); ii++) { if (!resetGroupListModel) { DefaultListModel model = (DefaultListModel) groupList.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { Integer gnum = (Integer) enu.nextElement(); if (gnum == ii) { mlist.add(matcher.group(ii)); } } } else { mlist.add(matcher.group(ii)); } } if (resetGroupListModel && !setGroupListModel) { resetGroupList(matcher.groupCount()); } } set.add(mlist.toString()); } } if (contextFilter.getSelectedItem().equals("Match")) { List<String> ssset = new ArrayList<String>(set); Collections.sort(ssset); for (String str : ssset) { listModel.addElement(str); } } matchList.setModel(listModel); matchLabel.setText(String.valueOf(matchList.getModel().getSize())); } catch (Exception ex) { } sysinfo(); }
From source file:au.org.ala.delta.intkey.ui.TaxonInformationDialog.java
private void displayTaxon(int index) { _selectedIndex = index;/*from ww w .j a v a 2s .c om*/ Item selectedTaxon = _taxa.get(_selectedIndex); _comboBox.setSelectedIndex(_selectedIndex); // Update other list // _fileNames = new ArrayList<String>(); _cmds = new ArrayList<InformationDialogCommand>(); DefaultListModel otherListModel = new DefaultListModel(); for (Pair<String, String> fileNameTitlePair : selectedTaxon.getLinkFiles()) { String fileName = fileNameTitlePair.getFirst(); String fileTitle = fileNameTitlePair.getSecond(); if (fileTitle != null) { otherListModel.addElement(fileTitle); } else { otherListModel.addElement(fileName); } _cmds.add(new OpenLinkFileCommand(fileName, fileTitle)); } for (Pair<String, String> subjectDirectiveCommandPair : _definedDirectiveCommands) { String subject = subjectDirectiveCommandPair.getFirst(); String directiveCommand = subjectDirectiveCommandPair.getSecond(); otherListModel.addElement(subject); _cmds.add(new RunDirectiveCommand(directiveCommand, subject)); } // If no link files or directive commands have been defined, display an entry labelled "Full description" that will // run the describe command for the taxon if (otherListModel.isEmpty()) { otherListModel.addElement(fullDescriptionCaption); _cmds.add(new RunDirectiveCommand("DESCRIBE (?S) all", fullDescriptionCaption)); } _listOther.setModel(otherListModel); // Update illustrations list _images = new ArrayList<Image>(); DefaultListModel illustrationsListModel = new DefaultListModel(); for (Image img : selectedTaxon.getImages()) { _images.add(img); illustrationsListModel.addElement(img.getSubjectTextOrFileName()); } if (_images.isEmpty()) { illustrationsListModel.addElement(noImagesCaption); } _listIllustrations.setModel(illustrationsListModel); // update button state _btnStart.setEnabled(index > 0); _btnPrevious.setEnabled(index > 0); _btnForward.setEnabled(index < _taxa.size() - 1); _btnEnd.setEnabled(index < _taxa.size() - 1); }
From source file:gtu._work.ui.PropertyEditUI.java
void loadCurrentFile(File file) { if (file == null) { file = PropertiesUtil.getJarCurrentPath(getClass()); JCommonUtil._jOptionPane_showMessageDialog_info("load current !"); }/*from w w w . j ava2s . c om*/ DefaultListModel model = new DefaultListModel(); backupFileList.clear(); for (File f : file.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".properties"); } })) { File_ ff = new File_(); ff.file = f; model.addElement(ff); backupFileList.add(f); } fileList.setModel(model); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
/** * Checks if the movie list should be retrived from IMDB or the local movie Database *//*w w w .j a va 2 s. co m*/ void executeSearchMultipleMovies() { if (addInfoToExistingMovie) { executeEditExistingMovie(getSearchField().getText()); } else { final DefaultListModel listModel = new DefaultListModel(); int setSelectedIndex = 0; try { IMDb imdb = IMDbLib.newIMDb(MovieManager.getConfig().getHttpSettings()); ArrayList<ModelIMDbSearchHit> hits = imdb.getSimpleMatches(getSearchField().getText()); // Error if (hits == null) { HTTPResult res = imdb.getLastHTTPResult(); if (res.getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) { listModel.addElement(new ModelIMDbSearchHit("Connection timed out...")); //$NON-NLS-1$ } } for (int i = 0; i < hits.size(); i++) { listModel.addElement(hits.get(i)); } } catch (Exception e) { executeErrorMessage(e); e.printStackTrace(); dispose(); } if (listModel.getSize() == 0) listModel.addElement( new ModelIMDbSearchHit(Localizer.get("DialogIMDB.list-element.messsage.no-hits-found"))); //$NON-NLS-1$ getMoviesList().setModel(listModel); getMoviesList().setSelectedIndex(setSelectedIndex); // This delays the execution of requestFocusInWindow. // The reason is to avoid that the actionlistener for the choose button // is invoked, which is would be if invokelater isn't used. (Experienced on Ubuntu). SwingUtilities.invokeLater(new Runnable() { public void run() { getMoviesList().requestFocusInWindow(); } }); } }
From source file:io.neocdtv.simpleplayer.ui.PlaylistTransferHandler.java
@Override public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; }/* www . ja va2s.co m*/ JList list = (JList) info.getComponent(); DefaultListModel<PlaylistEntry> listModel = (DefaultListModel) list.getModel(); JList.DropLocation dropLocation = (JList.DropLocation) info.getDropLocation(); // Get the string that is being dropped. Transferable transferable = info.getTransferable(); List<File> data; try { data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor); for (File file : data) { if (file.isDirectory()) { final boolean recursive = true; final String[] fileExtensionFilter = null; final List<File> listFiles = Arrays.asList(FileUtils.convertFileCollectionToFileArray( FileUtils.listFiles(file, fileExtensionFilter, recursive))); for (File o : listFiles) { listModel.addElement(buildEntry(o)); } } else { listModel.addElement(buildEntry(file)); } } } catch (UnsupportedFlavorException | IOException ex) { LOGGER.log(Level.SEVERE, null, ex); return false; } return true; }
From source file:gtu._work.etc._3DSMovieRenamer.java
void loadDirVids() { if (!loadDir.isDirectory()) { return;/* www. j av a 2 s. c om*/ } DefaultListModel vidListModel = new DefaultListModel(); for (File f : loadDir.listFiles(new FileFilter() { public boolean accept(File pathname) { if (pathname.getName().toLowerCase().endsWith(".avi")) { return true; } return false; } })) { vidListModel.addElement(f); } if (vidListModel.size() == 0) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog("no avi file", getTitle()); } vidList.setModel(vidListModel); }
From source file:gtu._work.ui.JarFinderUI.java
private void initGUI() { try {/*from w ww.j a v a2 s .c o m*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setTitle("Jar finder"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("src dir", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(406, 255)); { DefaultListModel jList1Model = new DefaultListModel(); try { prop.load(new FileInputStream(CONFIG_FILE)); for (Enumeration<?> enu = prop.keys(); enu.hasMoreElements();) { File val = new File((String) enu.nextElement()); jList1Model.addElement(val); } } catch (Exception ex) { JCommonUtil.handleException("??:" + CONFIG_FILE, ex); } jarFileDirs = new JList(); jScrollPane1.setViewportView(jarFileDirs); jarFileDirs.setModel(jList1Model); jarFileDirs.setPreferredSize(new java.awt.Dimension(406, 221)); jarFileDirs.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (!JListUtil.newInstance(jarFileDirs).isCorrectMouseClick(evt)) { return; } File file = (File) JListUtil.getLeadSelectionObject(jarFileDirs); try { Desktop.getDesktop().open(file); } catch (IOException e) { JCommonUtil.handleException(e); } } }); jarFileDirs.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(jarFileDirs).defaultJListKeyPressed(evt); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("result", null, jPanel2, null); { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(406, 26)); { searchText = new JTextField(); jPanel3.add(searchText, BorderLayout.WEST); searchText.setPreferredSize(new java.awt.Dimension(326, 26)); } { search = new JButton(); jPanel3.add(search, BorderLayout.CENTER); search.setText("search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } } { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(406, 231)); { ListModel searchResultModel = new DefaultListModel(); searchResult = new JList(); jScrollPane2.setViewportView(searchResult); searchResult.setModel(searchResultModel); searchResult.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jList1MouseClicked(evt); } }); searchResult.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(searchResult).defaultJListKeyPressed(evt); } }); } } { resetFinder = new JButton(); jPanel2.add(resetFinder, BorderLayout.SOUTH); resetFinder.setText("reset finder"); resetFinder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jarfinder.clear(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("copy to", null, jPanel4, null); { copyToBtn = new JButton(); jPanel4.add(copyToBtn, BorderLayout.NORTH); copyToBtn.setText("copy to"); copyToBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } else { copyToFile = file; } } }); } { jScrollPane3 = new JScrollPane(); jPanel4.add(jScrollPane3, BorderLayout.CENTER); { DefaultListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane3.setViewportView(copyToList); copyToList.setModel(copyToListModel); { panel = new JPanel(); jTabbedPane1.addTab("config", null, panel, null); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { lblNewLabel = new JLabel("JD Gui"); panel.add(lblNewLabel, "2, 2, right, default"); } { jdGuiText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(jdGuiText, false); panel.add(jdGuiText, "4, 2, fill, default"); jdGuiText.setColumns(10); } { saveConfigBtn = new JButton(""); saveConfigBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { configBean.reflectSetConfig(JarFinderUI.this); configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); panel.add(saveConfigBtn, "2, 24"); } } copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // copyToFile if (evt.getClickCount() != 2) { return; } if (copyToList.getLeadSelectionIndex() == -1) { return; } if (copyToFile == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } DefaultListModel model = (DefaultListModel) copyToList.getModel(); Object val = model.getElementAt(copyToList.getLeadSelectionIndex()); StringBuilder sb = new StringBuilder(); sb.append("?\n"); sb.append("file : " + val + "\n"); sb.append("copy to dir : " + copyToFile + "\n"); ComfirmDialogResult result = JOptionPaneUtil.newInstance().confirmButtonYesNo() .showConfirmDialog(sb, getTitle()); File srcFile = new File((String) val); if (!srcFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog(srcFile + " not found!", getTitle()); return; } File copyDestFile = new File(copyToFile, srcFile.getName()); switch (result) { case YES_OK_OPTION: System.out.println("yes.."); try { FileUtil.copyFile(srcFile, copyDestFile); } catch (IOException e) { JCommonUtil.handleException(e.toString(), e); } if (srcFile != null && // copyDestFile != null && // srcFile.length() == copyDestFile.length()) { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("success!\n" + copyDestFile, getTitle()); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("failed!\n" + copyDestFile, getTitle()); } break; case NO_OPTION: System.out.println("no.."); break; } } }); } } } jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { copyToList.setModel(searchResult.getModel()); } }); } this.setSize(562, 407); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (CONFIG_FILE.exists()) { DefaultListModel model = (DefaultListModel) jarFileDirs.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { Object obj = enu.nextElement(); prop.setProperty(((File) obj).getAbsolutePath(), ""); } try { prop.store(new FileOutputStream(CONFIG_FILE), "testtesttesttest"); } catch (Exception e) { JCommonUtil.handleException("", e); } } setVisible(false); dispose(); } }); { configBean.reflectInit(this); } } catch (Exception e) { e.printStackTrace(); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);// w w w. j a v a 2s . co m g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxFilterPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < jConquersTable.getColumnCount(); i++) { TableColumnExt col = jConquersTable.getColumnExt(i); if (col.isVisible() && !col.getTitle().equals("Entfernung") && !col.getTitle().equals("Dorfpunkte")) { model.addElement(col.getTitle()); } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxFilterPane.setVisible(true); } }