Java Code Examples for javax.swing.JFileChooser

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Briss, under directory /src/main/java/at/laborg/briss/.

Source file: BrissGUI.java

  32 
vote

private File getCropFileDestination(File sourceFile){
  File recommendedFile=BrissFileHandling.getRecommendedDestination(sourceFile);
  JFileChooser fc=new JFileChooser(lastOpenDir);
  fc.setSelectedFile(recommendedFile);
  fc.setFileFilter(new PDFFileFilter());
  int retval=fc.showSaveDialog(this);
  if (retval == JFileChooser.APPROVE_OPTION)   return fc.getSelectedFile();
  return null;
}
 

Example 2

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/param/.

Source file: ExecutionListParamWindow.java

  32 
vote

private String showChooserForImport(String title){
  JFileChooser jFileChooser=new JFileChooser();
  jFileChooser.setDialogTitle(title);
  jFileChooser.addChoosableFileFilter(new XmlFileFilter());
  int result=jFileChooser.showOpenDialog(frame);
  if (result == JFileChooser.APPROVE_OPTION) {
    return jFileChooser.getSelectedFile().getAbsolutePath();
  }
  return null;
}
 

Example 3

From project Cours-3eme-ann-e, under directory /Java/FerryInpres/src/mail_client/.

Source file: NouveauMessage.java

  32 
vote

private void ajoutPieceButtonActionPerformed(java.awt.event.ActionEvent evt){
  JFileChooser fc=new JFileChooser();
  int returnVal=fc.showOpenDialog(this);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file=fc.getSelectedFile();
    DefaultListModel model=(DefaultListModel)this.piecesJointesList.getModel();
    this._piecesJointes.add(file.getPath());
    model.addElement(file.getName());
  }
}
 

Example 4

From project drools-planner, under directory /drools-planner-examples/src/main/java/org/drools/planner/examples/common/swingui/.

Source file: SolverAndPersistenceFrame.java

  32 
vote

public void actionPerformed(ActionEvent e){
  JFileChooser fileChooser=new JFileChooser(solutionBusiness.getExportDataDir());
  int approved=fileChooser.showSaveDialog(SolverAndPersistenceFrame.this);
  if (approved == JFileChooser.APPROVE_OPTION) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {
      solutionBusiness.exportSolution(fileChooser.getSelectedFile());
    }
  finally {
      setCursor(Cursor.getDefaultCursor());
    }
  }
}
 

Example 5

From project encog-java-examples, under directory /src/main/java/org/encog/examples/gui/generic/.

Source file: GenericExample.java

  32 
vote

public void performLoad(){
  final JFileChooser fc=new JFileChooser();
  int rc=fc.showOpenDialog(this);
  if (rc == JFileChooser.APPROVE_OPTION) {
    File f=fc.getSelectedFile();
    GenericIO.load(f,this.worldRunner);
    this.visualizer=new BasicCAVisualizer(this.worldRunner.getUniverse());
    this.worldArea.setCurrentImage(this.visualizer.visualize());
  }
}
 

Example 6

From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/dialogs/common/.

Source file: FolderField.java

  32 
vote

public void actionPerformed(ActionEvent e){
  if (e.getSource() == this.button) {
    final JFileChooser fc=new JFileChooser();
    fc.setCurrentDirectory(new File(((JTextField)this.getField()).getText()));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    final int result=fc.showOpenDialog(this.getOwner());
    if (result == JFileChooser.APPROVE_OPTION) {
      String file=fc.getSelectedFile().getAbsolutePath();
      ((JTextField)this.getField()).setText(file);
    }
  }
}
 

Example 7

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/.

Source file: FileField.java

  32 
vote

public void actionPerformed(ActionEvent e){
  if (e.getSource() == _browseButton) {
    JFileChooser chooser=new JFileChooser();
    int result=chooser.showOpenDialog(_browseButton);
    if (result == JFileChooser.APPROVE_OPTION) {
      _pathTextField.setText(chooser.getSelectedFile().getAbsolutePath());
      _pathTextField.setCaretPosition(0);
      _browseButton.requestFocus();
    }
  }
}
 

Example 8

From project freemind, under directory /freemind/freemind/modes/.

Source file: ControllerAdapter.java

  32 
vote

/** 
 * Creates a file chooser with the last selected directory as default.
 */
public JFileChooser getFileChooser(FileFilter filter){
  JFileChooser chooser=new JFileChooser();
  File parentFile=getMapsParentFile();
  if (parentFile != null && lastCurrentDir == null) {
    lastCurrentDir=parentFile;
  }
  if (lastCurrentDir != null) {
    chooser.setCurrentDirectory(lastCurrentDir);
  }
  if (filter != null) {
    chooser.addChoosableFileFilter(filter);
  }
  return chooser;
}
 

Example 9

From project gs-tool, under directory /src/org/graphstream/tool/gui/.

Source file: PathSelector.java

  32 
vote

public void actionPerformed(ActionEvent e){
  JFileChooser chooser=new JFileChooser();
  int r=chooser.showOpenDialog(selector);
  if (r == JFileChooser.APPROVE_OPTION) {
    selector.path.setText(chooser.getSelectedFile().getAbsolutePath());
    selector.repaint();
  }
}
 

Example 10

From project huiswerk, under directory /print/zxing-1.6/javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  32 
vote

private void chooseImage() throws MalformedURLException {
  JFileChooser fileChooser=new JFileChooser();
  fileChooser.showOpenDialog(this);
  File file=fileChooser.getSelectedFile();
  Icon imageIcon=new ImageIcon(file.toURI().toURL());
  setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight() + 100);
  imageLabel.setIcon(imageIcon);
  String decodeText=getDecodeText(file);
  textArea.setText(decodeText);
}
 

Example 11

From project imageflow, under directory /src/de/danielsenff/imageflow/.

Source file: ImageFlowView.java

  32 
vote

/** 
 * Import workflow from XML.  The current workflow will remain and the second workflow will be added without replacement
 * @return
 * @throws MalformedURLException 
 */
@Action public ImportGraphTask importGraph() throws MalformedURLException {
  final JFileChooser fc=new JFileChooser();
  final String filesExtension=getResourceString("flowXMLFileExtension");
  final String filesDesc=getResourceString("flowXMLFileExtensionDescription");
  fc.setFileFilter(new DescriptiveFileFilter(filesExtension,filesDesc));
  ImportGraphTask task=null;
  final int option=fc.showOpenDialog(null);
  if (option == JFileChooser.APPROVE_OPTION) {
    task=new ImportGraphTask(fc.getSelectedFile().toURI().toURL());
  }
  return task;
}
 

