Package javax.swing.filechooser

Examples of javax.swing.filechooser.FileFilter


          chooser=new JFileChooser();
          chooser.setAcceptAllFileFilterUsed(false); // don't want all
          filters=new HashMap();
        }
        final int r=i;
        FileFilter ff=new FileFilter(){
         
          public boolean accept(File f) {
            if (f.isDirectory())
              return true;
            String name = f.getName();
View Full Code Here


    private static JFileChooser createChooser() {
        JFileChooser chooser = new JFileChooser();
        // to prevent a deadlock (using Java6) make a copy of the File
        chooser.setCurrentDirectory(new File(CurrentPathProvider.currentPathProvider.getCurrentPath().getAbsolutePath()));
        chooser.setFileFilter(new FileFilter() {
            @Override
            public boolean accept(File f) {
                if (f.isDirectory())
                    return true;
                return f.getName().endsWith(JAVA_3D_FILE_EXT);
View Full Code Here

        }

        public void updateFileChooserAccessory(){
            removeAll();

            FileFilter filter = null;
            if (action == Plugin.OPEN) {
                filter =  openFileChooser.getFileFilter();

            } else if (action == Plugin.SAVE) {
                filter =  saveFileChooser.getFileFilter();
View Full Code Here

    /** Do a previously declared action */
    public void doAction(Object action) {
        if (action.equals("Load file")) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new FileFilter() {
                public boolean accept(File f) {
                    if (f.isDirectory()) return true;
                    String name = f.getName();
                    return name.toLowerCase().endsWith(".xyz");
                }
View Full Code Here

            return null;
        }
        CurrentPathProvider.currentPathProvider.setCurrentPath(fileChooser.getCurrentDirectory());


        FileFilter currentFileFilter =  fileChooser.getFileFilter();
        if (currentFileFilter instanceof AggregateFileFilter) {
            currentFileFilter = ((AggregateFileFilter) currentFileFilter).getFilterForFile(getOwner(), fileChooser
                    .getSelectedFile());
            if (currentFileFilter == null) {
                return null;
View Full Code Here

                            chooser.setCurrentDirectory(jsynoptic.ui.JSynoptic.gui.getPath());
                            chooser.setAcceptAllFileFilterUsed(false); // don't want all
                            filters=new HashMap<FileFilter, String>();
                        }
                        final int r=i;
                        FileFilter ff=new FileFilter(){
                           
                            public boolean accept(File f) {
                                if (f.isDirectory())
                                    return true;
                                String name = f.getName();
View Full Code Here

            if(chooser==null||filters==null
                    ||chooser.showOpenDialog(null)!=JFileChooser.APPROVE_OPTION){
                return false;
            }
            File f=chooser.getSelectedFile();
            FileFilter ff=chooser.getFileFilter();
            if(ff==aggregateFilter){
                ff=aggregateFilter.getFilterForFile(null, f);
            }
            String ext=(String)filters.get(ff);
            if(ext==null){
View Full Code Here

      int rc = chooser.showSaveDialog(SimpleMixer.this);

      if (rc == JFileChooser.APPROVE_OPTION) {
    trackFile = chooser.getSelectedFile();
    FileFilter ff = chooser.getFileFilter();
    if (ff instanceof ExtensionFilter) {
        ExtensionFilter xff =
            (ExtensionFilter) chooser.getFileFilter();
              trackModel.write(xff, trackFile);
    } else { // generate default MIX file
View Full Code Here

                fd.setMultiSelectionEnabled( false );
                fd.setCurrentDirectory( new File( "." ) );
                fd.setDialogTitle( DemoApp.getRes().getString( "Select Executable for customization" ) );
                fd.setFileHidingEnabled( true );
                fd.setApproveButtonText( DemoApp.getRes().getString( "Load Executable" ) );
                FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Wrapper Executable (*.exe)" ), new String[] { "exe" } );
                fd.setFileFilter( filter );
                int returnVal = fd.showOpenDialog( CustomizeDialog.this );

                if ( returnVal == JFileChooser.APPROVE_OPTION )
                {
                    try
                    {
                        selectedSource = fd.getSelectedFile().getCanonicalPath();
                        jTextField1.setText( selectedSource );
                    }
                    catch ( IOException e1 )
                    {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        } );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        jPanel1.add( jButton1, gridBagConstraints );

        jButton2.setText( "..." );
        jButton2.addActionListener( new ActionListener()
        {
            public void actionPerformed( ActionEvent e )
            {
                JFileChooser fd = new JFileChooser();
                fd.setMultiSelectionEnabled( false );
                fd.setCurrentDirectory( new File( "." ) );
                fd.setDialogTitle( DemoApp.getRes().getString( "Select Icon for customization" ) );
                fd.setFileHidingEnabled( true );
                fd.setApproveButtonText( DemoApp.getRes().getString( "Load Icon" ) );
                FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Icon File (*.ico)" ), new String[] { "ico" } );
                fd.setFileFilter( filter );
                int returnVal = fd.showOpenDialog( CustomizeDialog.this );

                if ( returnVal == JFileChooser.APPROVE_OPTION )
                {
                    try
                    {
                        selectedIcon = fd.getSelectedFile().getCanonicalPath();
                        jTextField2.setText( selectedIcon );
                    }
                    catch ( IOException e1 )
                    {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        } );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        jPanel1.add( jButton2, gridBagConstraints );

        jButton3.setText( "..." );
        jButton3.addActionListener( new ActionListener()
        {
            public void actionPerformed( ActionEvent e )
            {
                JFileChooser fd = new JFileChooser();
                fd.setMultiSelectionEnabled( false );
                fd.setCurrentDirectory( new File( "." ) );
                fd.setDialogTitle( DemoApp.getRes().getString( "Select splash screen for customization" ) );
                fd.setFileHidingEnabled( true );
                fd.setApproveButtonText( DemoApp.getRes().getString( "Load splash screen" ) );
                FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Splash screen File (*.bmp)" ), new String[] { "bmp" } );
                fd.setFileFilter( filter );
                int returnVal = fd.showOpenDialog( CustomizeDialog.this );

                if ( returnVal == JFileChooser.APPROVE_OPTION )
                {
                    try
                    {
                        selectedSplashScreen = fd.getSelectedFile().getCanonicalPath();
                        jTextField3.setText( selectedSplashScreen );
                    }
                    catch ( IOException e1 )
                    {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        } );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        jPanel1.add( jButton3, gridBagConstraints );

        jButton4.setText( DemoApp.getRes().getString( "Customize" ) );
        jButton4.addActionListener( new ActionListener()
        {
            public void actionPerformed( ActionEvent e )
            {
                String errorMsg = "";
                if ( jTextField1.getText().length() == 0 || !new File( jTextField1.getText() ).exists() )
                {
                    jTextField1.setBackground( Color.red );
                    errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Source Binary Specified\n" ) );
                }

                if ( jTextField2.getText().length() != 0 && !new File( jTextField2.getText() ).exists() )
                {
                    jTextField2.setBackground( Color.red );
                    errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Icon File Specified\n" ) );
                }
                if ( jTextField3.getText().length() != 0 && !new File( jTextField3.getText() ).exists() )
                {
                    jTextField3.setBackground( Color.red );
                    errorMsg = errorMsg.concat( DemoApp.getRes().getString( "No valid Splash Screen File Specified\n" ) );
                }
                if ( jTextField2.getText().length() == 0 && jTextField3.getText().length() == 0 )
                {
                    errorMsg = errorMsg.concat( DemoApp.getRes().getString( "Please select at least one Icon or Splash Screen File.\n" ) );
                    jTextField2.setBackground( Color.yellow );
                    jTextField3.setBackground( Color.yellow );
                }

                if ( errorMsg.length() > 0 )
                {
                    JOptionPane.showMessageDialog( CustomizeDialog.this, DemoApp.getRes().getString( "See the following list of errors:\n" ) + errorMsg, DemoApp.getRes().getString( "Error" ), JOptionPane.ERROR_MESSAGE );
                    return;
                }

                JFileChooser fd = new JFileChooser();
                fd.setMultiSelectionEnabled( false );

                fd.setCurrentDirectory( new File( "." ) );
                fd.setDialogTitle( DemoApp.getRes().getString( "Select destination file of the customization" ) );
                fd.setFileHidingEnabled( true );

                fd.setApproveButtonText( DemoApp.getRes().getString( "Custimize Binary" ) );
                FileFilter filter = new ExtensionFilter( DemoApp.getRes().getString( "Executable File (*.exe)" ), new String[] { "exe" } );
                fd.setFileFilter( filter );

                int returnVal = fd.showSaveDialog( CustomizeDialog.this );

                if ( returnVal == JFileChooser.APPROVE_OPTION )
View Full Code Here

                    Globals.prefs.get("exportWorkingDirectory"));
        fc.showSaveDialog(frame);
        File file = fc.getSelectedFile();
        if (file == null)
          return;
        FileFilter ff = fc.getFileFilter();
        if (ff instanceof ExportFileFilter) {


                    ExportFileFilter eff = (ExportFileFilter) ff;
                    String path = file.getPath();
View Full Code Here

TOP

Related Classes of javax.swing.filechooser.FileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.