Java Code Examples for javax.swing.JFileChooser.setDialogTitle()

The following are Jave code examples for showing how to use setDialogTitle() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jaer   File: YuhuangBoundingboxDisplay.java   Source Code and License Vote up 6 votes
synchronized public void doLoadGroundTruthFromTXT() {
    JFileChooser c = new JFileChooser(gtFilename);
    c.setDialogTitle("Choose ground truth bounding box file");
    FileFilter filt = new FileNameExtensionFilter("TXT File", "txt");
    c.addChoosableFileFilter(filt);
    c.setFileFilter(filt);
    c.setSelectedFile(new File(gtFilename));
    int ret = c.showOpenDialog(chip.getAeViewer());
    if (ret != JFileChooser.APPROVE_OPTION) {
        return;
    }
    gtFilename = c.getSelectedFile().toString();
    putString("GTFilename", gtFilename);
    gtFilenameShort = gtFilename.substring(0, 5) + "..." + gtFilename.substring(gtFilename.lastIndexOf(File.separator));
    try {
        this.loadBoundingBoxes(c.getSelectedFile());
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(chip.getAeViewer().getFilterFrame(), "Couldn't read bounding box file" + ex + ". See console for logging.", "Bad bounding box file", JOptionPane.WARNING_MESSAGE);
    }

}
 
Example 2
Project: Wilmersdorf_SER316   File: Util.java   Source Code and License Vote up 6 votes
public static boolean checkBrowser() {
    AppList appList = MimeTypesList.getAppList();
    String bpath = appList.getBrowserExec();
    if (bpath != null)
        if (new File(bpath).isFile())
            return true;
    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);*/
    if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION)
        return false;
    appList.setBrowserExec(chooser.getSelectedFile().getPath());
    CurrentStorage.get().storeMimeTypesList();
    return true;
}
 
Example 3
Project: SER316-Aachen   File: Util.java   Source Code and License Vote up 6 votes
public static boolean checkBrowser() {
    AppList appList = MimeTypesList.getAppList();
    String bpath = appList.getBrowserExec();
    if (bpath != null)
        if (new File(bpath).isFile())
            return true;
    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);*/
    if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION)
        return false;
    appList.setBrowserExec(chooser.getSelectedFile().getPath());
    CurrentStorage.get().storeMimeTypesList();
    return true;
}
 
Example 4
Project: incubator-netbeans   File: PanelProjectLocationVisual.java   Source Code and License Vote up 6 votes
private void browseLocationAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationAction
    String command = evt.getActionCommand();        
    if ( "BROWSE".equals( command ) ) { // NOI18N                
        JFileChooser chooser = new JFileChooser ();
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
        chooser.setDialogTitle(NbBundle.getMessage(PanelSourceFolders.class,"LBL_NWP1_SelectProjectLocation"));
        chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
        String path = this.projectLocationTextField.getText();
        if (path.length() > 0) {
            File f = new File (path);
            if (f.exists ()) {
                chooser.setSelectedFile(f);
            }
        }
        if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
            File projectDir = chooser.getSelectedFile();
            projectLocationTextField.setText( FileUtil.normalizeFile(projectDir).getAbsolutePath() );
        }            
        panel.fireChangeEvent();
    }
}
 
Example 5
Project: jaer   File: StereoCalibrationDualViewFilter.java   Source Code and License Vote up 6 votes
synchronized public void doSetPath() {
	JFileChooser j = new JFileChooser();
	j.setCurrentDirectory(new File(dirPath));
	j.setApproveButtonText("Select");
	j.setDialogTitle("Select a folder and base file name for calibration images");
	j.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // let user specify a base filename
	int ret = j.showSaveDialog(null);
	if (ret != JFileChooser.APPROVE_OPTION) {
		return;
	}
	//imagesDirPath = j.getSelectedFile().getAbsolutePath();
	dirPath = j.getCurrentDirectory().getPath();
	fileBaseName = j.getSelectedFile().getName();
	if (!fileBaseName.isEmpty()) {
		fileBaseName = "-" + fileBaseName;
	}
	log.log(Level.INFO, "Changed images path to {0}", dirPath);
	putString("dirPath", dirPath);
}
 
