Example usage for java.awt FileDialog setTitle

List of usage examples for java.awt FileDialog setTitle

Introduction

In this page you can find the example usage for java.awt FileDialog setTitle.

Prototype

@Override
public void setTitle(String title) 

Source Link

Document

Note: Some platforms may not support showing the user-specified title in a file dialog.

Usage

From source file:Main.java

/**
 * @param jFrame// w  ww .j a va  2  s  .co m
 * @param currentDirectory
 * @return You can get the filename with fileDialog.getFile(),
 * and you can get the directory with fileDialog.getDirectory().
 * String filename = fileDialog.getDirectory() + System.getProperty("file.separator") + fileDialog.getFile();
 * 
 */
public static FileDialog letUserChooseFile(JFrame jFrame, String currentDirectory) {
    FileDialog fileDialog = new FileDialog(jFrame);
    fileDialog.setModal(true);
    fileDialog.setMode(FileDialog.LOAD);
    fileDialog.setTitle("Open a File");
    if (currentDirectory != null && !currentDirectory.trim().equals("")) {
        fileDialog.setDirectory(currentDirectory);
    }
    fileDialog.setVisible(true);
    return fileDialog;
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java

/**
 * //from  w  w w  .  ja  v a2 s. co  m
 */
private void importSchema(final boolean doLocalization) {
    FileDialog fileDlg = new FileDialog((Dialog) null);
    fileDlg.setTitle(getResourceString(doLocalization ? SL_CHS_LOC : SL_CHS_IMP));
    UIHelper.centerAndShow(fileDlg);

    String fileName = fileDlg.getFile();
    if (StringUtils.isNotEmpty(fileName)) {
        String title = getResourceString(doLocalization ? "SL_L10N_SCHEMA" : "SL_IMPORT_SCHEMA");

        final File file = new File(fileDlg.getDirectory() + File.separator + fileName);
        final SimpleGlassPane glassPane = new SimpleGlassPane(title, 18);
        glassPane.setBarHeight(12);
        glassPane.setFillColor(new Color(0, 0, 0, 85));

        setGlassPane(glassPane);
        glassPane.setVisible(true);

        SwingWorker<Integer, Integer> importWorker = new SwingWorker<Integer, Integer>() {
            private boolean isOK = false;

            @Override
            protected Integer doInBackground() throws Exception {
                DataProviderSessionIFace localSession = null;
                try {
                    localSession = DataProviderFactory.getInstance().createSession();

                    localSession.beginTransaction();

                    BuildSampleDatabase bsd = new BuildSampleDatabase();

                    Discipline discipline = localSession.get(Discipline.class,
                            AppContextMgr.getInstance().getClassObject(Discipline.class).getId());

                    isOK = bsd.loadSchemaLocalization(discipline, schemaType, DBTableIdMgr.getInstance(), null, //catFmtName,
                            null, //accFmtName,
                            doLocalization ? UpdateType.eLocalize : UpdateType.eImport, // isDoingUpdate
                            file, // external file
                            glassPane, localSession);
                    if (isOK) {
                        localSession.commit();
                    } else {
                        localSession.rollback();
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildSampleDatabase.class, ex);

                } finally {
                    if (localSession != null) {
                        localSession.close();
                    }
                }

                return null;
            }

            @Override
            protected void done() {
                super.done();

                glassPane.setVisible(false);

                if (isOK) {
                    UIRegistry.showLocalizedMsg("Specify.ABT_EXIT");
                    CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit"));
                }
            }
        };
        importWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                }
            }
        });
        importWorker.execute();
    }
}

From source file:phex.gui.common.FileDialogHandler.java

private static File openMacDirectoryChooser(String title, String notifyPopupTitle,
        String notifyPopupShortMessage) {
    // create folder dialog through other class this prevents 
    // NoClassDefFoundError on Windows systems since the import of the
    // required OS X classes is elsewhere.
    FileDialog dia = MacOsxGUIUtils.createFolderDialog();
    dia.setTitle(title);

    // unfortunatly its not possible to display notification popup
    // besides heavy weight dialog.
    //if ( notifyPopupTitle != null || notifyPopupShortMessage != null )
    //{/*www.  j av  a  2  s.c  om*/
    //displayMacNotificationPopup( dia, notifyPopupTitle, 
    //    notifyPopupShortMessage );
    //}

    DirectoryOnlyFileFilter filter = new DirectoryOnlyFileFilter();
    dia.setFilenameFilter(new FileFilterWrapper(filter));
    dia.setVisible(true);
    String dirStr = dia.getDirectory();
    String fileStr = dia.getFile();

    if (dirStr == null || fileStr == null) {
        return null;
    }
    File file = new File(dirStr, fileStr);
    // validate filter
    if (!filter.accept(file)) {
        return null;
    }
    return file;
}