當前位置: 首頁>>代碼示例>>Java>>正文


Java FileDialog.LOAD屬性代碼示例

本文整理匯總了Java中java.awt.FileDialog.LOAD屬性的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.LOAD屬性的具體用法?Java FileDialog.LOAD怎麽用?Java FileDialog.LOAD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.FileDialog的用法示例。


在下文中一共展示了FileDialog.LOAD屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showNativeDialog

private void showNativeDialog() {
    String dirname = fd.getDirectory();
    // File path has a priority against directory path.
    String filename = fd.getFile();
    if (filename != null) {
        final File file = new File(filename);
        if (fd.getMode() == FileDialog.LOAD
            && dirname != null
            && file.getParent() == null) {
            // File path for gtk_file_chooser_set_filename.
            filename = dirname + (dirname.endsWith(File.separator) ? "" :
                                          File.separator) + filename;
        }
        if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
            // Filename for gtk_file_chooser_set_current_name.
            filename = file.getName();
            // Directory path for gtk_file_chooser_set_current_folder.
            dirname = file.getParent();
        }
    }
    run(fd.getTitle(), fd.getMode(), dirname, filename,
        fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:GtkFileDialogPeer.java

示例2: showNativeDialog

private void showNativeDialog() {
    String dirname = fd.getDirectory();
    // File path has a priority against directory path.
    String filename = fd.getFile();
    if (filename != null) {
        final File file = new File(filename);
        if (fd.getMode() == FileDialog.LOAD
            && dirname != null
            && file.getParent() == null) {
            // File path for gtk_file_chooser_set_filename.
            filename = dirname + (dirname.endsWith(File.separator) ? "" :
                                          File.separator) + filename;
        }
        if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
            // Filename for gtk_file_chooser_set_current_name.
            filename = file.getName();
            // Directory path for gtk_file_chooser_set_current_folder.
            dirname = file.getParent();
        }
    }
    if (!quit) {
        run(fd.getTitle(), fd.getMode(), dirname, filename,
                fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:GtkFileDialogPeer.java

示例3: actionPerformed

public void actionPerformed(ActionEvent event) {
	FileDialog dialog = new FileDialog(SnakeGameFrame.this, "Open",
			FileDialog.LOAD);
	dialog.setVisible(true);
	String dir = dialog.getDirectory();
	String fileName = dialog.getFile();
	String filePath = dir + fileName;

	if (fileName != null && fileName.trim().length() != 0) {
		File file = new File(filePath);
		panel.loadGameDataFromFile(file);
		startMI.setEnabled(false);
		pauseMI.setEnabled(true);
	} else {
		JOptionPane.showConfirmDialog(SnakeGameFrame.this,
				"�ļ���Ϊ��\nװ����Ϸ����ʧ��", "̰������Ϸ", JOptionPane.DEFAULT_OPTION);
	}

}
 
開發者ID:ljheee,項目名稱:MySnakeGame,代碼行數:19,代碼來源:SnakeGameFrame.java

示例4: actionPerformed

@Override
public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(ImageViewerGui.getMainFrame(), "Choose a file", FileDialog.LOAD);
    // does not work on Windows
    fileDialog.setFilenameFilter(new AllFilenameFilter());
    fileDialog.setMultipleMode(true);
    fileDialog.setDirectory(Settings.getSingletonInstance().getProperty("default.local.path"));
    fileDialog.setVisible(true);

    String directory = fileDialog.getDirectory();
    File[] fileNames = fileDialog.getFiles();
    if (fileNames.length > 0 && directory != null) {
        // remember the current directory for future
        Settings.getSingletonInstance().setProperty("default.local.path", directory);
        Settings.getSingletonInstance().save("default.local.path");
        for (File fileName : fileNames) {
            if (fileName.isFile())
                Load.image.get(fileName.toURI());
        }
    }
}
 
開發者ID:Helioviewer-Project,項目名稱:JHelioviewer-SWHV,代碼行數:21,代碼來源:OpenLocalFileAction.java

示例5: actionPerformed

@Override
public void actionPerformed(ActionEvent e) {
    FileDialog fileDialog = new FileDialog(ImageViewerGui.getMainFrame(), "Choose a file", FileDialog.LOAD);
    // does not work on Windows
    fileDialog.setFilenameFilter(new JsonFilenameFilter());
    fileDialog.setMultipleMode(true);
    fileDialog.setDirectory(Settings.getSingletonInstance().getProperty("default.local.path"));
    fileDialog.setVisible(true);

    String directory = fileDialog.getDirectory();
    File[] fileNames = fileDialog.getFiles();
    if (fileNames.length > 0 && directory != null) {
        // remember the current directory for future
        Settings.getSingletonInstance().setProperty("default.local.path", directory);
        Settings.getSingletonInstance().save("default.local.path");
        for (File fileName : fileNames) {
            if (fileName.isFile())
                Load.timeline.get(fileName.toURI());
        }
    }
}
 
開發者ID:Helioviewer-Project,項目名稱:JHelioviewer-SWHV,代碼行數:21,代碼來源:OpenLocalFileAction.java

示例6: ReadFileButton

/**
 * Constructs a button for reading in a music file.
 *
 * @param owner {@link Frame} which is the owner of this button.  Access to
 *              this <CODE>Frame</CODE> will be suspended when the user is
 *              selecting a music file and when error messages are
 *              displayed.
 */
public ReadFileButton(final Frame owner) {
    super("Read File");
    final FileDialog load = new FileDialog(owner,
            "Select a Midi or jMusic file to import",
            FileDialog.LOAD);
    load.setFilenameFilter(new ReadFilenameFilter());

    addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            load.show();

            Score score = Read.midiOrJmWithAWTMessaging(load.getDirectory(),
                                                        load.getFile(),
                                                        owner); 
            if (score == null) {
                return;
            }
            if (readListenerList != null) {
                score = readListenerList.scoreRead(score);
                readListenerList.finishedReading();
            }
        }
    }
    );
}
 
