List of usage examples for java.awt FileDialog LOAD
int LOAD
To view the source code for java.awt FileDialog LOAD.
Click Source Link
From source file:br.upe.ecomp.dosa.view.mainwindow.MainWindowActions.java
private void openTestScenario() { FileDialog fileopen = new FileDialog(this, "Open Test Scenario", FileDialog.LOAD); fileopen.setFilenameFilter(new FilenameFilter() { @Override//from ww w. j a va2s. c o m public boolean accept(File dir, String name) { return name.toLowerCase().endsWith("xml"); } }); fileopen.setVisible(true); if (fileopen.getFile() != null) { filePath = fileopen.getDirectory(); fileName = fileopen.getFile(); algorithm = AlgorithmXMLParser.read(filePath, fileName); configureTree(); updateToolBarButtonsState(); ((CardLayout) panelTestScenario.getLayout()).last(panelTestScenario); } }
From source file:PlayerOfMedia.java
/*************************************************************************** * React to menu selections (quit or open) or one of the the buttons on the * dialog boxes./*from w w w . j a va2 s. c o m*/ **************************************************************************/ public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof MenuItem) { ////////////////////////////////////////////////// // Quit and free up any player acquired resources. ////////////////////////////////////////////////// if (e.getActionCommand().equalsIgnoreCase("QUIT")) { if (player != null) { player.stop(); player.close(); } System.exit(0); } ///////////////////////////////////////////////////////// // User to open/play media. Show the selection dialog box. ///////////////////////////////////////////////////////// else if (e.getActionCommand().equalsIgnoreCase("OPEN")) { selectionDialog.show(); } } ////////////////////// // One of the Buttons. ////////////////////// else { ///////////////////////////////////////////////////////////// // User to browse the local file system. Popup a file dialog. ///////////////////////////////////////////////////////////// if (e.getSource() == choose) { FileDialog choice = new FileDialog(this, "Media File Choice", FileDialog.LOAD); if (lastDirectory != null) choice.setDirectory(lastDirectory); choice.show(); String selection = choice.getFile(); if (selection != null) { lastDirectory = choice.getDirectory(); mediaName.setText("file://" + choice.getDirectory() + selection); } } /////////////////////////////////////////////// // User chooses to cancel opening of new media. /////////////////////////////////////////////// else if (e.getSource() == cancel) { selectionDialog.hide(); } /////////////////////////////////////////////////////// // User has selected the name of the media. Attempt to // create a Player. /////////////////////////////////////////////////////// else if (e.getSource() == open) { selectionDialog.hide(); createAPlayer(mediaName.getText()); } //////////////////////////////////////////// // User has seen error message. Now hide it. //////////////////////////////////////////// else if (e.getSource() == ok) errorDialog.hide(); } }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
public void install(JComponent parent, Window dialog) { final File installDirectory; switch (OSInfosDefault.INSTANCE.getOs()) { case OSX:/*from w w w .j a v a 2 s . c o m*/ System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog d = new FileDialog(Frame.getFrames()[0], "Choose directory for installation of " + toolName, FileDialog.LOAD); d.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (d.getFile() != null) { installDirectory = new File(d.getDirectory(), d.getFile()); } else { installDirectory = null; } break; default: final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Choose directory for installation of " + toolName); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setApproveButtonText("Install " + toolName + " here"); int result = chooser.showDialog(parent, "Install " + toolName + " here"); if (result == JFileChooser.APPROVE_OPTION) { installDirectory = chooser.getSelectedFile(); } else { installDirectory = null; } } if (installDirectory != null) { try { final File tmp = File.createTempFile("keymaeraDownload", "." + ft.toString().toLowerCase()); final FileInfo info = new FileInfo(url, tmp.getName(), false); final DownloadManager dlm = new DownloadManager(); ProgressBarWindow pbw = new ProgressBarWindow(parent, installDirectory, tmp, ft, ps, dialog); dlm.addListener(pbw); Runnable down = new Runnable() { @Override public void run() { dlm.downloadAll(new FileInfo[] { info }, 2000, tmp.getParentFile().getAbsolutePath(), true); } }; Thread thread = new Thread(down); thread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * /*from w ww. jav a 2 s. c o m*/ */ public void startUp() { //AskForDirectory afd = new AskForDirectory(frame); //currentPath = afd.getDirectory(); FileDialog dlg = new FileDialog(frame, "Select a Directory", FileDialog.LOAD); UIHelper.centerAndShow(dlg); String currentPath = dlg.getDirectory(); if (StringUtils.isNotEmpty(currentPath)) { if (doSrcParsing) { File rootDir = new File("/Users/rods/Documents/SVN/SpecifyInsightL10N"); srcIndexer = new L10NSrcIndexer(rootDir); doScanSources(); } boolean isDirOK = true; rootDir = new File(currentPath); if (!rootDir.exists()) { String dirPath = getFullPath(currentPath); rootDir = new File(dirPath); isDirOK = rootDir.exists(); } if (isDirOK) { createUI(); register(MAINPANE, mainPane); frame.setGlassPane(glassPane = GhostGlassPane.getInstance()); frame.setLocationRelativeTo(null); Toolkit.getDefaultToolkit().setDynamicLayout(true); register(GLASSPANE, glassPane); if (setupSrcFiles(rootDir) > 0) { frame.pack(); UIHelper.centerAndShow(frame); destLanguage = doChooseLangLocale(Locale.ENGLISH); if (destLanguage != null) { destLbl.setText(destLanguage.getDisplayName() + ":"); return; } } else { UIRegistry.showError("The are no localizable files in the directory you selected."); System.exit(0); } } } UIRegistry.showError("StrLocalizer will exit."); System.exit(0); }
From source file:de.freese.base.swing.mac_os_x.MyApp.java
/** * @see/*ww w . j av a2s.c o m*/ * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(final ActionEvent e) { Object source = e.getSource(); if (source == this.quitMI) { quit(); } else { if (source == this.optionsMI) { preferences(); } else { if (source == this.aboutMI) { about(); } else { if (source == this.openMI) { // File:Open action shows a FileDialog for loading displayable images FileDialog openDialog = new FileDialog(this); openDialog.setMode(FileDialog.LOAD); openDialog.setFilenameFilter(new FilenameFilter() { /** * @see java.io.FilenameFilter#accept(java.io.File, * java.lang.String) */ @Override public boolean accept(final File dir, final String name) { String[] supportedFiles = ImageIO.getReaderFormatNames(); for (String supportedFile : supportedFiles) { if (name.endsWith(supportedFile)) { return true; } } return false; } }); openDialog.setVisible(true); String filePath = openDialog.getDirectory() + openDialog.getFile(); if (filePath.length() > 0) { loadImageFile(filePath); } } } } } }
From source file:Forms.CreateGearForm.java
private GearSpec loadGearSpec() { //Get top level frame JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel); //Create dialog for choosing gearspec file FileDialog fd = new FileDialog(topFrame, "Choose a .gearspec file", FileDialog.LOAD); fd.setDirectory(System.getProperty("user.home")); fd.setFile("*.gearspec"); fd.setVisible(true);// www . j a v a 2s .co m //Get file String filename = fd.getFile(); if (filename == null) System.out.println("You cancelled the choice"); else { System.out.println("You chose " + filename); //Get spec file File specFile = new File(fd.getDirectory() + Utils.pathSeparator() + filename); //If it exists, set it as the selected file path if (specFile.exists()) { //Generate spec return Utils.specForFile(specFile); } } return null; }
From source file:edu.ku.brc.af.core.db.MySQLBackupService.java
@Override public void doRestore() { AppPreferences remotePrefs = AppPreferences.getLocalPrefs(); final String mysqlLoc = remotePrefs.get(MYSQL_LOC, getDefaultMySQLLoc()); final String backupLoc = remotePrefs.get(MYSQLBCK_LOC, getDefaultBackupLoc()); if (!(new File(mysqlLoc)).exists()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_RESTORE", mysqlLoc); return;/*from w w w . ja v a 2s .co m*/ } File backupDir = new File(backupLoc); if (!backupDir.exists()) { if (!backupDir.mkdir()) { UIRegistry.showLocalizedError("MySQLBackupService.MYSQL_NO_BK_DIR", backupDir.getAbsoluteFile()); return; } } FileDialog dlg = new FileDialog(((Frame) UIRegistry.getTopWindow()), getResourceString("Open"), FileDialog.LOAD); dlg.setDirectory(backupLoc); dlg.setVisible(true); String dirStr = dlg.getDirectory(); String fileName = dlg.getFile(); if (StringUtils.isEmpty(dirStr) || StringUtils.isEmpty(fileName)) { return; } errorMsg = null; final String path = dirStr + fileName; final JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setIndeterminate(STATUSBAR_NAME, true); String databaseName = DBConnection.getInstance().getDatabaseName(); SimpleGlassPane glassPane = UIRegistry .writeSimpleGlassPaneMsg(getLocalizedMessage("MySQLBackupService.RESTORING", databaseName), 24); doCompareBeforeRestore(path, glassPane); }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * Method for enabling a user to choose a toolbar icon. * @param appLabel the label used to display the icon. * @param clearIconBtn the button used to clear the icon *///from ww w. java2 s . c o m protected void chooseToolbarIcon(final JLabel appLabel, final JButton clearIconBtn) { FileDialog fileDialog = new FileDialog((Frame) UIRegistry.get(UIRegistry.FRAME), getResourceString("PREF_CHOOSE_APPICON_TITLE"), FileDialog.LOAD); //$NON-NLS-1$ fileDialog.setFilenameFilter(new ImageFilter()); UIHelper.centerAndShow(fileDialog); fileDialog.dispose(); String path = fileDialog.getDirectory(); if (StringUtils.isNotEmpty(path)) { String fullPath = path + File.separator + fileDialog.getFile(); File imageFile = new File(fullPath); if (imageFile.exists()) { ImageIcon newIcon = null; ImageIcon icon = new ImageIcon(fullPath); if (icon.getIconWidth() != -1 && icon.getIconHeight() != -1) { if (icon.getIconWidth() > 32 || icon.getIconHeight() > 32) { Image img = GraphicsUtils.getScaledImage(icon, 32, 32, false); if (img != null) { newIcon = new ImageIcon(img); } } else { newIcon = icon; } } ImageIcon appIcon; if (newIcon != null) { appLabel.setIcon(newIcon); clearIconBtn.setEnabled(true); String imgBufStr = GraphicsUtils.uuencodeImage(newAppIconName, newIcon); AppPreferences.getRemote().put(iconImagePrefName, imgBufStr); appIcon = newIcon; } else { appIcon = IconManager.getIcon("AppIcon"); appLabel.setIcon(appIcon); //$NON-NLS-1$ clearIconBtn.setEnabled(false); AppPreferences.getRemote().remove(iconImagePrefName); } IconEntry entry = IconManager.getIconEntryByName(INNER_APPICON_NAME); entry.setIcon(appIcon); if (entry.getIcons().get(IconManager.IconSize.Std32) != null) { entry.getIcons().get(IconManager.IconSize.Std32).setImageIcon(appIcon); } //((FormViewObj)form).getMVParent().set form.getValidator().dataChanged(null, null, null); } } }
From source file:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java
private FitxerDades getFitxerDades(final String sPath) { final FileDialog fd = new FileDialog(fDialog, Language.getLabel(9), FileDialog.LOAD); FitxerDades fitx;//from w ww .j a v a2 s.c o m fitx = new FitxerDades(); fd.setDirectory(sPath); fd.setVisible(true); if (fd.getFile() == null) { fitx = null; } else { fitx.setNom(fd.getFile()); fitx.setPath(fd.getDirectory()); } return fitx; }
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
@SuppressWarnings({ "unchecked" }) private void openXML() { FileDialog fileDlg = new FileDialog((Frame) UIRegistry.getTopWindow(), "", FileDialog.LOAD); fileDlg.setFilenameFilter(new FilenameFilter() { @Override/*from w w w.java2s. c o m*/ public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".xml"); } }); fileDlg.setVisible(true); String fileName = fileDlg.getFile(); if (fileName != null) { File iFile = new File(fileDlg.getDirectory() + File.separator + fileName); XStream xstream = new XStream(); FormInfo.configXStream(xstream); FormFieldInfo.configXStream(xstream); try { forms = (Vector<FormInfo>) xstream.fromXML(FileUtils.openInputStream(iFile)); formsTable.setModel(new FormCellModel(forms)); } catch (IOException e) { e.printStackTrace(); } } }