Example 12

From project Java3DTest, under directory /Java3D/src/.

Source file: GUI_3D.java

  32 
vote

public void actionPerformed(ActionEvent e){
  JFileChooser chooser=new JFileChooser(new File(".").getAbsolutePath());
  int returnVal=chooser.showOpenDialog(null);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
    logPart(chooser.getSelectedFile().getName());
  }
  String fileName=chooser.getSelectedFile().getName();
  int ext=fileName.indexOf('.');
  fileName=fileName.substring(0,ext);
  sessionLog.setFilename(fileName);
}
 

Example 13

From project jCAE, under directory /jcae/core/src/org/jcae/netbeans/viewer3d/actions/.

Source file: SnapshotAction.java

  32 
vote

@Override public void actionPerformed(View view){
  JFileChooser fc=new JFileChooser();
  fc.setFileFilter(PNG_FILE_FILTER);
  if (fc.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) {
    Utils.takeScreenshot(view,fc.getSelectedFile().getPath());
  }
}
 

Example 14

From project jftp, under directory /src/main/java/com/myjavaworld/jftp/.

Source file: DownloadAndUnzipDlg.java

  32 
vote

private File browse(){
  JFileChooser chooser=new JFileChooser();
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  chooser.setDialogTitle(CommonResources.getString("title.selectDirectory"));
  chooser.setApproveButtonText(CommonResources.getString("text.select"));
  int option=chooser.showOpenDialog(this);
  if (option == JFileChooser.APPROVE_OPTION) {
    File selectedDir=chooser.getSelectedFile();
    return selectedDir;
  }
  return null;
}
 

Example 15

From project jSite, under directory /src/main/java/de/todesbaum/jsite/gui/.

Source file: PreferencesPage.java

  32 
vote

/** 
 * Lets the user choose a new temp directory.
 */
private void chooseTempDirectory(){
  JFileChooser fileChooser=new JFileChooser(tempDirectory);
  fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int returnValue=fileChooser.showDialog(wizard,I18n.getMessage("jsite.preferences.temp-directory.choose.approve"));
  if (returnValue == JFileChooser.CANCEL_OPTION) {
    return;
  }
  tempDirectory=fileChooser.getSelectedFile().getPath();
  tempDirectoryTextField.setText(tempDirectory);
}
 

Example 16

From project Kayak, under directory /Kayak-logging/src/main/java/com/github/kayak/logging/options/.

Source file: LoggingPanel.java

  32 
vote

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
  JFileChooser chooser=new JFileChooser(jTextField1.getText());
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
    jTextField1.setText(chooser.getSelectedFile().getAbsolutePath());
  }
}
 

Example 17

From project Maimonides, under directory /src/com/codeko/apps/maimonides/.

Source file: PanelAnos.java

  32 
vote

NuevoTask(org.jdesktop.application.Application app){
  super(app);
  firePropertyChange("setIniciado",null,true);
  JOptionPane.showMessageDialog(MaimonidesApp.getMaimonidesView().getFrame(),"A continuaci?n se le pedir? el directorio donde se encuentran todos los datos a importar para el nuevo a?o escolar.\nConsulte la documentaci?n para ver que archivos necesita incluir en este directorio y como obtenerlos.","Directorio de datos",JOptionPane.INFORMATION_MESSAGE);
  JFileChooser f=new JFileChooser(MaimonidesApp.getApplication().getUltimoArchivo());
  f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int res=f.showOpenDialog(MaimonidesApp.getMaimonidesView().getFrame());
  if (res != JFileChooser.APPROVE_OPTION) {
    cancel(true);
  }
 else {
    setDirectorio(f.getSelectedFile());
  }
}
 

Example 18

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: FileOpen.java

  31 
vote

public FileOpen(final String title,final String... extensions){
  final JFileChooser chooser=new JFileChooser();
  chooser.setDialogTitle(title);
  chooser.setCurrentDirectory(new File(System.getProperties().getProperty("user.dir")));
  chooser.setFileFilter(new javax.swing.filechooser.FileFilter(){
    @Override public boolean accept(    final File f){
      if (f.isDirectory()) {
        return true;
      }
      for (      final String ex : extensions) {
        if (f.getName().endsWith(ex)) {
          return true;
        }
      }
      return false;
    }
    @Override public String getDescription(){
      final StringBuffer buf=new StringBuffer();
      for (      final String ex : extensions) {
        buf.append("*").append(ex).append(" ");
      }
      return buf.toString();
    }
  }
);
  final int result=chooser.showOpenDialog(null);
  if (result == JFileChooser.CANCEL_OPTION) {
    return;
  }
  try {
    file=chooser.getSelectedFile();
  }
 catch (  final Exception ex) {
    JOptionPane.showMessageDialog(null,ERR_MSG_1,"Warning!",JOptionPane.WARNING_MESSAGE);
    file=null;
  }
}
 

Example 19

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.

Source file: Case.java

  31 
vote

/** 
 * Ensure that all image paths point to valid image files
 */
private static void checkImagesExist(SleuthkitCase db){
  Map<Long,String> imgPaths=getImagePaths(db);
  for (  Map.Entry<Long,String> entry : imgPaths.entrySet()) {
    JFileChooser fc=new JFileChooser();
    FileFilter filter;
    long obj_id=entry.getKey();
    String path=entry.getValue();
    boolean fileExists=pathExists(path);
    if (!fileExists) {
      filter=AddImageVisualPanel1.allFilter;
      fc.setMultiSelectionEnabled(false);
      fc.setFileFilter(filter);
      int ret=JOptionPane.showConfirmDialog(null,appName + " has detected that one of the images associated with \n" + "this case are missing. Would you like to search for them now?\n"+ "Previously, the image was located at:\n"+ path+ "\nPlease note that you will still be able to browse directories and generate reports\n"+ "if you choose No, but you will not be able to view file content or run the ingest process.","Missing Image",JOptionPane.YES_NO_OPTION);
      if (ret == JOptionPane.YES_OPTION) {
        fc.showOpenDialog(null);
        String newPath=fc.getSelectedFile().getPath();
        try {
          db.setImagePaths(obj_id,Arrays.asList(new String[]{newPath}));
        }
 catch (        TskException ex) {
          Logger.getLogger(Case.class.getName()).log(Level.WARNING,"Error setting image paths",ex);
        }
      }
 else {
        Logger.getLogger(Case.class.getName()).log(Level.WARNING,"Selected image files don't match old files!");
      }
    }
  }
}
 