Example 6
Project: jaer   File: SingleCameraCalibration.java   Source Code and License Vote up 6 votes
synchronized public void doSaveCalibration() {
    if (!calibrated) {
        JOptionPane.showMessageDialog(null, "No calibration yet");
        return;
    }
    JFileChooser j = new JFileChooser();
    j.setCurrentDirectory(new File(dirPath));
    j.setApproveButtonText("Select folder");
    j.setDialogTitle("Select a folder to store calibration XML files");
    j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
    int ret = j.showSaveDialog(null);
    if (ret != JFileChooser.APPROVE_OPTION) {
        return;
    }
    dirPath = j.getSelectedFile().getPath();
    putString("dirPath", dirPath);
    serializeMat(dirPath, "cameraMatrix", cameraMatrix);
    serializeMat(dirPath, "distortionCoefs", distortionCoefs);
    saved = true;
    generateCalibrationString();
}
 
Example 7
Project: incubator-netbeans   File: RunJarPanel.java   Source Code and License Vote up 6 votes
private void btnWorkDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkDirActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(null);
    chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    
    String workDir = txtWorkDir.getText();
    if (workDir.equals("")) { //NOI18N
        workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
    }
    chooser.setSelectedFile(new File(workDir));
    chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(RunJarPanel.class, "TIT_SelectWorkingDirectory"));
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { //NOI18N
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        txtWorkDir.setText(file.getAbsolutePath());
    }
}
 
Example 8
Project: java-course   File: OpenDocumentAction.java   Source Code and License Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent e) {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Open file");
    if (fc.showOpenDialog(observer) != JFileChooser.APPROVE_OPTION) {
        return;
    }
    Path file = fc.getSelectedFile().toPath();
    if (!Files.isReadable(file)) {
        JOptionPane.showMessageDialog(observer,
                lp.getString("readingError"), lp.getString("errorTitle"),
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    JNotepadPPDocument openedDocument;
    try {
        openedDocument = new JNotepadPPDocument(observer, file);
    } catch (IOException e1) {
        observer.errorMessage(e1);
        return;
    }
    int index = observer.getEditors().indexOf(openedDocument);
    if (index > -1) {
        observer.getTabs().setSelectedIndex(index);
        return;
    }
    observer.addNewTab(openedDocument);
}
 
Example 9
Project: Wilmersdorf_SER316   File: FileExportDialog.java   Source Code and License Vote up 5 votes
private void browseTemplate() {
	JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Select file"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    if (templF.getText().length() >0)
    	chooser.setCurrentDirectory(new java.io.File(templF.getText()));
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    	templF.setText(chooser.getSelectedFile().getPath());
}
 
Example 10
Project: brModelo   File: Dialogos.java   Source Code and License Vote up 5 votes
public static File ShowDlgSaveDiagrama(JComponent form, Diagrama diag) {
    JFileChooser f = new JFileChooser();
    //f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
    f.setFileSelectionMode(JFileChooser.FILES_ONLY);

    FileFilter filter = new FileNameExtensionFilter("BrModelo(bin)", Arquivo.brM3);
    FileFilter filter2 = new FileNameExtensionFilter("BrModelo(xml)", Arquivo.xml);
    f.addChoosableFileFilter(filter);
    f.addChoosableFileFilter(filter2);
    f.setAcceptAllFileFilterUsed(false);
    f.setFileFilter(filter);
    if (dir.isEmpty()) dir = System.getProperty("user.dir");
    f.setCurrentDirectory(new File(dir + "."));
    f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.MSG_SAVE_TITLE") + " " + diag.getNomeFormatado());
    if (!diag.getNome().isEmpty()){ 
        f.setSelectedFile(new File(diag.getNome()));
    }
    //f.setApproveButtonText(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
    int returnVal = f.showSaveDialog(form);
    //int returnVal = f.showDialog(form, Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();
        String ext = Arquivo.getExtension(file);
        if (ext == null) {
            ext = "";
        }
        String arq = file.getAbsolutePath();
        dir = f.getCurrentDirectory().getAbsolutePath();
        if (f.getFileFilter().equals(filter) && !Arquivo.brM3.toUpperCase().equals(ext.toUpperCase())) {
            return new File(arq + "." + Arquivo.brM3);
        }
        if (f.getFileFilter().equals(filter2) && !Arquivo.xml.toUpperCase().equals(ext.toUpperCase())) {
            return new File(arq + "." + Arquivo.xml);
        }
        return file;
    } else {
        return null;
    }
}
 
Example 11
Project: SER316-Ingolstadt   File: SetApplicationPanel.java   Source Code and License Vote up 5 votes
void selectAppBrowseB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");

JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(Local.getString("Path to executable"));
chooser.setFileHidingEnabled(false);
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (System.getProperty("os.name").startsWith("Win")) {
    chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.EXE));
    chooser.setCurrentDirectory(new File("C:\\Program Files"));
}
chooser.setPreferredSize(new Dimension(550, 375));
/*
    java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_IMPORT_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);
*/
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    applicationField.setText(chooser.getSelectedFile().getPath());
}
 
