本文整理汇总了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());
}
示例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());
}
}
示例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);
}
}
示例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());
}
}
}
示例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());
}
}
}
示例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();
}
}
}
);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}