Example 20

From project BMach, under directory /src/documentcontainer/.

Source file: DocumentIOManager.java

  31 
vote

public boolean saveAs(Component parent,FileFilter filter) throws IOException {
  JFileChooser fc=new JFileChooser();
  fc.setCurrentDirectory(this.lastSaveDir);
  fc.setFileFilter(filter);
  int selection=fc.showSaveDialog(parent);
  if (selection == JFileChooser.APPROVE_OPTION) {
    this.lastSaveDir=fc.getCurrentDirectory();
    File f=fc.getSelectedFile();
    if (f != null) {
      if (f.exists()) {
        if (confirmOverwrite(parent,f.getAbsolutePath())) {
          container.saveDocument(f);
          this.addToRecentlyAccessed(f);
          return true;
        }
 else {
          return saveAs(parent,filter);
        }
      }
 else {
        container.saveDocument(f);
        this.addToRecentlyAccessed(f);
        return true;
      }
    }
  }
  return false;
}
 

Example 21

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/binding/internal/.

Source file: FileEditor.java

  31 
vote

@Override public JComponent createEditorComponent(PropertyDescriptor propertyDescriptor,BindingContext bindingContext){
  final JTextField textField=new JTextField();
  final ComponentAdapter adapter=new TextComponentAdapter(textField);
  final Binding binding=bindingContext.bind(propertyDescriptor.getName(),adapter);
  final JPanel editorPanel=new JPanel(new BorderLayout(2,2));
  editorPanel.add(textField,BorderLayout.CENTER);
  final JButton etcButton=new JButton("...");
  final Dimension size=new Dimension(26,16);
  etcButton.setPreferredSize(size);
  etcButton.setMinimumSize(size);
  etcButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      final JFileChooser fileChooser=new JFileChooser();
      int i=fileChooser.showDialog(editorPanel,"Select");
      if (i == JFileChooser.APPROVE_OPTION && fileChooser.getSelectedFile() != null) {
        binding.setPropertyValue(fileChooser.getSelectedFile());
      }
    }
  }
);
  editorPanel.add(etcButton,BorderLayout.EAST);
  return editorPanel;
}
 

Example 22

From project Clotho-Core, under directory /ClothoApps/SequenceChecker/src/jaligner/ui/filechooser/.

Source file: FileChooserTrusted.java

  31 
vote

/** 
 * Shows a dialog to select a file.
 * @return input stream
 * @throws FileChooserException
 * @see NamedInputStream
 */
public NamedInputStream open() throws FileChooserException {
  try {
    JFileChooser chooser=new JFileChooser();
    chooser.setCurrentDirectory(new File(getUserDirectory()));
    int returnVal=chooser.showOpenDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      setUserDirectory(chooser.getCurrentDirectory().toString());
      logger.info("Loaded: " + chooser.getSelectedFile().getName());
      return new NamedInputStream(chooser.getSelectedFile().getName(),new FileInputStream(chooser.getSelectedFile()));
    }
 else {
      return null;
    }
  }
 catch (  Exception e) {
    String message="Failed open: " + e.getMessage();
    logger.warning(message);
    throw new FileChooserException(message);
  }
}
 

Example 23

From project coffeescript-netbeans, under directory /src/coffeescript/nb/project/sample/.

Source file: CoffeeScriptApplicationPanelVisual.java

  31 
vote

private void browseButtonActionPerformed(java.awt.event.ActionEvent evt){
  String command=evt.getActionCommand();
  if ("BROWSE".equals(command)) {
    JFileChooser chooser=new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser,null);
    chooser.setDialogTitle("Select Project Location");
    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)) {
      File projectDir=chooser.getSelectedFile();
      projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
    }
    panel.fireChangeEvent();
  }
}
 

Example 24

From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.

Source file: DefaultTableView.java

  31 
vote

/** 
 * import data values from binary file.
 */
private void importBinaryData(){
  String currentDir=dataset.getFileFormat().getParent();
  JFileChooser fchooser=new JFileChooser(currentDir);
  fchooser.setFileFilter(DefaultFileFilter.getFileFilterBinary());
  int returnVal=fchooser.showOpenDialog(this);
  if (returnVal != JFileChooser.APPROVE_OPTION) {
    return;
  }
  File choosedFile=fchooser.getSelectedFile();
  if (choosedFile == null) {
    return;
  }
  String fname=choosedFile.getAbsolutePath();
  int pasteDataFlag=JOptionPane.showConfirmDialog(this,"Do you want to paste selected data ?",this.getTitle(),JOptionPane.YES_NO_OPTION);
  if (pasteDataFlag == JOptionPane.NO_OPTION) {
    return;
  }
  getBinaryDatafromFile(fname);
}
 

Example 25

From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/userlib/.

Source file: ImportClassAction.java

  31 
vote

public void actionPerformed(ActionEvent event){
  super.actionPerformed(event);
  NamedObj target=getTarget();
  if (target instanceof EntityLibrary) {
    EntityLibrary lib=(EntityLibrary)target;
    File actorFile=null;
    JFileChooser fileChooser=new JFileChooser();
    fileChooser.setDialogTitle("Import shared actor from...");
    fileChooser.setCurrentDirectory(EnvironmentUtils.getUserRelevantDirectory());
    fileChooser.setAccessory(new FinderAccessory(fileChooser));
    fileChooser.addChoosableFileFilter(new ExtensionFileFilter(new String[]{"xml","moml"},"Passerelle model files"));
    int returnVal=fileChooser.showOpenDialog(panel);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      actorFile=fileChooser.getSelectedFile();
      if (logger.isInfoEnabled())       logger.info("Importing actor in Library " + lib.getFullName() + " from "+ actorFile.getPath());
      EnvironmentUtils.setLastSelectedDirectory(fileChooser.getCurrentDirectory());
      MoMLParser parser=new MoMLParser();
      try {
        Entity e=(Entity)parser.parse(null,actorFile.toURL());
        panel.getLibraryManager().saveEntityInLibrary(lib,e);
      }
 catch (      Exception e) {
        MessageHandler.error("Failed to load actor",e);
      }
    }
  }
 else {
    MessageHandler.error("Selected item is not an actor library");
  }
}
 

Example 26

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/.

Source file: LogBrokerMonitor.java

  31 
vote

/** 
 * Uses a JFileChooser to select a file to opened with the LF5 GUI.
 */
