Java Code Examples for javax.swing.JFileChooser#setPreferredSize()

The following examples show how to use javax.swing.JFileChooser#setPreferredSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DebugMe.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
    JFileChooser fileopen = new JFileChooser();
    fileopen.setFileFilter(new OpenFileFilter("bsh", "BSH files (*.bsh)"));
    fileopen.setAcceptAllFileFilterUsed(false);
    fileopen.setMultiSelectionEnabled(false);
    fileopen.setPreferredSize(new Dimension(scr.width - 350, scr.height - 350));
    if (fileopen.showOpenDialog(null) == 0) {
        DebugMe.scriptFile = fileopen.getSelectedFile();
    } else {
        DebugMe.scriptFile = null;
    }
    dialogOpened.set(false);
}
 
Example 2
Source File: TDA.java    From tda with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * initializes session file chooser, if not already done.
 */
private static void initSessionFc() {

    sessionFc = new JFileChooser();
    sessionFc.setMultiSelectionEnabled(true);
    sessionFc.setCurrentDirectory(PrefManager.get().getSelectedPath());
    if ((PrefManager.get().getPreferredSizeFileChooser().height > 0)) {
        sessionFc.setPreferredSize(PrefManager.get().getPreferredSizeFileChooser());
    }
    sessionFc.setFileFilter(getSessionFilter());
        
    sessionFc.setSelectedFile(null);
}
 
Example 3
Source File: CPSGlobalSettings.java    From cropplanning with GNU General Public License v3.0 5 votes vote down vote up
public OutDirWizardPage () {
   super( PAGE_OUT_DIR, getDescription(), CPSWizardPage.WIZ_TYPE_PRE_INIT );

   setLongDescription( getDescription() );

   setPreferredSize( panelDim );
   setMaximumSize( panelDim );

   JLabel lblOutDir = new JLabel( "<html><body style='width: 300px'>" +
                                  "<b>Select a folder or directory to store all of your crop planning data.</b>" +
                                  "<p><p>If you have already used this program to create crop plans and would like to load that information, " +
                                  "please select the folder or directory which contains your existing data. " +
                                  "(The data files have names that start with \"CPSdb\".)" +
                                  "" );
   lblOutDir.setAlignmentX( Component.CENTER_ALIGNMENT );

   String defaultDirectory = CPSGlobalSettings.getOutputDir();
   flchOutDir = new JFileChooser();
   flchOutDir.setSelectedFile( new File( defaultDirectory ) );
   flchOutDir.setName( SETTING_OUT_DIR );
   flchOutDir.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
   flchOutDir.setMultiSelectionEnabled( false );
   flchOutDir.setControlButtonsAreShown( false );
   flchOutDir.addPropertyChangeListener( new PropertyChangeListener() {

      public void propertyChange ( PropertyChangeEvent evt ) {
         if ( evt.getPropertyName().equals( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY ) ) {
            outDirIsSelected = ( evt.getNewValue() != null ) ? true : false;
            userInputReceived( flchOutDir, evt );
         }
      }
   } ); // new PropChangeListener
   flchOutDir.setPreferredSize( fileDim );
   flchOutDir.setMaximumSize( fileDim );

   add( lblOutDir );
   add( flchOutDir );
}
 
Example 4
Source File: RemoteSessionChooserFactory.java    From chipster with MIT License 5 votes vote down vote up
public JFileChooser getExampleSessionChooser() throws MalformedURLException, JMSException, FileBrokerException, AuthCancelledException {
	JFileChooser exampleSessionFileChooser = populateFileChooserFromServer(false);
	exampleSessionFileChooser.setSelectedFile(new File("session"));
	ServerFileUtils.hideJFileChooserButtons(exampleSessionFileChooser);
	exampleSessionFileChooser.setPreferredSize(new Dimension(800, 600));

	ServerFileSystemView view = (ServerFileSystemView) exampleSessionFileChooser.getFileSystemView();
	exampleSessionFileChooser.setCurrentDirectory(view.getExampleSessionDir());				
	
	return exampleSessionFileChooser;
}
 
Example 5
Source File: RemoteSessionChooserFactory.java    From chipster with MIT License 5 votes vote down vote up
public JFileChooser getRemoteSessionChooser() throws MalformedURLException, JMSException, FileBrokerException, AuthCancelledException {
	JFileChooser remoteSessionFileChooser = populateFileChooserFromServer();
	remoteSessionFileChooser.setSelectedFile(new File("session"));
	remoteSessionFileChooser.setPreferredSize(new Dimension(800, 600));
	remoteSessionFileChooser.setAccessory(new RemoteSessionAccessory(remoteSessionFileChooser, app.getSessionManager(), app));
	ServerFileUtils.hideJFileChooserButtons(remoteSessionFileChooser);
		
	return remoteSessionFileChooser;
}
 
