本文整理汇总了Java中sun.awt.AWTAccessor.FileDialogAccessor方法的典型用法代码示例。如果您正苦于以下问题:Java AWTAccessor.FileDialogAccessor方法的具体用法?Java AWTAccessor.FileDialogAccessor怎么用?Java AWTAccessor.FileDialogAccessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.AWTAccessor
的用法示例。
在下文中一共展示了AWTAccessor.FileDialogAccessor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSelection
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
/**
* handle the selection event
*/
void handleSelection(String file) {
int index = file.lastIndexOf(java.io.File.separatorChar);
if (index == -1) {
savedDir = this.dir;
savedFile = file;
} else {
savedDir = file.substring(0, index+1);
savedFile = file.substring(index+1);
}
String[] fileNames = fileList.getSelectedItems();
int filesNumber = (fileNames != null) ? fileNames.length : 0;
File[] files = new File[filesNumber];
for (int i = 0; i < filesNumber; i++) {
files[i] = new File(savedDir, fileNames[i]);
}
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
fileDialogAccessor.setDirectory(target, savedDir);
fileDialogAccessor.setFile(target, savedFile);
fileDialogAccessor.setFiles(target, files);
}
示例2: handleCancel
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
/**
* handle the cancel event
*/
void handleCancel() {
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removeKeyEventDispatcher(this);
setSelectionField(null);
setFilterField(null);
directoryList.clear();
fileList.clear();
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
fileDialogAccessor.setDirectory(target, null);
fileDialogAccessor.setFile(target, null);
fileDialogAccessor.setFiles(target, null);
handleQuitButton();
}
示例3: handleCancel
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
/**
* handle the cancel event
*/
@SuppressWarnings("deprecation")
void handleCancel() {
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removeKeyEventDispatcher(this);
setSelectionField(null);
setFilterField(null);
directoryList.clear();
fileList.clear();
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
fileDialogAccessor.setDirectory(target, null);
fileDialogAccessor.setFile(target, null);
fileDialogAccessor.setFiles(target, null);
handleQuitButton();
}
示例4: setFileInternal
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
/**
* Called exclusively by the native C code.
*/
private void setFileInternal(String directory, String[] filenames) {
AWTAccessor.FileDialogAccessor accessor = AWTAccessor
.getFileDialogAccessor();
if (filenames == null) {
accessor.setDirectory(fd, null);
accessor.setFile(fd, null);
accessor.setFiles(fd, null);
} else {
// Fix 6987233: add the trailing slash if it's absent
String with_separator = directory;
if (directory != null) {
with_separator = directory.endsWith(File.separator) ?
directory : (directory + File.separator);
}
accessor.setDirectory(fd, with_separator);
accessor.setFile(fd, filenames[0]);
int filesNumber = (filenames != null) ? filenames.length : 0;
File[] files = new File[filesNumber];
for (int i = 0; i < filesNumber; i++) {
files[i] = new File(directory, filenames[i]);
}
accessor.setFiles(fd, files);
}
}
示例5: run
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
@Override
public void run() {
try {
boolean navigateApps = !AccessController.doPrivileged(
new GetBooleanAction("apple.awt.use-file-dialog-packages"));
boolean chooseDirectories = AccessController.doPrivileged(
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
int dialogMode = target.getMode();
String title = target.getTitle();
if (title == null) {
title = " ";
}
String[] userFileNames = nativeRunFileDialog(title,
dialogMode,
target.isMultipleMode(),
navigateApps,
chooseDirectories,
target.getFilenameFilter() != null,
target.getDirectory(),
target.getFile());
String directory = null;
String file = null;
File[] files = null;
if (userFileNames != null) {
// the dialog wasn't cancelled
int filesNumber = userFileNames.length;
files = new File[filesNumber];
for (int i = 0; i < filesNumber; i++) {
files[i] = new File(userFileNames[i]);
}
directory = files[0].getParent();
// make sure directory always ends in '/'
if (!directory.endsWith(File.separator)) {
directory = directory + File.separator;
}
file = files[0].getName(); // pick any file
}
// store results back in component
AWTAccessor.FileDialogAccessor accessor = AWTAccessor.getFileDialogAccessor();
accessor.setDirectory(target, directory);
accessor.setFile(target, file);
accessor.setFiles(target, files);
} finally {
// Java2 Dialog waits for hide to let show() return
target.dispose();
}
}
示例6: handleSelected
import sun.awt.AWTAccessor; //导入方法依赖的package包/类
void handleSelected(final char[] buffer)
{
String[] wFiles = (new String(buffer)).split("\0"); // NULL is the delimiter
boolean multiple = (wFiles.length > 1);
String jDirectory = null;
String jFile = null;
File[] jFiles = null;
if (multiple) {
jDirectory = wFiles[0];
int filesNumber = wFiles.length - 1;
jFiles = new File[filesNumber];
for (int i = 0; i < filesNumber; i++) {
jFiles[i] = new File(jDirectory, wFiles[i + 1]);
}
jFile = wFiles[1]; // choose any file
} else {
int index = wFiles[0].lastIndexOf(java.io.File.separatorChar);
if (index == -1) {
jDirectory = "."+java.io.File.separator;
jFile = wFiles[0];
} else {
jDirectory = wFiles[0].substring(0, index + 1);
jFile = wFiles[0].substring(index + 1);
}
jFiles = new File[] { new File(jDirectory, jFile) };
}
final FileDialog fileDialog = (FileDialog)target;
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
fileDialogAccessor.setDirectory(fileDialog, jDirectory);
fileDialogAccessor.setFile(fileDialog, jFile);
fileDialogAccessor.setFiles(fileDialog, jFiles);
WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
@Override
public void run() {
fileDialog.setVisible(false);
}
});
}