protected void requestOpen(){
  JFileChooser chooser;
  if (_fileLocation == null) {
    chooser=new JFileChooser();
  }
 else {
    chooser=new JFileChooser(_fileLocation);
  }
  int returnVal=chooser.showOpenDialog(_logMonitorFrame);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    if (loadLogFile(f)) {
      _fileLocation=chooser.getSelectedFile();
      _mruFileManager.set(f);
      updateMRUList();
    }
  }
}
 

Example 27

From project dolphin, under directory /texcel/svn/com/tan/util/.

Source file: TanUtil.java

  31 
vote

/** 
 * Chose the directory.
 * @param dir	default directory.
 * @param title	Dialog title.
 * @return
 */
public static File chooseDir(final String dir,final String title){
  Component parent=null;
  JFileChooser chooser=new JFileChooser(dir);
  chooser.setDialogTitle(title);
  javax.swing.filechooser.FileFilter dirFilter=new javax.swing.filechooser.FileFilter(){
    public boolean accept(    File f){
      return f.isDirectory();
    }
    public String getDescription(){
      return "";
    }
  }
;
  chooser.setFileFilter(dirFilter);
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  if (chooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
    return chooser.getSelectedFile();
  }
  return null;
}
 

Example 28

From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/.

Source file: FileDialog.java

  31 
vote

public FileDialog(Component frame,String[][] extension,String[] description){
  d_frame=frame;
  d_fileChooser=new JFileChooser();
  Filter defaultFilter=null;
  for (int i=0; i < extension.length; i++) {
    Filter filter=new Filter(extension[i],description[i]);
    d_fileChooser.addChoosableFileFilter(filter);
    if (i == 0) {
      defaultFilter=filter;
    }
  }
  d_fileChooser.setFileFilter(defaultFilter);
  if (d_currentDirectory != null)   d_fileChooser.setCurrentDirectory(d_currentDirectory);
}
 

Example 29

From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/controller/file/.

Source file: OpenProjectCommand.java

  31 
vote

/** 
 * Choose and open a project.
 */
@Override public final void execute(final INotification notification){
  FileProxy fileProxy=(FileProxy)getFacade().retrieveProxy(FileProxy.NAME);
  JFileChooser fileChooser=fileProxy.getFileChooser();
  JFrame frame=fileProxy.getDialogParent();
  fileChooser.resetChoosableFileFilters();
  FileNameExtensionFilter filter=new FileNameExtensionFilter("Project XML Files","xml");
  fileChooser.setFileFilter(filter);
  int returnValue=fileChooser.showOpenDialog(frame);
  if (returnValue == JFileChooser.APPROVE_OPTION) {
    fileProxy.setFile(fileChooser.getSelectedFile());
    System.out.println("OpenProjectCommand.execute() File opened: " + fileProxy.getFile().getName());
  }
 else {
    return;
  }
  DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
  try {
    DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();
    parseXML(docBuilder,fileProxy.getFile());
  }
 catch (  ParserConfigurationException exception) {
    showMessage("OpenProjectCommand.execute() ParserConfigurationException: " + exception.getMessage());
  }
}
 

Example 30

From project Gmote, under directory /gmoteserver/src/org/gmote/server/.

Source file: MediaPathChooserUi.java

  31 
vote

/** 
 * This method initializes cmdAddPath	
 * @return javax.swing.JButton	
 */
private JButton getCmdAddPath(){
  if (cmdAddPath == null) {
    cmdAddPath=new JButton();
    cmdAddPath.setText("    Add path    ");
    cmdAddPath.addActionListener(new java.awt.event.ActionListener(){
      public void actionPerformed(      java.awt.event.ActionEvent e){
        JFileChooser fc=new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal=fc.showOpenDialog(getRightButtonPanel());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
          BaseMediaPaths.getInstance().addPath(fc.getSelectedFile().getAbsolutePath());
          loadBasePaths();
        }
      }
    }
);
  }
  return cmdAddPath;
}
 

Example 31

From project hanoitowers-piqle, under directory /src/agents/.

Source file: AbstractAgent.java

  31 
vote

public void saveAgent(){
  JFileChooser chooser=new JFileChooser();
  chooser.setCurrentDirectory(new File("."));
  File sauvegarde;
  ObjectOutputStream sortie;
  String ext[]={"agt"};
  ExtensionFileFilter filter=new ExtensionFileFilter(ext);
  filter.setDescription("Agent file");
  chooser.setFileFilter(filter);
  int returnVal=chooser.showSaveDialog(null);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
    sauvegarde=chooser.getSelectedFile();
  }
 else {
    sauvegarde=new File("raymond.agt");
  }
  try {
    sortie=new ObjectOutputStream(new FileOutputStream(sauvegarde));
    sortie.writeObject(this);
    sortie.close();
  }
 catch (  Exception e) {
    System.err.println("Problem when trying to save agent " + e.getMessage());
  }
}
 

Example 32

From project hecl, under directory /heclbuilder/org/hecl/heclbuilder/.

Source file: HeclBuilderGui.java

  31 
vote

private void selectScriptButtonActionPerformed(java.awt.event.ActionEvent evt){
  scriptFileChooser=new JFileChooser(System.getProperty("user.dir"));
  scriptFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  int retval=scriptFileChooser.showOpenDialog(this);
  if (retval == JFileChooser.APPROVE_OPTION) {
    File file=scriptFileChooser.getSelectedFile();
    scriptTextField.setText(file.toString());
  }
}
 

Example 33

From project Holo-Edit, under directory /algo/.

Source file: Example.java

  31 
vote

public Example(GestionPistes gp){
  super(gp,TYPE_TRANS_ATOB,"example","Example","...");
  addField(new Field("Apply To",Param.TYPE_COMBO,0,"applyTo"));
  addField(new Field("Input track n" + Ut.numCar,Param.TYPE_COMBO,1));
  addField(new Field("Output track n" + Ut.numCar,Param.TYPE_COMBO,2));
  addField(new Field("Test Integer",25));
  addField(new Field("Test Float",25f));
  addField(new Field("Min/Max/Mod Float",Param.TYPE_FLOAT,25f,0,100,25));
  addField(new Field("Test Double",25.));
  addField(new Field("Test Text","testing..."));
  addField(new Field("Test Check",false));
  addField(new Field("Test Button",Param.TYPE_BUTTON,"Choose",new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      JFileChooser jfc=new JFileChooser();
      jfc.showOpenDialog(null);
      selectedFile=jfc.getSelectedFile();
      ((ButtonParam)e.getSource()).setText("Ok");
    }
  }
));
  setCategory("Dev. Example");
}
 