Example 12
Project: gate-core   File: CreateIndexGUI.java   Source Code and License Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e){
  JFileChooser fileChooser = MainFrame.getFileChooser();
  fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fileChooser.setDialogTitle("Select a directory for the index files");
  int res = fileChooser.showOpenDialog(CreateIndexGUI.this);
  if(res == JFileChooser.APPROVE_OPTION) indexLocationTextField.
                                        setText(fileChooser.
                                        getSelectedFile().toString());
}
 
Example 13
Project: geomapapp   File: LayerManager.java   Source Code and License Vote up 5 votes
public static void getLayerSessionChooser() throws IOException{	
	JFileChooser sessionImport = new JFileChooser
	(System.getProperty("user.home") + "/Desktop");
	sessionImport.setDialogTitle("Import Layer Session");
	sessionImport.setAcceptAllFileFilterUsed(true);
	sessionImport.setFileFilter(new FileFilter() {
		public boolean accept(File file) {
			String fileName = file.getName().toLowerCase();
			if (fileName.endsWith(".xml")) {
				return true;
			}
			return false;
			}
		public String getDescription() {
			return "XML file (*.xml)";
		}
	});
	sessionImport.setFileSelectionMode(JFileChooser.FILES_ONLY);
	int code = sessionImport.showOpenDialog(map.getParent());
	if(code==JFileChooser.CANCEL_OPTION){
		doImport = false;
		return;
	}else if(code==JFileChooser.APPROVE_OPTION){
		File f =sessionImport.getSelectedFile();
		String fs = f.toString();
		importLayerSession(fs);
		doImport = true;
	}

}
 
Example 14
Project: incubator-netbeans   File: J2SEPlatformCustomizer.java   Source Code and License Vote up 4 votes
private static boolean select(
    final PathModel model,
    final File[] currentDir,
    final Component parentComponent) {
    final JFileChooser chooser = new JFileChooser ();
    chooser.setMultiSelectionEnabled (true);
    String title = null;
    String message = null;
    String approveButtonName = null;
    String approveButtonNameMne = null;
    if (model.type == SOURCES) {
        title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
        message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Sources");
        approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
        approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenSources");
    } else if (model.type == JAVADOC) {
        title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
        message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Javadoc");
        approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
        approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenJavadoc");
    }
    chooser.setDialogTitle(title);
    chooser.setApproveButtonText(approveButtonName);
    chooser.setApproveButtonMnemonic (approveButtonNameMne.charAt(0));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    if (Utilities.isMac()) {
        //New JDKs and JREs are bundled into package, allow JFileChooser to navigate in
        chooser.putClientProperty("JFileChooser.packageIsTraversable", "always");   //NOI18N
    }
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setFileFilter (new ArchiveFileFilter(message,new String[] {"ZIP","JAR"}));   //NOI18N
    if (currentDir[0] != null) {
        chooser.setCurrentDirectory(currentDir[0]);
    }
    if (chooser.showOpenDialog(parentComponent) == JFileChooser.APPROVE_OPTION) {
        File[] fs = chooser.getSelectedFiles();
        boolean addingFailed = false;
        for (File f : fs) {
            //XXX: JFileChooser workaround (JDK bug #5075580), double click on folder returns wrong file
            // E.g. for /foo/src it returns /foo/src/src
            // Try to convert it back by removing last invalid name component
            if (!f.exists()) {
                File parent = f.getParentFile();
                if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) {
                    f = parent;
                }
            }
            if (f.exists()) {
                addingFailed|=!model.addPath (f);
            }
        }
        if (addingFailed) {
            new NotifyDescriptor.Message (NbBundle.getMessage(J2SEPlatformCustomizer.class,"TXT_CanNotAddResolve"),
                    NotifyDescriptor.ERROR_MESSAGE);
        }
        currentDir[0] = FileUtil.normalizeFile(chooser.getCurrentDirectory());
        return true;
    }
    return false;
}
 
