List of usage examples for javax.swing JFileChooser FILES_ONLY
int FILES_ONLY
To view the source code for javax.swing JFileChooser FILES_ONLY.
Click Source Link
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
private void importMarketLogs() { File inputDir = null;/* w w w . j a va 2 s. c om*/ if (appConfigProvider.getAppConfig().hasLastMarketLogImportDirectory()) { inputDir = appConfigProvider.getAppConfig().getLastMarketLogImportDirectory(); if (!inputDir.exists() || !inputDir.isDirectory()) { inputDir = null; } } final JFileChooser chooser = inputDir != null ? new JFileChooser(inputDir) : new JFileChooser(); chooser.setFileHidingEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setMultiSelectionEnabled(true); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File[] files = chooser.getSelectedFiles(); if (!ArrayUtils.isEmpty(files)) { appConfigProvider.getAppConfig().setLastMarketLogImportDirectory(files[0].getParentFile()); try { appConfigProvider.save(); } catch (IOException e) { log.error("importMarketLogs(): Failed to save configuration", e); } importMarketLogs(files); } } }
From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java
private void initFilemenu() { final EditorMainWindow parentWinRef = this; exitMenuItem.addActionListener(new ActionListener() { @Override//from w ww. j a v a 2 s .c om public void actionPerformed(ActionEvent e) { parentWinRef.dispose(); } }); openOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final JFileChooser fc = new JFileChooser(); fc.setDialogType(JFileChooser.OPEN_DIALOG); File lastOpenedFrom = guiProps.getLastOpenedFromFile(); // Set current directory fc.setCurrentDirectory(lastOpenedFrom); FileFilter ff = new OcilOrOvalFilesFilter("OVAL"); fc.setFileFilter(ff); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int ret = fc.showOpenDialog(EditorMainWindow.getInstance()); if (ret == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); File parent = f.getAbsoluteFile().getParentFile(); guiProps.setLastOpenedFrom(parent.getAbsolutePath()); guiProps.save(); openFile(f, SCAPDocumentClassEnum.OVAL); } } }); saveMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // get the currently open window JInternalFrame selectedWin = desktopPane.getSelectedFrame(); if (selectedWin != null) { SCAPDocument scapDoc = null; Document dom = null; String filename = null; if (selectedWin instanceof OvalEditorForm) { OvalEditorForm oef = (OvalEditorForm) selectedWin; scapDoc = oef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else if (selectedWin instanceof CPEDictionaryEditorForm) { CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin; scapDoc = cef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } if (dom != null) { // since this is a save operation, not save as, we won't // prompt the user for where to store the file try { scapDoc.save(); ((EditorForm) selectedWin).setDirty(false); } catch (Exception e) { String message = "An error occured trying to save to file " + filename + ": " + e.getMessage(); EditorUtil.showMessageDialog(parentWinRef, message, EditorMessages.SAVE_ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE); } } } } }); saveAsMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // get the currently open window JInternalFrame selectedWin = desktopPane.getSelectedFrame(); if (selectedWin != null) { SCAPDocument scapDoc = null; Document dom = null; String filename = null; String windowTitle = null; if (selectedWin instanceof OvalEditorForm) { windowTitle = OvalEditorForm.WINDOW_TITLE_BASE; OvalEditorForm oef = (OvalEditorForm) selectedWin; scapDoc = oef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else if (selectedWin instanceof CPEDictionaryEditorForm) { windowTitle = CPEDictionaryEditorForm.WINDOW_TITLE_BASE; CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin; scapDoc = cef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else { return; } if (dom != null) { String newFilename = null; SCAPDocumentTypeEnum docType = scapDoc.getDocumentType(); FileSaveAsWizard saveAsWiz = new FileSaveAsWizard(EditorMainWindow.getInstance(), true, docType); //saveAsWiz.pack(); saveAsWiz.setLocationRelativeTo(EditorMainWindow.getInstance()); saveAsWiz.setVisible(true); if (saveAsWiz.wasCancelled()) { return; } newFilename = saveAsWiz.getFilename(); try { scapDoc.setFilename(newFilename); scapDoc.saveAs(newFilename); EditorUtil.markActiveWindowDirty(EditorMainWindow.getInstance(), false); ((EditorForm) selectedWin).refreshRootNode(); } catch (Exception e) { LOG.error(e.getMessage(), e); EditorUtil.showMessageDialog(parentWinRef, "An error occured trying to save to file " + newFilename + ": " + e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); return; } SCAPContentManager scm = SCAPContentManager.getInstance(); if (scm != null) { scm.removeDocument(filename); scm.addDocument(newFilename, scapDoc); selectedWin.setTitle(windowTitle + (new File(newFilename)).getAbsolutePath()); } else { LOG.error("SCM instance is null here!"); } } } } }); newXCCDFFromOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { //generateXccdfFromOvalOrOcil("OVAL"); final JFileChooser fc = new JFileChooser(); fc.setDialogType(JFileChooser.OPEN_DIALOG); File lastOpenedFrom = guiProps.getLastOpenedFromFile(); // Set current directory fc.setCurrentDirectory(lastOpenedFrom); FileFilter ff = new OcilOrOvalFilesFilter("OVAL"); fc.setFileFilter(ff); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int ret = fc.showOpenDialog(EditorMainWindow.getInstance()); if (ret == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); File parent = f.getAbsoluteFile().getParentFile(); guiProps.setLastOpenedFrom(parent.getAbsolutePath()); guiProps.save(); try { InputStream is = this.getClass().getClassLoader().getResourceAsStream("oval-to-xccdf.xsl"); File xsltfile = new File("oval-to-xccdf.xsl"); OutputStream outputStream = new FileOutputStream(xsltfile); IOUtils.copy(is, outputStream); outputStream.close(); OvalToXCCDF1.ovalToXccdf(f, xsltfile); xsltfile.delete(); String reverseDNS = JOptionPane.showInputDialog("reverse_DNS:"); if (reverseDNS == null || reverseDNS.length() == 0) { JOptionPane.showMessageDialog(null, "Enter the reverse_DNS", "alert", JOptionPane.ERROR_MESSAGE); } else { JFileChooser fc1 = new JFileChooser(); fc1.setCurrentDirectory(f); int ret1 = fc1.showSaveDialog(EditorMainWindow.getInstance()); if (ret1 == JFileChooser.APPROVE_OPTION) { File savefile = fc1.getSelectedFile(); is = this.getClass().getClassLoader().getResourceAsStream("xccdf_1.1_to_1.2.xsl"); xsltfile = new File("oval-to-xccdf.xsl"); outputStream = new FileOutputStream(xsltfile); IOUtils.copy(is, outputStream); outputStream.close(); File temp = new File("temp.xml"); XCCDF1to2.xccdf12(savefile, reverseDNS, xsltfile, temp); JOptionPane.showMessageDialog(null, "XCCDF File Created: " + savefile.getAbsolutePath(), "XCCDF Created", JOptionPane.PLAIN_MESSAGE); xsltfile.delete(); temp.delete(); temp = null; } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } // openFile(f, SCAPDocumentClassEnum.OVAL); } } }); newOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { CreateOvalWizard wiz = new CreateOvalWizard(true); wiz.setName("create_oval_wizard"); wiz.pack(); wiz.setVisible(true); if (!wiz.wasCancelled()) { // User has been through the wizard to select // 1. an Oval schema version (eg, OVAL55) // 2. one or more platforms (eg, "windows", "solaris", etc) // 3. a file name for the new Oval file // Now we are ready to actually create the file String createdFilename = createNewOvalDocument(wiz); if (createdFilename == null) { LOG.error("newOvalMenuItem.actionlistener: Created filename was null!"); return; } File f = new File(createdFilename); guiProps.setLastOpenedFromFile(f.getParentFile()); guiProps.save(); SCAPContentManager scm = SCAPContentManager.getInstance(); if (scm != null) { OvalDefinitionsDocument dd = (OvalDefinitionsDocument) scm.getDocument(f.getAbsolutePath()); openFile(dd); } } wiz.setVisible(false); wiz.dispose(); } }); /* wizModeMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WizardModeWindow wizModeWin = new WizardModeWindow(); EditorMainWindow emw = EditorMainWindow.getInstance(); JDesktopPane emwDesktopPane = emw.getDesktopPane(); wizModeWin.setTitle("Wizard Mode"); wizModeWin.pack(); wizModeWin.addInternalFrameListener(new WeakInternalFrameListener(EditorMainWindow.getInstance())); Dimension dpDim = emwDesktopPane.getSize(); int x = (dpDim.width - wizModeWin.getWidth()) / 2; int y = (dpDim.height - wizModeWin.getHeight()) / 2; wizModeWin.setLocation(x, y); emwDesktopPane.add(wizModeWin); wizModeWin.setVisible(true); setWizMode(true); } });*/ ugMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); InputStream resource = this.getClass().getResourceAsStream("/User_Guide.pdf"); try { File userGuideFile = File.createTempFile("UserGuide", ".pdf"); userGuideFile.deleteOnExit(); OutputStream out = new FileOutputStream(userGuideFile); try { // copy contents from resource to out IOUtils.copy(resource, out); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Couldn't copy between streams."); } finally { out.close(); } desktop.open(userGuideFile); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Could not call Open on desktop object."); } finally { try { if (resource != null) { resource.close(); } } catch (IOException ex) { LOG.error("Error displaying user guide", ex); JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide."); } } } else { JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide."); } } }); }
From source file:cn.labthink.ReadAccess060.java
private void jButton_exportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_exportActionPerformed JFileChooser jfc = new JFileChooser(); ExtensionFileFilter filter;// w ww. j a va2s.c o m if (jTable1.getSelectedRowCount() == 1) { // filter filter = new ExtensionFileFilter("xls", false, true); filter.setDescription("Save Export File"); jfc.setDialogTitle("Create the Export Excel file"); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); } else if (jTable1.getSelectedRowCount() > 1) { // filter filter = new ExtensionFileFilter("", false, true); filter.setDescription("Save Export Files"); jfc.setDialogTitle("Choose the Export Directory"); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } else { //? jLabel_info.setText("<html><font color='red'>No Record Selected</font></html>"); return; } //? FileSystemView fsv = FileSystemView.getFileSystemView(); //? jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setMultiSelectionEnabled(false); jfc.setDialogType(JFileChooser.SAVE_DIALOG); jfc.setFileFilter(filter); int result = jfc.showSaveDialog(this); // ""? if (result == JFileChooser.APPROVE_OPTION) { if (jTable1.getSelectedRowCount() == 1) { // String filesrc = jfc.getSelectedFile().getAbsolutePath(); if (!filesrc.toLowerCase().endsWith(".xls")) { filesrc = jfc.getSelectedFile().getAbsolutePath() + ".xls"; } outputfile = new File(filesrc); jLabel_info.setText("Exported File:" + outputfile.getAbsolutePath()); } else if (jTable1.getSelectedRowCount() > 1) { // outputfile = jfc.getSelectedFile().isDirectory() ? jfc.getSelectedFile() : jfc.getSelectedFile().getParentFile(); if (outputfile == null) { outputfile = fsv.getHomeDirectory(); } jLabel_info.setText("Exported to path:" + outputfile.getAbsolutePath()); } else { //? return; } } else { return; } if (inputfile == null) { return; } int[] rows = jTable1.getSelectedRows(); if (rows.length == 1) { //? book = null; ExportOneRecord(rows[0]); } else { File path = outputfile; for (int rowindex = 0; rowindex < rows.length; rowindex++) { int k = rows[rowindex]; book = null; outputfile = new File(path.getAbsolutePath() + "/" + jTable1.getValueAt(k, 0) + ".xls"); ExportOneRecord(k); } } // int k = jTable1.getSelectedRow(); // ExportOneRecord(k); }
From source file:dylemator.UserResultList.java
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed if (this.filenameCombo.getSelectedIndex() == 0) return;/* ww w .j a v a2 s. c om*/ String sheetName = (String) this.filenameCombo.getSelectedItem(); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(sheetName); Row headerRow = sheet.createRow(0); String[] headers = exportData.get(0); int numOfColumns = headers.length; for (int i = 0, j = 0; i < numOfColumns; i++) { if (i == 1 || i == 2 || i == 3) // opuszcz. date, imie, nazwisko continue; Cell cell = headerRow.createCell(j++); cell.setCellValue(headers[i]); } int rowCount = exportData.size(); for (int rownum = 1; rownum < rowCount; rownum++) { Row row = sheet.createRow(rownum); String[] values = exportData.get(rownum); for (int i = 0, j = 0; i < numOfColumns; i++) { if (i == 1 || i == 2 || i == 3) // opuszcz. date, imie, nazwisko continue; Cell cell = row.createCell(j++); cell.setCellValue(values[i]); } } String defaultFilename = "Export.xlsx"; JFileChooser f = new JFileChooser(System.getProperty("user.dir")); f.setSelectedFile(new File(defaultFilename)); f.setDialogTitle("Wybierz nazw dla pliku eksportu"); f.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter ff = new FileFilter() { @Override public boolean accept(File file) { if (file.getName().endsWith(".xlsx")) return true; return false; } @Override public String getDescription() { return ""; } }; f.setFileFilter(ff); File file = null; int save = f.showSaveDialog(this); if (save == JFileChooser.APPROVE_OPTION) file = f.getSelectedFile(); else return; FileOutputStream out; try { out = new FileOutputStream(file); wb.write(out); out.close(); } catch (FileNotFoundException ex) { Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ch.fork.AdHocRailway.ui.locomotives.configuration.LocomotiveConfig.java
public void chooseLocoImage() { File previousLocoDir = ctx.getPreviousLocoDir(); if (previousLocoDir == null) { previousLocoDir = new File("locoimages"); }/* w w w .ja v a2s. c o m*/ final JFileChooser chooser = new JFileChooser(previousLocoDir); final ImagePreviewPanel preview = new ImagePreviewPanel(); chooser.setAccessory(preview); chooser.addPropertyChangeListener(preview); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Image Files"; } @Override public boolean accept(final File f) { if (f.isDirectory()) { return true; } if (StringUtils.endsWithAny(f.getName().toLowerCase(), ".png", ".gif", ".bmp", ".jpg")) { return true; } return false; } }); final int ret = chooser.showOpenDialog(LocomotiveConfig.this); if (ret == JFileChooser.APPROVE_OPTION) { File selectedFile = chooser.getSelectedFile(); ctx.setPreviousLocoDir(selectedFile.getParentFile()); presentationModel.getBean().setImage(selectedFile.getName()); final String image = presentationModel.getBean().getImage(); presentationModel.getBean() .setImageBase64(LocomotiveImageHelper.getImageBase64(presentationModel.getBean())); if (image != null && !image.isEmpty()) { imageLabel.setIcon(LocomotiveImageHelper.getLocomotiveIcon(presentationModel.getBean())); pack(); } else { imageLabel.setIcon(null); pack(); } } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveReference(boolean mustSupportEvaluation, boolean includeEvaluation) throws FileNotFoundException { Set<ReferenceFormat> formats = mustSupportEvaluation ? ReferenceFormats.REFERENCE_FORMATS.evaluationIncludingFormats : ReferenceFormats.REFERENCE_FORMATS.formats; formats.retainAll(ReferenceFormats.REFERENCE_FORMATS.writeableFormats); ReferenceFormat format = formatChooser(formats); if (format == null) { return;/*from ww w .j a v a 2 s. co m*/ } JFileChooser chooser = new JFileChooser("Save reference. Please choose a file."); chooser.setCurrentDirectory(frame.defaultDirectory); chooser.setFileSelectionMode( format.readsDirectory() ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY); if (format.getFileExtension() != null) { chooser.addChoosableFileFilter( new FilesystemFilter(format.getFileExtension(), format.getDescription())); } else { chooser.setAcceptAllFileFilterUsed(true); } int returnVal = chooser.showSaveDialog(frame); if (returnVal != JFileChooser.APPROVE_OPTION) return; System.out.print("Saving..."); format.writeReference(frame.reference, chooser.getSelectedFile(), includeEvaluation); //frame.loadPositiveNegativeNT(chooser.getSelectedFile()); System.out.println("saving finished."); }
From source file:com.akman.excel.view.frmExportExcel.java
private void btnAddFileActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnAddFileActionPerformed {//GEN-HEADEREND:event_btnAddFileActionPerformed JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel files", "xlsx", "xlsm", "xlt", "xlsb", "xltx", "xltm", "xls", "xlt", "xls"); chooser.setFileFilter(filter);/*from w ww . j a va2 s . co m*/ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setDialogTitle("Select The Image"); chooser.setMultiSelectionEnabled(false); int res = chooser.showOpenDialog(null); if (res == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); // checking file extension. it must be excel file. if (file.equals(filter)) { JOptionPane.showMessageDialog(null, "Wrong File selected", "ERROR", JOptionPane.ERROR_MESSAGE); return; } fileName = file.getAbsolutePath(); txtPath.setText(fileName); } }
From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java
public JButton initButtonLoad() { JButton buttonLoad = new JButton("Load"); buttonLoad.addActionListener(new ActionListener() { @Override/* ww w . j av a 2 s . com*/ public void actionPerformed(ActionEvent e) { fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileFilter( new ExtensionFileFilterSwing(new String[] { "arff", "vec", "rp", "rh", "ssd", "tfxidf" })); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } // TODO: remove fileChooser.setSelectedFile( new File("/data/music/ISMIRgenre/vec/mp3_vec_conv_from_wav/ISMIRgenre.rp")); int returnVal = fileChooser.showDialog(SimilarityRetrievalGUI.this, "Open input data"); if (returnVal == JFileChooser.APPROVE_OPTION) { // FIXME: remove dependency on AbstractSOMLibSparseInputData AbstractSOMLibSparseInputData data = (AbstractSOMLibSparseInputData) InputDataFactory .open(fileChooser.getSelectedFile().getAbsolutePath()); String[] newLabels = data.getLabels(); Arrays.sort(newLabels); if (inputData.size() > 0) { // check if the input data files match; if not, don't add this new one String[] existingLabels = inputData.get(0).getLabels(); Arrays.sort(existingLabels); if (!ArrayUtils.isEquals(existingLabels, newLabels)) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "New data loaded doesn't have the same labels as the existing ones. Aborting", "Error", JOptionPane.ERROR_MESSAGE); System.out.println(Arrays.toString(existingLabels)); System.out.println(Arrays.toString(newLabels)); return; } } inputData.add(data); final InputDataRadioButton rb = new InputDataRadioButton(data); bgInputData.add(rb); rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String actionCommand = rb.getActionCommand(); System.out.println(actionCommand); } }); if (inputData.size() == 1) { // first time loaded rb.setSelected(true); // enable the retrieval panel panelRetrieval.setEnabled(true); panelLoadedFeatureFiles.remove(labelNoInputData); // populate the combo box for the retrieval comboQueryVector.setModel(new DefaultComboBoxModel(data.getLabels())); modelNumberNeighbours.setMaximum(data.numVectors() - 1); modelNumberNeighbours.setValue(Math.min(5, data.numVectors())); spinnerNumberNeighbours.setToolTipText("Maximum value:" + (data.numVectors() - 1)); btnStart.setEnabled(true); // fill the library tab Object[][] libraryData = new Object[data.numVectors()][]; ImageIcon icon = UiUtils.getIcon(PlayerControl.ICON_PREFIX, "play" + PlayerControl.ICON_SUFFIX); for (int i = 0; i < libraryData.length; i++) { final JButton button = new JButton(icon); final int index = i; button.setActionCommand(String.valueOf(i)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String label = inputData.get(0).getLabel(index); try { player.stop(); player.play(new MP3VectorMetaData( new File(txtFieldMusicPath.getText() + File.separator + label), label)); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "Error playing audio file: " + e1.getMessage(), "Playback Error", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); libraryData[i] = new Object[] { button, data.getLabel(i), "unknown" }; } databaseDetailsTable .setModel(new DefaultTableModel(libraryData, databaseDetailsColumnNames)); databaseDetailsTable.getColumn(databaseDetailsColumnNames[0]) .setCellEditor(new ButtonCellEditor()); databaseDetailsTable.getColumn("").setCellRenderer(new ButtonCellRenderer()); resizeDatabaseDetailsTableColumns(); buttonLoadClassInfo.setEnabled(true); } panelLoadedFeatureFiles.add(rb); pack(); } } }); return buttonLoad; }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildBasicPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); // BASIC: Top panel final JPanel logoPanel = new JPanel(); logoPanel.setLayout(new FlowLayout()); logoPanel.setBorder(/*from w ww . ja va2 s .co m*/ new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logoPanel.border"))); //$NON-NLS-1$ jlMTLogo.setIcon(icon); logoPanel.add(jlMTLogo); // BASIC: Middle panel final JPanel memPanel = new JPanel(); memPanel.setLayout(new GridLayout(3, 2)); memPanel.setBorder(new LineBorder(Color.WHITE)); jtfMaxMem.setHorizontalAlignment(SwingConstants.RIGHT); jtfMaxMem.setInfo(CopiedFromOtherJars.getText("msg.info.javaMaxMem", DEFAULT_MAXMEM)); //$NON-NLS-1$ jtfMaxMem.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.javaMaxMem")); //$NON-NLS-1$ jtfMaxMem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { jtfMaxMemActionPerformed(evt); } }); jtfMaxMem.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent evt) { jtfMaxMemFocusLost(evt); } @Override public void focusGained(FocusEvent evt) { jtfMaxMemFocusLost(evt); } }); jtfMaxMem.addKeyListener(new InputValidator()); jtfMinMem.setHorizontalAlignment(SwingConstants.RIGHT); jtfMinMem.setInfo(CopiedFromOtherJars.getText("msg.info.javaMinMem", DEFAULT_MINMEM)); //$NON-NLS-1$ jtfMinMem.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.javaMinMem")); //$NON-NLS-1$ jtfMinMem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { jtfMinMemActionPerformed(evt); } }); jtfMinMem.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent evt) { jtfMinMemFocusLost(evt); } @Override public void focusGained(FocusEvent evt) { jtfMinMemFocusLost(evt); } }); jtfMinMem.addKeyListener(new InputValidator()); jtfStackSize.setHorizontalAlignment(SwingConstants.RIGHT); jtfStackSize.setInfo(CopiedFromOtherJars.getText("msg.info.javaStackSize", DEFAULT_STACKSIZE)); //$NON-NLS-1$ jtfStackSize.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.javaStackSize")); //$NON-NLS-1$ jtfStackSize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { jtfStackSizeActionPerformed(evt); } }); jtfStackSize.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent evt) { jtfStackSizeFocusLost(evt); } @Override public void focusGained(FocusEvent evt) { jtfStackSizeFocusLost(evt); } }); jtfStackSize.addKeyListener(new InputValidator()); memPanel.add(jtfMaxMem); memPanel.add(jtfMinMem); memPanel.add(jtfStackSize); // BASIC: Bottom panel final JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); final JPanel cbPanel = new JPanel(); cbPanel.setLayout(new GridLayout(2, 1)); cbPanel.setBorder(new LineBorder(Color.GRAY)); jcbPromptUser.setSelected(true); jcbPromptUser.setText(CopiedFromOtherJars.getText("msg.info.promptAtNextLaunch")); //$NON-NLS-1$ jcbPromptUser.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.promptAtNextLaunch")); //$NON-NLS-1$ jcbPromptUser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { promptUser = jcbPromptUser.isSelected(); } }); jbMTJar.setText(jbMTJarText); jbMTJar.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.registerMapToolJar")); //$NON-NLS-1$ jbMTJar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter filter = new FileNameExtensionFilter( CopiedFromOtherJars.getText("msg.chooser.javaExecutable"), "jar"); //$NON-NLS-1$ //$NON-NLS-2$ jfc.addChoosableFileFilter(filter); jfc.setFileFilter(filter); if (IS_MAC) { filter = new FileNameExtensionFilter( CopiedFromOtherJars.getText("msg.chooser.appleApplicationBundle"), "app"); //$NON-NLS-1$ //$NON-NLS-2$ jfc.addChoosableFileFilter(filter); } jfc.setCurrentDirectory(mapToolJarDir); final int returnVal = jfc.showOpenDialog(jbMTJar); if (returnVal == JFileChooser.APPROVE_OPTION) { final File f = jfc.getSelectedFile(); final String fileName = f.getName(); if (IS_MAC && fileName.endsWith(".app")) { //$NON-NLS-1$ File jarDir = new File(f.getParentFile(), fileName); if (jarDir.isDirectory()) { jarDir = new File(jarDir, "Contents/Resources/Java"); //$NON-NLS-1$ if (jarDir.isDirectory()) { mapToolJarDir = jarDir; mapToolJarName = fileName.replace(".app", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ } else { logMsg(Level.SEVERE, "{0} does not contain 'Contents/Resources/Java' like it should!", //$NON-NLS-1$ "msg.chooser.badAppLocation", jarDir); //$NON-NLS-1$ return; } } else { logMsg(Level.SEVERE, "{0} is not a directory and it should be!", //$NON-NLS-1$ "msg.chooser.badAppLocation", jarDir); //$NON-NLS-1$ return; } } else { mapToolJarName = fileName; mapToolJarDir = f.getParentFile(); } logMsg(Level.INFO, f.toString(), null); jbMTJar.setText(fileName.replace(".jar", EMPTY)); //$NON-NLS-1$ if (fileName.toLowerCase().startsWith("maptool-")) { // We expect the name matches 'maptool-1.3.b89.jar' mapToolVersion = " " + fileName.substring(8, 11); } else { logMsg(Level.SEVERE, "Cannot determine MapTool version number from JAR filename: {0}", //$NON-NLS-1$ "msg.info.noMapToolVersion", fileName); mapToolVersion = EMPTY; } jbLaunch.setEnabled(true); updateCommand(); jbLaunch.requestFocusInWindow(); } } }); cbPanel.add(jcbPromptUser); cbPanel.add(jbMTJar); southPanel.add(cbPanel, BorderLayout.CENTER); p.add(memPanel, BorderLayout.CENTER); p.add(logoPanel, BorderLayout.NORTH); p.add(southPanel, BorderLayout.SOUTH); p.setBorder(new LineBorder(Color.BLACK)); return p; }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Gets the show to open and opens the respective json file. *//* w w w . jav a 2 s. com*/ private void openShow() { if (askToSave()) { File file; final JFileChooser fc = new JFileChooser(Main.getFilePath()); fc.setFileFilter(new DrillFileFilter()); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal; do { returnVal = fc.showOpenDialog(this); file = fc.getSelectedFile(); } while (returnVal != JFileChooser.CANCEL_OPTION && returnVal != JFileChooser.ERROR_OPTION && !file.exists()); if (returnVal == JFileChooser.APPROVE_OPTION) { try { String name, path; path = file.getCanonicalPath(); path = path.substring(0, Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/')) + 1); name = file.getName().toLowerCase().endsWith(".drill") ? file.getName() : file.getName() + ".drill"; Main.setFilePath(path); Main.setPagesFileName(name); Main.load(false); desktop.createNewInternalFrames(); } catch (IOException e) { e.printStackTrace(); } } } }