Example 34

From project jgraphx, under directory /examples/com/mxgraph/examples/swing/editor/.

Source file: EditorActions.java

  31 
vote

/** 
 */
public void actionPerformed(ActionEvent e){
  BasicGraphEditor editor=getEditor(e);
  if (editor != null) {
    String wd=(lastDir != null) ? lastDir : System.getProperty("user.dir");
    JFileChooser fc=new JFileChooser(wd);
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.addChoosableFileFilter(new DefaultFileFilter(".shape","Dia Shape " + mxResources.get("file") + " (.shape)"));
    int rc=fc.showDialog(null,mxResources.get("importStencil"));
    if (rc == JFileChooser.APPROVE_OPTION) {
      lastDir=fc.getSelectedFile().getParent();
      try {
        if (fc.getSelectedFile().isDirectory()) {
          EditorPalette palette=editor.insertPalette(fc.getSelectedFile().getName());
          for (          File f : fc.getSelectedFile().listFiles(new FilenameFilter(){
            public boolean accept(            File dir,            String name){
              return name.toLowerCase().endsWith(".shape");
            }
          }
)) {
            String nodeXml=mxUtils.readFile(f.getAbsolutePath());
            addStencilShape(palette,nodeXml,f.getParent() + File.separator);
          }
          JComponent scrollPane=(JComponent)palette.getParent().getParent();
          editor.getLibraryPane().setSelectedComponent(scrollPane);
        }
 else {
          String nodeXml=mxUtils.readFile(fc.getSelectedFile().getAbsolutePath());
          String name=addStencilShape(null,nodeXml,null);
          JOptionPane.showMessageDialog(editor,mxResources.get("stencilImported",new String[]{name}));
        }
      }
 catch (      IOException e1) {
        e1.printStackTrace();
      }
    }
  }
}
 

Example 35

From project jlac, under directory /src/org/sump/analyzer/devices/.

Source file: Hp16500DeviceController.java

  31 
vote

/** 
 * Return the device data of the last successful run.
 * @return device data
 */
public CapturedData getDeviceData(Component parent){
  if ((rawData != null) && (parent != null)) {
    if (JOptionPane.showConfirmDialog(parent,"store a RAW dump file instead ?","No decoder found!",JOptionPane.YES_NO_OPTION,JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) {
      JFileChooser dumpFileChooser=new JFileChooser();
      if (dumpFileChooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
        File file=dumpFileChooser.getSelectedFile();
        try {
          FileOutputStream os=new FileOutputStream(file);
          os.write(rawData);
          os.flush();
          os.close();
        }
 catch (        Exception ex) {
          ex.printStackTrace();
        }
      }
    }
    rawData=null;
  }
  return capturedData;
}
 

Example 36

From project jMemorize, under directory /src/jmemorize/gui/swing/actions/file/.

Source file: AbstractExportAction.java

  31 
vote

/** 
 * Displays a Save As or Export dialog, and to confirm overwrites, and to attach specified file extension.
 * @return the file path or <code>null</code> if the dialog was cancelled.
 * @author Perry (elsapo)
 * @author djemili
 */
public static File showSaveDialog(JFrame frame,ExtensionFileFilter fileFilter){
  JFileChooser chooser=new JFileChooser();
  try {
    chooser.setCurrentDirectory(Settings.loadLastDirectory());
  }
 catch (  Exception ioe) {
    Main.logThrowable("Could not load last directory",ioe);
    chooser.setCurrentDirectory(null);
  }
  chooser.setFileFilter(fileFilter);
  while (true) {
    int choice=chooser.showSaveDialog(frame);
    if (choice != JFileChooser.APPROVE_OPTION)     return null;
    File file=chooser.getSelectedFile();
    String extension=fileFilter.getExtension();
    if (extension.length() > 0 && !file.getName().endsWith(extension)) {
      file=new File(file.getAbsolutePath() + '.' + extension);
      chooser.setSelectedFile(file);
    }
    if (file.exists()) {
      String text=Localization.get("MainFrame.CONFIRM_OVERWRITE");
      String title=Localization.get("MainFrame.CONFIRM_OVERWRITE_TITLE");
      int act=JOptionPane.showConfirmDialog(frame,text + " " + file.toString(),title,JOptionPane.YES_NO_OPTION);
      if (act == JOptionPane.NO_OPTION)       continue;
    }
    Settings.storeLastDirectory(file);
    return file;
  }
}
 

Example 37

From project jninka, under directory /jninka-parent/jninka-gui/src/main/java/org/whitesource/jninka/gui/.

Source file: AgentPresenter.java

  31 
vote

private JFileChooser getFileChooser(){
  fileDialog=new JFileChooser(lastFile);
  FileFilter filter=new FileNameExtensionFilter("XML","xml");
  fileDialog.setFileFilter(filter);
  fileDialog.setFileSelectionMode(JFileChooser.SAVE_DIALOG);
  return fileDialog;
}
 

Example 38

From project joshua, under directory /src/joshua/ui/tree_visualizer/browser/.

Source file: FileChoiceListener.java

  31 
vote

/** 
 * The constructor. Also automatically registers <code>this</code> as an action listener for each button.
 * @param enclosingFrame the main Browser frame
 * @param source menu item for choosing new source files
 * @param reference menu item for choosing new reference files
 * @param nBest menu item for choosing new n-best translation files
 */
public FileChoiceListener(JFrame enclosingFrame,JMenuItem source,JMenuItem reference,JMenuItem nBest){
  this.enclosingFrame=enclosingFrame;
  this.src=source;
  this.ref=reference;
  this.nBest=nBest;
  this.fileChooser=new JFileChooser();
  src.addActionListener(this);
  ref.addActionListener(this);
  this.nBest.addActionListener(this);
}
 

Example 39

From project JSocksProxy, under directory /src/main/java/nu/najt/kecon/jsocksproxy/admin/.

Source file: JSocksProxyAdmin.java

  31 
vote

@Override public void run(){
  while (!this.loadConfiguration(this.configurationFileLocation)) {
    JOptionPane.showMessageDialog(this,this.resourceBundle.getString("dialog.loadFailed"),this.resourceBundle.getString("dialog.loadFailed.title"),JOptionPane.ERROR_MESSAGE);
    final JFileChooser fileChooser=new JFileChooser(this.configurationFileLocation.getParentFile());
class CustomFileFilter extends FileFilter {
      @Override public boolean accept(      final File path){
        if ((path != null) && path.getName().equalsIgnoreCase(JSocksProxy.CONFIGURATION_XML) && path.isFile()) {
          return true;
        }
 else         if ((path != null) && path.isDirectory()) {
          return true;
        }
        return false;
      }
      @Override public String getDescription(){
        return JSocksProxy.CONFIGURATION_XML;
      }
    }
    fileChooser.addChoosableFileFilter(new CustomFileFilter());
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      final File selectedFile=fileChooser.getSelectedFile();
      if (selectedFile != null) {
        this.configurationFileLocation=selectedFile;
      }
    }
 else {
      this.dispose();
      return;
    }
  }
  this.setVisible(true);
}
 