Example 6
Source File: AntArtifactChooser.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Shows dialog with the artifact chooser 
 * @return null if canceled selected jars if some jars selected
 */
static AntArtifactItem[] showDialog( String[] artifactTypes, Project master, Component parent ) {
    
    JFileChooser chooser = ProjectChooser.projectChooser();
    chooser.setDialogTitle( NbBundle.getMessage( AntArtifactChooser.class, "LBL_AACH_Title" ) ); // NOI18N
    chooser.setApproveButtonText( NbBundle.getMessage( AntArtifactChooser.class, "LBL_AACH_SelectProject" ) ); // NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (AntArtifactChooser.class,"AD_AACH_SelectProject"));
    AntArtifactChooser accessory = new AntArtifactChooser( artifactTypes, chooser );
    chooser.setAccessory( accessory );
    chooser.setPreferredSize( new Dimension( 650, 380 ) );        
    File defaultFolder = null;
    FileObject defFo = master.getProjectDirectory();
    if (defFo != null) {
        defFo = defFo.getParent();
        if (defFo != null) {
            defaultFolder = FileUtil.toFile(defFo);
        }
    }
    chooser.setCurrentDirectory (getLastUsedArtifactFolder(defaultFolder));

    int option = chooser.showOpenDialog( parent ); // Show the chooser
          
    if ( option == JFileChooser.APPROVE_OPTION ) {

        File dir = chooser.getSelectedFile();
        dir = FileUtil.normalizeFile (dir);
        Project selectedProject = accessory.getProject( dir );

        if ( selectedProject == null ) {
            return null;
        }
        
        if ( selectedProject.getProjectDirectory().equals( master.getProjectDirectory() ) ) {
            DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( 
                NbBundle.getMessage( AntArtifactChooser.class, "MSG_AACH_RefToItself" ),
                NotifyDescriptor.INFORMATION_MESSAGE ) );
            return null;
        }
        
        if ( ProjectUtils.hasSubprojectCycles( master, selectedProject ) ) {
            DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( 
                NbBundle.getMessage( AntArtifactChooser.class, "MSG_AACH_Cycles" ),
                NotifyDescriptor.INFORMATION_MESSAGE ) );
            return null;
        }

        boolean noSuitableOutput = true;
        for (String type : artifactTypes) {
            if (AntArtifactQuery.findArtifactsByType(selectedProject, type).length > 0) {
                noSuitableOutput = false;
                break;
            }
        }
        if (noSuitableOutput) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    NbBundle.getMessage (AntArtifactChooser.class,"MSG_NO_JAR_OUTPUT")));
            return null;
        }
        
        setLastUsedArtifactFolder (FileUtil.normalizeFile(chooser.getCurrentDirectory()));
        
        Object[] tmp = new Object[accessory.jListArtifacts.getModel().getSize()];
        int count = 0;
        for(int i = 0; i < tmp.length; i++) {
            if (accessory.jListArtifacts.isSelectedIndex(i)) {
                tmp[count] = accessory.jListArtifacts.getModel().getElementAt(i);
                count++;
            }
        }
        AntArtifactItem artifactItems[] = new AntArtifactItem[count];
        System.arraycopy(tmp, 0, artifactItems, 0, count);
        return artifactItems;
    }
    else {
        return null; 
    }
            
}
 
Example 7
Source File: BoardEditor.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
private void setDialogSize(JFileChooser dialog) {
    int width = guip.getBoardEditLoadWidth();
    int height = guip.getBoardEditLoadHeight();
    dialog.setPreferredSize(new Dimension(width, height));   
}
 
Example 8
Source File: RemoteSessionChooserFactory.java    From chipster with MIT License 4 votes vote down vote up
public JFileChooser getManagementChooser() throws MalformedURLException, JMSException, FileBrokerException, AuthCancelledException {

		JFileChooser sessionFileChooser = null;

		// fetch current sessions to show in the dialog and create it
		sessionFileChooser = populateFileChooserFromServer();



		// tune GUI
		sessionFileChooser.setDialogTitle("Manage");

		sessionFileChooser.setPreferredSize(new Dimension(800, 600));
		sessionFileChooser.setAccessory(new RemoteSessionAccessory(sessionFileChooser, app.getSessionManager(), app));		

		// hide buttons that we don't need
		ServerFileUtils.hideJFileChooserButtons(sessionFileChooser);
		ServerFileUtils.hideApproveButton(sessionFileChooser);
		ServerFileUtils.setCancelButtonText(sessionFileChooser, "Close");

		return sessionFileChooser;
	}