List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY
int DIRECTORIES_ONLY
To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.
Click Source Link
From source file:phex.gui.common.FileDialogHandler.java
public static File openSingleDirectoryChooser(Component parent, String title, String approveBtnText, char approveBtnMnemonic, File currentDirectory) { if (SystemUtils.IS_OS_MAC_OSX) { return openMacDirectoryChooser(title, null, null); } else {//from w w w. ja v a 2 s . c o m return openDefaultSingleChooser(parent, initDefaultChooser(title, approveBtnText, approveBtnMnemonic, new DirectoryOnlyFileFilter(), JFileChooser.DIRECTORIES_ONLY, currentDirectory, null, null)); } }
From source file:phex.gui.common.FileDialogHandler.java
public static File[] openMultipleDirectoryChooser(Component parent, String title, String approveBtnText, char approveBtnMnemonic, File currentDirectory, String notifyPopupTitle, String notifyPopupShortMessage) { if (SystemUtils.IS_OS_MAC_OSX) { return new File[] { openMacDirectoryChooser(title, notifyPopupTitle, notifyPopupShortMessage) }; } else {/* w w w . ja v a 2 s.c o m*/ return openDefaultMultiChooser(parent, initDefaultChooser(title, approveBtnText, approveBtnMnemonic, new DirectoryOnlyFileFilter(), JFileChooser.DIRECTORIES_ONLY, currentDirectory, notifyPopupTitle, notifyPopupShortMessage)); } }
From source file:processing.app.Base.java
static public File selectFolder(String prompt, File folder, Component parent) { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(prompt);//from www .j a va 2 s. com if (folder != null) { fc.setSelectedFile(folder); } fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returned = fc.showOpenDialog(parent); if (returned == JFileChooser.APPROVE_OPTION) { return fc.getSelectedFile(); } return null; }
From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java
private void scanDisk(boolean resume) { if (!clientCore.isLocalServer()) { class Action1 extends FileAction { private boolean resume = false; public void setResume(boolean resume) { this.resume = resume; }/*from w w w. j a v a2 s . c o m*/ @Override public void setFileChoosed(String filePath) { AdminRefs.getInstance().index(filePath, resume); TaskList tasks = TaskList.getInstance(); tasks.setVisible(true); tasks.toFront(); } } Action1 action = new Action1(); action.setResume(resume); RemoteFileChooser chooser = new RemoteFileChooser(AdminRefs.getInstance().getRFS(), AdminRefs.getInstance().getDefaultFilePath(), action); chooser.setTitle("Dicoogle Scan Directory"); chooser.setFileSelectionMode(RemoteFileChooser.DIRECTORIES_ONLY); chooser.setVisible(true); // TODO: put showTaskList = false; -- somewhere... } else { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(AdminRefs.getInstance().getDefaultFilePath())); chooser.setDialogTitle("Dicoogle Scan Directory"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { AdminRefs.getInstance().index(chooser.getSelectedFile().toString(), resume); TaskList tasks = TaskList.getInstance(); tasks.setVisible(true); tasks.toFront(); } } }
From source file:ro.nextreports.designer.wizimport.ImportPathSelectionWizardPanel.java
private void init() { setLayout(new BorderLayout()); nameTextField = new JTextField(); nameTextField.setPreferredSize(dim); nameTextField.setEditable(false);// w w w . j a va 2 s. co m propCheck = new JCheckBox(I18NSupport.getString("wizard.import.panel.start.select.title.prop"), true); selButton = new JButton(); selButton.setPreferredSize(buttonDim); selButton.setMaximumSize(buttonDim); selButton.setMinimumSize(buttonDim); selButton.setIcon(ImageUtil.getImageIcon("folder")); selButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(I18NSupport.getString("import.long.desc")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showSaveDialog((JDialog) context.getAttribute(ImportWizard.MAIN_FRAME)); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); if (f != null) { nameTextField.setText(f.getName()); path = f.getAbsolutePath(); } } } }); JPanel dsPanel = new JPanel(new GridBagLayout()); dsPanel.add(new JLabel(I18NSupport.getString("wizard.import.panel.start.select.title.label")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); dsPanel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); dsPanel.add(selButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); dsPanel.add(propCheck, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); dsPanel.add(new JLabel(""), new GridBagConstraints(3, 1, 1, 2, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); add(dsPanel, BorderLayout.CENTER); }
From source file:ropes.MainWindow.java
private void jButton_changePathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_changePathActionPerformed final JFileChooser fc = new JFileChooser(getSelectedPathFromCMB()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); Path p = Paths.get(file.toString()); //if root is changed via the change path botton, then also change to the right media in the combobox if (!p.getRoot().toString().equals(getSelectedPathFromCMB())) { for (int i = 0; i < jComboBox_media.getItemCount(); i++) { if (jComboBox_media.getItemAt(i).toString().contains(p.getRoot().toString())) { jComboBox_media.setSelectedIndex(i); break; }// ww w.j av a 2 s. c o m } } jLabel_path.setText(file.toString()); } }
From source file:se.trixon.almond.dialogs.SimpleDialog.java
public static boolean selectDirectory() { sFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = sFileChooser.showOpenDialog(sParent); if (result == JFileChooser.APPROVE_OPTION) { sPath = sFileChooser.getSelectedFile(); }//from ww w . j av a 2 s . c o m return result == JFileChooser.APPROVE_OPTION; }
From source file:se.trixon.jota.client.ui.editor.module.task.TaskSourceDestPanel.java
private void init() { mTitle = Dict.SOURCE_AND_DEST.toString(); sourcePanel.setMode(JFileChooser.DIRECTORIES_ONLY); destinationPanel.setMode(JFileChooser.DIRECTORIES_ONLY); }
From source file:se.trixon.toolbox.dbtext.DbTextTopComponent.java
private void initDestChooser() { File dest = new File(FileUtils.getTempDirectory(), "dbText"); try {// w w w . j a v a2 s .c om FileUtils.forceMkdir(dest); } catch (IOException ex) { // nvm } if (dest.isDirectory()) { destChooserPanel.setPath(dest.getAbsolutePath()); } destChooserPanel.setMode(JFileChooser.DIRECTORIES_ONLY); destChooserPanel.setButtonListener(this); }
From source file:sms.ViewResults.java
private void itextPrint() { // String searchQuery = "SELECT * FROM `exam` WHERE `yearid` ='" + yearid + "'AND `termid`='"+termid+"'AND `examid`='"+yearid+"'" // + "AND CONCAT(`class`) LIKE '%" + stream + "%'AND YEAR(updated_at)='"+yearchooser.getYear()+"'"; methods nn = new methods(); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { try {//w w w . ja va 2s .c o m Form1Exams n = new Form1Exams(); Document pdfp = new Document(); PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), "report.pdf"))); pdfp.open(); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD)); Paragraph po = new Paragraph(); po.setAlignment(Element.ALIGN_CENTER); po.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD)); Paragraph pd = new Paragraph(); pd.setAlignment(Element.ALIGN_CENTER); pd.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 14, Font.BOLD)); p.add("ITHANGA SECONDARY SCHOOL"); po.add("PO.BOX 238 ITHANGA THIKA"); pd.add(new Date().toString()); pdfp.add(p); pdfp.add(po); pdfp.add(pd); pdfp.add(new Paragraph("\n.................................................................." + ".................................................................................\n")); String[] names = n.findSubjectname(); PdfPTable tbl = new PdfPTable(names.length + 6); tbl.setWidths(new float[] { 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // tbl.setWidthPercentage(100); tbl.setTotalWidth(575); tbl.setLockedWidth(true); PdfPTable tbl1 = new PdfPTable(names.length + 6); tbl1.setWidths(new float[] { 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // tbl.setWidthPercentage(100); tbl1.setTotalWidth(575); tbl1.setLockedWidth(true); PdfPCell cell = new PdfPCell(new Paragraph("RESULTS")); cell.setColspan((names.length + 4) * 2); cell.setBackgroundColor(Color.CYAN); tbl1.addCell(cell); tbl1.addCell("Pos"); tbl1.addCell("id"); tbl1.addCell("Name"); int a; for (a = 0; a < names.length; a++) { String s = names[a]; tbl1.addCell(s.substring(0, Math.min(s.length(), 3))); } tbl1.addCell("Tot"); tbl1.addCell("Ave"); tbl1.addCell("Agg"); pdfp.add(tbl1); try { String[] Subjects = n.findSubjectid(); String[] Subjectsnames = n.findSubjectname(); int subjectCount = Subjects.length; ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText()); for (int i = 0; i < users.size(); i++) { tbl.addCell(String.valueOf(i + 1)); String id = ((ExamDbDataHolder) users.get(i)).getSid(); String nam = nn.getStudentName(id); String name = "Eric"; tbl.addCell(id); tbl.addCell(nam); int c = 2; for (int s = 0; s < Subjects.length; s++) { if (Subjects[s].equals("s1")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMathematics()); // JOptionPane.showMessageDialog(null,((ExamDbDataHolder)users.get(i)).getMathematics()); // String maths = ((ExamDbDataHolder)users.get(i)).getMathematics(); c++; } else if (Subjects[s].equals("s2")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getEnglish()); //row[c] = ((ExamDbDataHolder)users.get(i)).getEnglish(); c++; } else if (Subjects[s].equals("s3")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getKiswahili()); // row[c] = ((ExamDbDataHolder)users.get(i)).getKiswahili(); c++; } else if (Subjects[s].equals("s4")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getPhysics()); // row[c] = ((ExamDbDataHolder)users.get(i)).getPhysics(); c++; } else if (Subjects[s].equals("s5")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getChemistry()); // row[c] = ((ExamDbDataHolder)users.get(i)).getChemistry(); c++; } else if (Subjects[s].equals("s6")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBiology()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBiology(); c++; } else if (Subjects[s].equals("s7")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHistory()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHistory(); c++; } else if (Subjects[s].equals("s8")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getGeography()); // row[c] = ((ExamDbDataHolder)users.get(i)).getGeography(); c++; } else if (Subjects[s].equals("s9")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getCre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getCre(); c++; } else if (Subjects[s].equals("s10")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getIre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getIre(); c++; } else if (Subjects[s].equals("s11")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHre(); c++; } else if (Subjects[s].equals("s12")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getAgriculture()); // row[c] = ((ExamDbDataHolder)users.get(i)).getAgriculture(); c++; } else if (Subjects[s].equals("s13")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHomescience()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHomescience(); c++; } else if (Subjects[s].equals("s14")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getArtdesign()); // row[c] = ((ExamDbDataHolder)users.get(i)).getArtdesign(); c++; } else if (Subjects[s].equals("s15")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getComputer()); // row[c] = ((ExamDbDataHolder)users.get(i)).getComputer(); c++; } else if (Subjects[s].equals("s16")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBuilding()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBuilding(); c++; } else if (Subjects[s].equals("s17")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getWoodwork()); // row[c] = ((ExamDbDataHolder)users.get(i)).getWoodwork(); c++; } else if (Subjects[s].equals("s18")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMetalwork()); // row[c] = ((ExamDbDataHolder)users.get(i)).getMetalwork(); c++; } else if (Subjects[s].equals("s19")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMusic()); // row[c] = ((ExamDbDataHolder)users.get(i)).getMusic(); c++; } else if (Subjects[s].equals("s20")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getFrench()); // row[c] = ((ExamDbDataHolder)users.get(i)).getFrench(); c++; } else if (Subjects[s].equals("s21")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getGerman()); // row[c] = ((ExamDbDataHolder)users.get(i)).getGerman(); c++; } else if (Subjects[s].equals("s22")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getArabic()); // row[c] = ((ExamDbDataHolder)users.get(i)).getArabic(); c++; } else if (Subjects[s].equals("s23")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBusiness()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBusiness(); c++; } } int tt = ((ExamDbDataHolder) users.get(i)).getTotal(); tbl.addCell(String.valueOf(tt)); float g = Float.valueOf(tt) / 11; tbl.addCell(String.format("%.1f", g)); String gr = nn.checkGrade(yearid, String.format("%.1f", g)); tbl.addCell(gr); } pdfp.add(tbl); } catch (Exception j) { j.printStackTrace(); } pdfp.close(); // Image img=new Image.getInstance("j.png"); } catch (DocumentException ex) { Logger.getLogger(ViewResults.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ViewResults.class.getName()).log(Level.SEVERE, null, ex); } } }