Example 40

From project kabeja, under directory /blocks/ui/src/main/java/org/kabeja/ui/impl/.

Source file: OpenProcessingAction.java

  31 
vote

protected void openProcessing(){
  JFileChooser fc=new JFileChooser(this.baseDir);
  fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
  int value=fc.showOpenDialog(null);
  if (value == JFileChooser.APPROVE_OPTION) {
    File file=fc.getSelectedFile();
    try {
      ProcessingManager m=SAXProcessingManagerBuilder.buildFromStream(new FileInputStream(file));
      container.setProcessingManager(m);
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
  }
}
 

Example 41

From project log4jna, under directory /thirdparty/log4j/src/main/java/org/apache/log4j/lf5/viewer/.

Source file: LogBrokerMonitor.java

  31 
vote

/** 
 * Uses a JFileChooser to select a file to opened with the LF5 GUI.
 */
protected void requestOpen(){
  JFileChooser chooser;
  if (_fileLocation == null) {
    chooser=new JFileChooser();
  }
 else {
    chooser=new JFileChooser(_fileLocation);
  }
  int returnVal=chooser.showOpenDialog(_logMonitorFrame);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    if (loadLogFile(f)) {
      _fileLocation=chooser.getSelectedFile();
      _mruFileManager.set(f);
      updateMRUList();
    }
  }
}
 

Example 42

From project maple-ide, under directory /core/preproc/demo/.

Source file: PApplet.java

  31 
vote

/** 
 * Open a platform-specific folder chooser dialog.
 * @param prompt Mesage to show the user when prompting for a file.
 * @return full path to the selected folder, or null if no selection.
 */
public String selectFolder(final String prompt){
  checkParentFrame();
  try {
    SwingUtilities.invokeAndWait(new Runnable(){
      public void run(){
        if (platform == MACOSX) {
          FileDialog fileDialog=new FileDialog(parentFrame,prompt,FileDialog.LOAD);
          System.setProperty("apple.awt.fileDialogForDirectories","true");
          fileDialog.setVisible(true);
          System.setProperty("apple.awt.fileDialogForDirectories","false");
          String filename=fileDialog.getFile();
          selectedFile=(filename == null) ? null : new File(fileDialog.getDirectory(),fileDialog.getFile());
        }
 else {
          JFileChooser fileChooser=new JFileChooser();
          fileChooser.setDialogTitle(prompt);
          fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          int returned=fileChooser.showOpenDialog(parentFrame);
          System.out.println(returned);
          if (returned == JFileChooser.CANCEL_OPTION) {
            selectedFile=null;
          }
 else {
            selectedFile=fileChooser.getSelectedFile();
          }
        }
      }
    }
);
    return (selectedFile == null) ? null : selectedFile.getAbsolutePath();
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}
 

Example 43

From project medsavant, under directory /medsavant/MedSavantClient/src/org/ut/biolab/medsavant/view/dialog/.

Source file: SavantExportForm.java

  31 
vote

private void chooseFileButtonActionPerformed(java.awt.event.ActionEvent evt){
  JFileChooser fc=new JFileChooser();
  fc.setDialogTitle("Save Savant Project");
  fc.setDialogType(JFileChooser.SAVE_DIALOG);
  fc.addChoosableFileFilter(new ExtensionsFileFilter("svp"));
  fc.setMultiSelectionEnabled(false);
  int result=fc.showDialog(null,null);
  if (result == JFileChooser.CANCEL_OPTION || result == JFileChooser.ERROR_OPTION) {
    return;
  }
  outputFile=fc.getSelectedFile();
  String path=outputFile.getAbsolutePath();
  outputFileField.setText(path);
  exportButton.setEnabled(true);
}
 

Example 44

From project mididuino, under directory /editor/core/src/processing/core/.

Source file: PApplet.java

  31 
vote

/** 
 * Open a platform-specific folder chooser dialog.
 * @param prompt Mesage to show the user when prompting for a file.
 * @return full path to the selected folder, or null if no selection.
 */
public String selectFolder(final String prompt){
  checkParentFrame();
  try {
    SwingUtilities.invokeAndWait(new Runnable(){
      public void run(){
        if (platform == MACOSX) {
          FileDialog fileDialog=new FileDialog(parentFrame,prompt,FileDialog.LOAD);
          System.setProperty("apple.awt.fileDialogForDirectories","true");
          fileDialog.setVisible(true);
          System.setProperty("apple.awt.fileDialogForDirectories","false");
          String filename=fileDialog.getFile();
          selectedFile=(filename == null) ? null : new File(fileDialog.getDirectory(),fileDialog.getFile());
        }
 else {
          JFileChooser fileChooser=new JFileChooser();
          fileChooser.setDialogTitle(prompt);
          fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          int returned=fileChooser.showOpenDialog(parentFrame);
          System.out.println(returned);
          if (returned == JFileChooser.CANCEL_OPTION) {
            selectedFile=null;
          }
 else {
            selectedFile=fileChooser.getSelectedFile();
          }
        }
      }
    }
);
    return (selectedFile == null) ? null : selectedFile.getAbsolutePath();
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}
 

Example 45

From project milton, under directory /milton/milton-caldav/src/main/java/info/ineighborhood/cardme/engine/.

Source file: TestParser.java

  31 
vote

/** 
 * <p>Opens a file chooser dialog to select VCard files.</p>
 * @return {@link File}[]
 */
private File[] getFiles(){
  JFileChooser chooser=new JFileChooser();
  chooser.setDialogTitle("Select VCards");
  chooser.setCurrentDirectory(new File(System.getProperties().getProperty("user.home")));
  chooser.setMultiSelectionEnabled(true);
  chooser.setFileFilter(new javax.swing.filechooser.FileFilter(){
    @Override public boolean accept(    File f){
      return f.getName().toLowerCase().endsWith(".vcf") || f.isDirectory();
    }
    public @Override String getDescription(){
      return "VCard Files";
    }
  }
);
  int result=chooser.showOpenDialog(null);
  if (result == JFileChooser.CANCEL_OPTION) {
    return null;
  }
  try {
    File[] files=chooser.getSelectedFiles();
    return files;
  }
 catch (  Exception ex) {
    JOptionPane.showMessageDialog(null,"Warning! Could not load the file(s)!","Warning!",JOptionPane.WARNING_MESSAGE);
    return null;
  }
}
 

Example 46

From project milton2, under directory /external/cardme/src/main/java/info/ineighborhood/cardme/engine/.

Source file: TestParser.java

  31 
vote

/** 
 * <p>Opens a file chooser dialog to select VCard files.</p>
 * @return {@link File}[]
 */
private File[] getFiles(){
  JFileChooser chooser=new JFileChooser();
  chooser.setDialogTitle("Select VCards");
  chooser.setCurrentDirectory(new File(System.getProperties().getProperty("user.home")));
  chooser.setMultiSelectionEnabled(true);
  chooser.setFileFilter(new javax.swing.filechooser.FileFilter(){
    @Override public boolean accept(    File f){
      return f.getName().toLowerCase().endsWith(".vcf") || f.isDirectory();
    }
    public @Override String getDescription(){
      return "VCard Files";
    }
  }
);
  int result=chooser.showOpenDialog(null);
  if (result == JFileChooser.CANCEL_OPTION) {
    return null;
  }
  try {
    File[] files=chooser.getSelectedFiles();
    return files;
  }
 catch (  Exception ex) {
    JOptionPane.showMessageDialog(null,"Warning! Could not load the file(s)!","Warning!",JOptionPane.WARNING_MESSAGE);
    return null;
  }
}
 

Example 47

From project etherpad, under directory /infrastructure/rhino1_7R1/toolsrc/org/mozilla/javascript/tools/shell/.

Source file: JSConsole.java

  30 
vote

public void createFileChooser(){
  dlg=new JFileChooser();
  javax.swing.filechooser.FileFilter filter=new javax.swing.filechooser.FileFilter(){
    public boolean accept(    File f){
      if (f.isDirectory()) {
        return true;
      }
      String name=f.getName();
      int i=name.lastIndexOf('.');
      if (i > 0 && i < name.length() - 1) {
        String ext=name.substring(i + 1).toLowerCase();
        if (ext.equals("js")) {
          return true;
        }
      }
      return false;
    }
    public String getDescription(){
      return "JavaScript Files (*.js)";
    }
  }
;
  dlg.addChoosableFileFilter(filter);
}
 

Example 48

From project formic, under directory /src/java/org/formic/wizard/form/gui/component/.

Source file: FileChooser.java

  30 
vote

/** 
 * Creates a new instance.
 */
public FileChooser(int selectionMode,String choosable){
  super(new BorderLayout());
  chooser=new JFileChooser(){
    private static final long serialVersionUID=1L;
    protected boolean processKeyBinding(    KeyStroke key,    KeyEvent event,    int condition,    boolean pressed){
      if (event.getKeyCode() == KeyEvent.VK_ENTER) {
        Component focusOwner=KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (focusOwner instanceof JButton) {
          ((JButton)focusOwner).doClick();
          return true;
        }
      }
      return super.processKeyBinding(key,event,condition,pressed);
    }
  }
;
  chooser.setFileSelectionMode(selectionMode);
  addChoosableFileFilters(choosable);
  textField=new JTextField();
  button=new JButton(Installer.getString("browse.text"));
  button.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent event){
      int result=chooser.showOpenDialog(getParent());
      if (result == JFileChooser.APPROVE_OPTION) {
        textField.setText(chooser.getSelectedFile().getPath());
        textField.requestFocus();
      }
    }
  }
);
  add(textField,BorderLayout.CENTER);
  add(button,BorderLayout.EAST);
}
 