Example 15
Project: Reinickendorf_SER316   File: EditTypeDialog.java   Source Code and License Vote up 4 votes
void setIconB_actionPerformed(ActionEvent e) {
    // Fix until Sun's JVM supports more locales...
    UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
    UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
    UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
    UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
    UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
    UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
    UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
    UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
    UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
    UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
    UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
    UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");
    
    JFileChooser chooser = new JFileChooser();
    chooser.setPreferredSize(new Dimension(550, 375));
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Choose icon file"));
    //chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setCurrentDirectory(
        new File(net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/mimetypes").getPath()));
    /*if (System.getProperty("os.name").startsWith("Win")) {
        chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.ICO));
        chooser.setCurrentDirectory(new File("C:\\Program Files"));
    }
    else */
    chooser.addChoosableFileFilter(new net.sf.memoranda.ui.htmleditor.filechooser.ImageFilter());
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            iconLabel.setIcon(new ImageIcon(chooser.getSelectedFile().getPath()));
       }
        catch (Exception ex) {
  //ex.printStackTrace();
 }
        finally {
            iconPath = chooser.getSelectedFile().getPath();
        }

    }
}
 
Example 16
Project: incubator-netbeans   File: PatchAction.java   Source Code and License Vote up 4 votes
private File getPatchFor(FileObject fo) {
       JFileChooser chooser = new JFileChooser();
       String patchDirPath = DiffModuleConfig.getDefault().getPreferences().get(PREF_RECENT_PATCH_PATH, System.getProperty("user.home"));
       File patchDir = new File(patchDirPath);
       while (!patchDir.isDirectory()) {
           patchDir = patchDir.getParentFile();
           if (patchDir == null) {
               patchDir = new File(System.getProperty("user.home"));
               break;
           }
       }
       FileUtil.preventFileChooserSymlinkTraversal(chooser, patchDir);
       chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
       String title = NbBundle.getMessage(PatchAction.class,
           (fo.isData()) ? "TITLE_SelectPatchForFile"
                         : "TITLE_SelectPatchForFolder", fo.getNameExt());
       chooser.setDialogTitle(title);

       // setup filters, default one filters patch files
       FileFilter patchFilter = new javax.swing.filechooser.FileFilter() {
           @Override
           public boolean accept(File f) {
               return f.getName().endsWith("diff") || f.getName().endsWith("patch") || f.isDirectory();  // NOI18N
           }
           @Override
           public String getDescription() {
               return NbBundle.getMessage(PatchAction.class, "CTL_PatchDialog_FileFilter");
           }
       };
       chooser.addChoosableFileFilter(patchFilter);
       chooser.setFileFilter(patchFilter);

       chooser.setApproveButtonText(NbBundle.getMessage(PatchAction.class, "BTN_Patch"));
       chooser.setApproveButtonMnemonic(NbBundle.getMessage(PatchAction.class, "BTN_Patch_mnc").charAt(0));
       chooser.setApproveButtonToolTipText(NbBundle.getMessage(PatchAction.class, "BTN_Patch_tooltip"));
       HelpCtx ctx = new HelpCtx(PatchAction.class.getName());
       DialogDescriptor descriptor = new DialogDescriptor( chooser, title, true, new Object[0], null, 0, ctx, null );
       final Dialog dialog = DialogDisplayer.getDefault().createDialog( descriptor );
       dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PatchAction.class, "ACSD_PatchDialog"));

       ChooserListener listener = new PatchAction.ChooserListener(dialog,chooser);
chooser.addActionListener(listener);
       dialog.setVisible(true);

       File selectedFile = listener.getFile();
       if (selectedFile != null) {
           DiffModuleConfig.getDefault().getPreferences().put(PREF_RECENT_PATCH_PATH, selectedFile.getParentFile().getAbsolutePath());
       }
       return selectedFile;
   }
 