開發者ID:Impro-Visor,項目名稱:Impro-Visor,代碼行數:33,代碼來源:ReadFileButton.java

示例7: doLoadDisk

private void doLoadDisk()
{
    FileDialog fd = new FileDialog(getFrame(), "Load Script", FileDialog.LOAD);
    fd.setDirectory(RuntimeLogic.getProp("script.file.dir"));
    fd.setFile(RuntimeLogic.getProp("script.file.file"));
    fd.setVisible(true);
    if (fd.getDirectory() == null)
        return;
    String historyFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
    if ((historyFile == null) || (historyFile.length() == 0))
        return;
    try
    {
        ScriptLogic.load(mRuntime, new File(historyFile));
        RuntimeLogic.setProp("script.file.dir", fd.getDirectory());
        RuntimeLogic.setProp("script.file.file", fd.getFile());
    }
    catch (IOException e)
    {
        JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
    }
}
 
開發者ID:jjaquinta,項目名稱:EchoSim,代碼行數:22,代碼來源:ScriptPanel.java

示例8: doIntentLoadFile

protected void doIntentLoadFile()
{
    FileDialog fd = new FileDialog(getFrame(), "Load Intent File", FileDialog.LOAD);
    fd.setDirectory(RuntimeLogic.getProp("intent.file.dir"));
    fd.setFile(RuntimeLogic.getProp("intent.file.file"));
    fd.setVisible(true);
    if (fd.getDirectory() == null)
        return;
    String intentFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
    if ((intentFile == null) || (intentFile.length() == 0))
        return;
    try
    {
        RuntimeLogic.readIntents(mRuntime, (new File(intentFile)).toURI());
        RuntimeLogic.setProp("intent.file.dir", fd.getDirectory());
        RuntimeLogic.setProp("intent.file.file", fd.getFile());
    }
    catch (IOException e)
    {
        JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+intentFile, JOptionPane.ERROR_MESSAGE);
    }
}
 
開發者ID:jjaquinta,項目名稱:EchoSim,代碼行數:22,代碼來源:ApplicationPanel.java

示例9: doLoad

private void doLoad()
{
    FileDialog fd = new FileDialog(getFrame(), "Load History File", FileDialog.LOAD);
    fd.setDirectory(RuntimeLogic.getProp("history.file.dir"));
    fd.setFile(RuntimeLogic.getProp("history.file.file"));
    fd.setVisible(true);
    if (fd.getDirectory() == null)
        return;
    String historyFile = fd.getDirectory()+System.getProperty("file.separator")+fd.getFile();
    if ((historyFile == null) || (historyFile.length() == 0))
        return;
    try
    {
        RuntimeLogic.loadHistory(mRuntime, new File(historyFile));
        RuntimeLogic.setProp("history.file.dir", fd.getDirectory());
        RuntimeLogic.setProp("history.file.file", fd.getFile());
    }
    catch (IOException e)
    {
        JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), "Error reading "+historyFile, JOptionPane.ERROR_MESSAGE);
    }
}
 
開發者ID:jjaquinta,項目名稱:EchoSim,代碼行數:22,代碼來源:TestingPanel.java

示例10: getTableCellEditorComponent