Example 49

From project GenericKnimeNodes, under directory /com.genericworkflownodes.knime.base_plugin/src/com/genericworkflownodes/knime/nodes/io/listimporter/.

Source file: DialogComponentMultiFileChooser.java

  30 
vote

/** 
 * C'tor.
 * @param model The model to store the files.
 */
public DialogComponentMultiFileChooser(SettingsModelStringArray model){
  super(model);
  chooser=new JFileChooser();
  chooser.setMultiSelectionEnabled(true);
  SpringLayout springLayout=new SpringLayout();
  getComponentPanel().setLayout(springLayout);
  listbox=new JList(new FileListModel(model));
  listbox.setLayoutOrientation(JList.VERTICAL);
  listbox.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
  listbox.setVisibleRowCount(-1);
  JScrollPane listScroller=new JScrollPane(listbox);
  listScroller.setPreferredSize(new Dimension(SCROLLPANE_WIDTH,SCROLL_PANE_HEIGHT));
  getComponentPanel().add(listScroller);
  addButton=new JButton("Add");
  removeButton=new JButton("Remove");
  clearButton=new JButton("Clear");
  getComponentPanel().add(addButton);
  getComponentPanel().add(removeButton);
  getComponentPanel().add(clearButton);
  setupLayout(springLayout,listScroller);
  addListeners();
}
 

Example 50

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: Main.java

  29 
vote

public int fileLoadActions(){
  final boolean[] loaded={false};
  FileLoadDialog d=new FileLoadDialog(s_window,new String[][]{{"addis","xml"},{"addis"},{"xml"}},new String[]{"ADDIS or legacy XML files","ADDIS data files","ADDIS legacy XML files"}){
    @Override public void doAction(    String path,    String extension){
      loaded[0]=loadDomainFromFile(path);
    }
  }
;
  d.loadActions();
  return loaded[0] ? d.getReturnValue() : JFileChooser.ERROR_OPTION;
}
 

Example 51

From project ANNIS, under directory /annis-kickstarter/src/main/java/de/hu_berlin/german/korpling/annis/kickstarter/.

Source file: ImportDialog.java

  29 
vote

private void btSearchInputDirActionPerformed(java.awt.event.ActionEvent evt){
  if (!"".equals(txtInputDir.getText())) {
    File dir=new File(txtInputDir.getText());
    if (dir.exists() && dir.isDirectory()) {
      fileChooser.setSelectedFile(dir);
    }
  }
  if (fileChooser.showDialog(this,"Select") == JFileChooser.APPROVE_OPTION) {
    File f=fileChooser.getSelectedFile();
    txtInputDir.setText(f.getAbsolutePath());
    storeProperties();
  }
}
 

