List of usage examples for javax.swing JFileChooser setApproveButtonText
@BeanProperty(preferred = true, description = "The text that goes in the ApproveButton.") public void setApproveButtonText(String approveButtonText)
ApproveButton
in the FileChooserUI
. From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java
private void loadReport() { final JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Choose scanner report directory"); File lastReport = getLastUsedReport(); if (lastReport != null) { fc.setCurrentDirectory(lastReport); }//from w w w .j a va 2s .c o m fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setFileHidingEnabled(false); fc.setApproveButtonText("Open scanner report"); int returnVal = fc.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try { setLastUsedReport(file); loadReport(file); } catch (Exception e) { JOptionPane.showMessageDialog(frame, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); exit(); } } else { exit(); } }
From source file:phex.gui.common.FileDialogHandler.java
private static JFileChooser initDefaultChooser(String title, String approveBtnText, char approveBtnMnemonic, FileFilter filter, int mode, File currentDirectory, String notifyPopupTitle, String notifyPopupShortMessage) { JFileChooser chooser = new JFileChooser(); if (notifyPopupTitle != null || notifyPopupShortMessage != null) { displayNotificationPopup(chooser, notifyPopupTitle, notifyPopupShortMessage); }/*from w w w . ja v a2s. c o m*/ if (currentDirectory != null) { chooser.setCurrentDirectory(currentDirectory); } if (filter != null) { chooser.setFileFilter(filter); } chooser.setFileSelectionMode(mode); chooser.setDialogTitle(title); chooser.setApproveButtonText(approveBtnText); chooser.setApproveButtonMnemonic(approveBtnMnemonic); return chooser; }
From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java
public static void addFileMenu(final JFrame frame, JMenuBar menuBar) { // Create a menu JMenu menu = new JMenu("File"); menuBar.add(menu);/* w w w.j av a2 s .com*/ // Create a file open iten JMenuItem openFileItem = new JMenuItem("Open files..."); openFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setApproveButtonText("Convert to MITAB25"); // Enable multiple selections chooser.setMultiSelectionEnabled(true); // Show the dialog; wait until dialog is closed chooser.showOpenDialog(frame); // Retrieve the selected files. This method returns empty // if multiple-selection mode is not enabled. File[] files = chooser.getSelectedFiles(); if (files != null && files.length > 0) { FilesProcessor processor = new FilesProcessor(); processor.process(frame, files, expansionStrategy, postProcessorStrategy, aggregateSelectedFiles); } } }); menu.add(openFileItem); // Create an exit final JMenuItem mergeItem = new JCheckBoxMenuItem("Aggregate all selected files", aggregateSelectedFiles); mergeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // If selected, all files dropped or selected at once are aggregated into a single MITAB file aggregateSelectedFiles = mergeItem.isSelected(); log.debug("Aggregate is " + aggregateSelectedFiles); } }); menu.add(mergeItem); // Create an exit JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu.add(exitItem); }
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 {/*from w w w. j av a2 s . co 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); } } }
From source file:us.daveread.basicquery.BasicQuery.java
/** * Exports the results to a file// ww w. ja v a2s .c o m * * @param model * The model for the current results * @param fileType * The export file type */ private void chooseFileForSave(TableModel model, int fileType) { final JFileChooser chooser = new JFileChooser(); int returnVal; chooser.setDialogTitle(Resources.getString("dlgSaveDataTitle")); chooser.setApproveButtonText(Resources.getString("dlgSaveDataButton")); chooser.setApproveButtonMnemonic(Resources.getChar("dlgSaveDataButtonMnemonic")); if (latestFileDirectory != null) { if (latestFileDirectory.isDirectory()) { chooser.setCurrentDirectory(latestFileDirectory); } else if (latestFileDirectory.getParentFile().isDirectory()) { chooser.setCurrentDirectory(latestFileDirectory.getParentFile()); } } returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { latestFileDirectory = chooser.getSelectedFile().getParentFile(); switch (fileType) { case FILE_EXPORT_CSV: saveResultAsCSV(model, chooser.getSelectedFile().getAbsoluteFile()); break; case FILE_EXPORT_TRIPLES: saveResultsAsTriples(model, chooser.getSelectedFile().getAbsoluteFile()); break; default: throw new IllegalArgumentException("Unknown file type mode for export: " + fileType); } } }