Example 17
Project: Reinickendorf_SER316   File: AddResourceDialog.java   Source Code and License Vote up 4 votes
/**
* setup the JFileChooser so the user can select the resource file
*/

  void browseB_actionPerformed(ActionEvent e) {
      // Fix until Sun's JVM supports more locales...
      UIManager.put("FileChooser.lookInLabelText", 
          Local.getString("Look in:"));
      UIManager.put("FileChooser.upFolderToolTipText", 
          Local.getString("Up One Level"));
      UIManager.put("FileChooser.newFolderToolTipText", 
          Local.getString("Create New Folder"));
      UIManager.put("FileChooser.listViewButtonToolTipText", 
          Local.getString("List"));
      UIManager.put("FileChooser.detailsViewButtonToolTipText", 
          Local.getString("Details"));
      UIManager.put("FileChooser.fileNameLabelText", 
          Local.getString("File Name:"));
      UIManager.put("FileChooser.filesOfTypeLabelText", 
          Local.getString("Files of Type:"));
      UIManager.put("FileChooser.openButtonText", 
          Local.getString("Open"));
      UIManager.put("FileChooser.openButtonToolTipText", 
          Local.getString("Open selected file"));
      UIManager.put("FileChooser.cancelButtonText", 
          Local.getString("Cancel"));
      UIManager.put("FileChooser.cancelButtonToolTipText", 
          Local.getString("Cancel"));
      
      JFileChooser chooser = new JFileChooser();
      chooser.setFileHidingEnabled(false);
      chooser.setDialogTitle(Local.getString("Add resource"));
      chooser.setAcceptAllFileFilterUsed(true);
      chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);        
      chooser.setPreferredSize(new Dimension(550, 375));
      /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
      if (lastSel != null)
          chooser.setCurrentDirectory(lastSel);*/
      if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
          return;
      /*try {
          Context.put("LAST_SELECTED_RESOURCE_FILE", chooser.getSelectedFile());
      }
      catch (Exception ex) {}*/
      pathField.setText(chooser.getSelectedFile().getPath());
      checkOkEnabled();
  }
 
Example 18
Project: AgentWorkbench   File: ChartEditorJPanel.java   Source Code and License Vote up 4 votes
@Override
public void actionPerformed(ActionEvent ae) {
	
	if (ae.getSource() == jButtonCsvImport){
		// --- Import CSV data / Choose file ----------
		JFileChooser jFileChooserImportCSV = new JFileChooser(Application.getGlobalInfo().getLastSelectedFolder());
		jFileChooserImportCSV.setFileFilter(new FileNameExtensionFilter(Language.translate("CSV-Dateien"), "csv"));
		jFileChooserImportCSV.setDialogTitle(Language.translate("CSV-Datei importieren"));
		if(jFileChooserImportCSV.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){
			Application.getGlobalInfo().setLastSelectedFolder(jFileChooserImportCSV.getCurrentDirectory());
			File csvFile = jFileChooserImportCSV.getSelectedFile();
			
			// --- Separate DataModel --------------------------- 
			if (this.getDataModel() instanceof TimeSeriesDataModel) {
				// --- Ask for time format ----------------------
				TimeFormatImportConfiguration importFormatDialog = new TimeFormatImportConfiguration(Application.getMainWindow(), csvFile); 
				importFormatDialog.setVisible(true);
				// - - - - - - - - - - - - - - - - - - - - - - -  
				if (importFormatDialog.isCanceled()==true) return;
				// --- Import data ------------------------------
				this.importDataSeriesFromCSV(csvFile, importFormatDialog.getTimeFormat(), importFormatDialog.getTimeOffset());
				
			} else {
				// --- Import data ------------------------------
				this.importDataSeriesFromCSV(csvFile, null, null);	
				
			}
			this.getTableTab().setButtonsEnabledToSituation();
		}
		
	} else if(ae.getSource() == jButtonSaveAsImage) {
		// --- Export the image ---------------------------------
		this.saveAsImage();
	} else if(ae.getSource() == tfImageWidth) {
		// --- Recalculate image size when enter was pressed ----
		this.recalculateImageHeight();
	}else if(ae.getSource() == tfImageHeight){
		// --- Recalculate image size when enter was pressed-----
		this.recalculateImageWidth();
	}else if(ae.getSource() == cbImageAspectRatio){
		// --- Recalculate image size when aspect ratio changed -
		this.recalculateImageHeight();
	}else if(ae.getSource() == jButtonCsvExport){
		this.exportDataAsCSV();
	}

}
 