Example 52

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/spok/.

Source file: SpokFileFilter.java

  29 
vote

public static void addChoosableFileFilters(JFileChooser chooser){
  SpokFileFilter txtFilter=new SpokFileFilter(SpokFileFilter.txt,"Golm-DataSet");
  chooser.addChoosableFileFilter(txtFilter);
  SpokFileFilter jdxFilter=new SpokFileFilter(SpokFileFilter.jdx,"JCamp-DX Files");
  chooser.addChoosableFileFilter(jdxFilter);
  SpokFileFilter cmlFilter=new SpokFileFilter(SpokFileFilter.cml,"Chemical Markup Language Files");
  chooser.addChoosableFileFilter(cmlFilter);
}
 

Example 53

From project eclim, under directory /org.eclim.installer/java/org/eclim/installer/step/.

Source file: EclipseStep.java

  29 
vote

/** 
 * {@inheritDoc}
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init(){
  final JPanel panel=new JPanel(new MigLayout("wrap 2, fillx","[growprio 0] [fill]"));
  GuiForm form=createForm();
  String home=fieldName("home");
  eclipseHomeChooser=new FileChooser(JFileChooser.DIRECTORIES_ONLY);
  panel.add(form.createMessagePanel(),"span");
  panel.add(new JLabel(Installer.getString(home)));
  panel.add(eclipseHomeChooser);
  form.bind(home,eclipseHomeChooser.getTextField(),new ValidatorBuilder().required().isDirectory().validator(new EclipseHomeValidator()).validator());
  String eclipseHomeDefault=getDefaultEclipseHome();
  eclipseHomeChooser.getTextField().setText(eclipseHomeDefault);
  return panel;
}
 

Example 54

From project GraphWalker, under directory /src/main/java/org/graphwalker/GUI/.

Source file: App.java

  29 
vote

private void load(){
  status.setStopped();
  statusBar.setMessage("Stopped");
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  FileNameExtensionFilter filter=new FileNameExtensionFilter("XML files","xml");
  fileChooser.setFileFilter(filter);
  int returnVal=fileChooser.showOpenDialog(getContentPane());
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    xmlFile=fileChooser.getSelectedFile();
    logger.debug("Got file: " + xmlFile.getAbsolutePath());
    loadModel();
    if (appEvent != null) {
      appEvent.getLoadEvent();
    }
  }
}
 

Example 55

From project jchempaint, under directory /src/main/org/openscience/jchempaint/io/.

Source file: JCPExportFileFilter.java

  29 
vote

/** 
 * Adds the JCPFileFilter to the JFileChooser object.
 */
public static void addChoosableFileFilters(JFileChooser chooser){
  chooser.addChoosableFileFilter(new JCPExportFileFilter(JCPExportFileFilter.svg));
  chooser.addChoosableFileFilter(new JCPExportFileFilter(JCPExportFileFilter.png));
  chooser.addChoosableFileFilter(new JCPExportFileFilter(JCPExportFileFilter.bmp));
  chooser.addChoosableFileFilter(new JCPExportFileFilter(JCPExportFileFilter.jpg));
}
 

Example 56

From project jreepad, under directory /src/jreepad/.

Source file: JreepadViewer.java

  29 
vote

private void openAction(){
  if (!askAndSave(lang.getString("PROMPT_SAVE_BEFORE_OPEN")))   return;
  fileChooser.setCurrentDirectory(getPrefs().openLocation);
  if (fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)   return;
  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  openFile(fileChooser.getSelectedFile());
  setCursor(Cursor.getDefaultCursor());
  updateUndoRedoMenuState();
}
 

Example 57

From project jreversepro, under directory /src/main/java/org/jreversepro/gui/.

Source file: CustomFileChooser.java

  29 
vote

/** 
 * @param aDir Default Directory of the File Chooser.
 * @param aDescription Description of the extension aExtension
 * @param aExtension Extension of the file
 * @param aToolTipText Tooltip text used when viewing file.
 */
public CustomFileChooser(String aDir,String aDescription,String aExtension,String aToolTipText){
  super(aDir);
  mFileExtension=aExtension;
  mFileDescription=aDescription;
  setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  setFileFilter(new CustomFileFilter());
  setApproveButtonToolTipText(aToolTipText);
}
 

Example 58

From project jupload, under directory /src/wjhk/jupload2/gui/.

Source file: JUploadFileChooser.java

  29 
vote

/** 
 * The 'standard' constructor for our file chooser
 * @param uploadPolicyParam
 */
public JUploadFileChooser(UploadPolicy uploadPolicyParam){
  this.uploadPolicy=uploadPolicyParam;
  this.fileFilter=new JUploadFileFilter(this.uploadPolicy);
  this.fileView=new JUploadFileView(this.uploadPolicy,this);
  setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  setMultiSelectionEnabled(true);
  setFileView(this.fileView);
  if (this.uploadPolicy.fileFilterGetDescription() != null) {
    setFileFilter(this.fileFilter);
    setAcceptAllFileFilterUsed(false);
  }
}
 

Example 59

From project LateralGM, under directory /org/lateralgm/components/visual/.

Source file: FileChooserImagePreview.java

  29 
vote

public void propertyChange(PropertyChangeEvent e){
  if (e.getPropertyName() == JFileChooser.SELECTED_FILE_CHANGED_PROPERTY) {
    if (isShowing()) {
      File f=(File)e.getNewValue();
      if (f == null)       prev=null;
 else {
        BufferedImage img=null;
        try {
          img=ImageIO.read(f);
        }
 catch (        Throwable t) {
        }
        if (img != null) {
          if (img.getWidth() > WIDTH && img.getHeight() > HEIGHT) {
            prev=new ImageIcon(img.getScaledInstance(img.getWidth() >= img.getHeight() ? WIDTH : -1,img.getHeight() > img.getWidth() ? HEIGHT : -1,Image.SCALE_FAST));
          }
 else           if (img.getWidth() > WIDTH || img.getHeight() > HEIGHT) {
            prev=new ImageIcon(img.getScaledInstance(img.getWidth() > WIDTH ? WIDTH : -1,img.getHeight() > HEIGHT ? HEIGHT : -1,Image.SCALE_FAST));
          }
 else           prev=new ImageIcon(img);
        }
 else         prev=null;
      }
      setIcon(prev);
    }
  }
}