/**
 * Apply the Editor for a selected option.
 */
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  if(row < parameters.size()) {
    Parameter<?> option = parameters.getNode(row).param;
    if(option instanceof FileParameter) {
      FileParameter fp = (FileParameter) option;
      File f = null;
      mode = FileParameter.FileType.INPUT_FILE.equals(fp.getFileType()) ? FileDialog.LOAD : FileDialog.SAVE;
      if(fp.isDefined()) {
        f = fp.getValue();
      }
      textfield.setText(f != null ? f.getPath() : "");
    }
  }
  textfield.requestFocus();
  return panel;
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:20,代碼來源:ParameterTable.java

示例11: loadTransformation

private void loadTransformation (
) {
   final Frame f = new Frame();
   final FileDialog fd = new FileDialog(f, "Load Transformation", FileDialog.LOAD);
   fd.setVisible(true);
   final String path = fd.getDirectory();
   final String filename = fd.getFile();
   if ((path == null) || (filename == null)) {
      return;
   }
   String fn_tnf=path+filename;

   int intervals=unwarpJMiscTools.
      numberOfIntervalsOfTransformation(fn_tnf);
   double [][]cx=new double[intervals+3][intervals+3];
   double [][]cy=new double[intervals+3][intervals+3];
   unwarpJMiscTools.loadTransformation(fn_tnf, cx, cy);

   // Apply transformation
   dialog.applyTransformationToSource(intervals,cx,cy);
}
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:21,代碼來源:UnwarpJ_.java

示例12: loadPoints

private void loadPoints (
) {
   final Frame f = new Frame();
   final FileDialog fd = new FileDialog(f, "Load Points", FileDialog.LOAD);
   fd.setVisible(true);
   final String path = fd.getDirectory();
   final String filename = fd.getFile();
   if ((path == null) || (filename == null)) return;

   Stack sourceStack = new Stack();
   Stack targetStack = new Stack();
   unwarpJMiscTools.loadPoints(path+filename,sourceStack,targetStack);

   sourcePh.removePoints();
   targetPh.removePoints();
   while ((!sourceStack.empty()) && (!targetStack.empty())) {
      Point sourcePoint = (Point)sourceStack.pop();
      Point targetPoint = (Point)targetStack.pop();
      sourcePh.addPoint(sourcePoint.x, sourcePoint.y);
      targetPh.addPoint(targetPoint.x, targetPoint.y);
   }
}
 
開發者ID:akmaier,項目名稱:CONRAD,代碼行數:22,代碼來源:UnwarpJ_.java

示例13: jMenuItem4ActionPerformed

private void jMenuItem4ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
    // Add your handling code here:
    FileDialog fileDialog = new FileDialog (this, "Open...", FileDialog.LOAD);
    fileDialog.show ();
    if (fileDialog.getFile () == null)
        return;
    fileName = fileDialog.getDirectory () + File.separator + fileDialog.getFile ();

    FileInputStream fis = null;
    String str = null;
    try {
        fis = new FileInputStream (fileName);
        int size = fis.available ();
        byte[] bytes = new byte [size];
        fis.read (bytes);
        str = new String (bytes);
    } catch (IOException e) {
    } finally {
        try {
            fis.close ();
        } catch (IOException e2) {
        }
    }

    if (str != null)
        textBox.setText (str);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Ted.java

示例14: openMenuItemActionPerformed

/** This method is called when File -> Open menu item is invoked.
 * It displays a dialog to choose the file to be opened and edited.
 * @param evt ActionEvent instance passed from actionPerformed event.
 */
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
    FileDialog fileDialog = new FileDialog(this, "Open...", FileDialog.LOAD);
    fileDialog.show();
    if (fileDialog.getFile() == null)
        return;
    fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();

    FileInputStream fis = null;
    String str = null;
    try {
        fis = new FileInputStream(fileName);
        int size = fis.available();
        byte[] bytes = new byte [size];
        fis.read(bytes);
        str = new String(bytes);
    } catch (IOException e) {
    } finally {
        try {
            fis.close();
        } catch (IOException e2) {
        }
    }

    if (str != null)
        textBox.setText(str);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:Ted.java

示例15: loadFile

public String loadFile(Frame f, String title, String defDir, String fileType) {
 FileDialog fd = new FileDialog(f, title, FileDialog.LOAD);
 fd.setFile(fileType);
 fd.setDirectory(defDir);
 fd.setLocation(50, 50);
 fd.show();
 return fd.getDirectory()+fd.getFile();
}
 
開發者ID:HML-UnBBayes,項目名稱:hml,代碼行數:8,代碼來源:FileChooserDialog.java


注:本文中的java.awt.FileDialog.LOAD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。