Example 19
Project: SER316-Munich   File: AddResourceDialog.java   Source Code and License Vote up 4 votes
/**
* setup the JFileChooser so the user can select the resource file
*/

  void browseB_actionPerformed(ActionEvent e) {
      // Fix until Sun's JVM supports more locales...
      UIManager.put("FileChooser.lookInLabelText", 
          Local.getString("Look in:"));
      UIManager.put("FileChooser.upFolderToolTipText", 
          Local.getString("Up One Level"));
      UIManager.put("FileChooser.newFolderToolTipText", 
          Local.getString("Create New Folder"));
      UIManager.put("FileChooser.listViewButtonToolTipText", 
          Local.getString("List"));
      UIManager.put("FileChooser.detailsViewButtonToolTipText", 
          Local.getString("Details"));
      UIManager.put("FileChooser.fileNameLabelText", 
          Local.getString("File Name:"));
      UIManager.put("FileChooser.filesOfTypeLabelText", 
          Local.getString("Files of Type:"));
      UIManager.put("FileChooser.openButtonText", 
          Local.getString("Open"));
      UIManager.put("FileChooser.openButtonToolTipText", 
          Local.getString("Open selected file"));
      UIManager.put("FileChooser.cancelButtonText", 
          Local.getString("Cancel"));
      UIManager.put("FileChooser.cancelButtonToolTipText", 
          Local.getString("Cancel"));
      
      JFileChooser chooser = new JFileChooser();
      chooser.setFileHidingEnabled(false);
      chooser.setDialogTitle(Local.getString("Add resource"));
      chooser.setAcceptAllFileFilterUsed(true);
      chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);        
      chooser.setPreferredSize(new Dimension(550, 375));
      /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
      if (lastSel != null)
          chooser.setCurrentDirectory(lastSel);*/
      if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
          return;
      /*try {
          Context.put("LAST_SELECTED_RESOURCE_FILE", chooser.getSelectedFile());
      }
      catch (Exception ex) {}*/
      pathField.setText(chooser.getSelectedFile().getPath());
      checkOkEnabled();
  }
 
Example 20
Project: LanChatLite   File: MainGui.java   Source Code and License Vote up 2 votes
/**
 * other party send "SFR - Send File Request"
 * asking me to receive the file,
 * if I click yes, then other party should give me the file
 * so, send GMF request to other party
 * and start TCP thread to receive file 
 * @param msg
 */
private void processSFR(String msg) {
    
	String l[] = msg.split("\\::");
	
	String otherHost = l[0];
	String filePath = l[1];		
	int fileSize = Integer.parseInt(l[2]);
	System.out.println("File length: " + fileSize);
	
	String otherIP = htblUsers.get(otherHost);
		
	Path p = Paths.get(filePath);
    String fileName = p.getFileName().toString();

    //System.out.println("filePath = " + filePath);
    //System.out.println("fileName = " + fileName);
      
	JDialog.setDefaultLookAndFeelDecorated(true);
    int response = JOptionPane.showConfirmDialog(null, 
    		"Do you want to receive file from " + otherHost + " ?",
    		"Receive File: " + fileName,
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    
    if (response == JOptionPane.NO_OPTION) {
      System.out.println("No button clicked");
      Utils.sendUdpMsg("GMF" + myHost + "::" + "" + "::" + "No file", otherIP, Config.UDP_PORT);
    } else if (response == JOptionPane.YES_OPTION) {
    
    System.out.println("Yes button clicked");  
    
 // parent component of the dialog
    JFrame parentFrame = new JFrame();
     
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Specify a file to save");   

    fileChooser.setSelectedFile(new File(System.getProperty("user.home") + File.separator  + fileName) ); 
    int userSelection = fileChooser.showSaveDialog(parentFrame);
     
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        
        
        
        String savePath = fileToSave.getAbsolutePath();
        System.out.println("Save as file: " + savePath);
        
        
        Config.TCP_PORT++;
        System.out.println("TCP Port : " +  Config.TCP_PORT );
	  	
	    new ReceiveFileThread(Config.TCP_PORT, savePath, fileSize).start();
	    Utils.sendUdpMsg("GMF" + myHost + "::" + Config.TCP_PORT + "::" + filePath, otherIP, Config.UDP_PORT);
    }
   
         
    } else if (response == JOptionPane.CLOSED_OPTION) {
      System.out.println("JOptionPane closed");
    }
}