本文整理了Java中com.apple.eawt.Application.setOpenFileHandler()
方法的一些代码示例,展示了Application.setOpenFileHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.setOpenFileHandler()
方法的具体详情如下:
包路径:com.apple.eawt.Application
类名称:Application
方法名:setOpenFileHandler
暂无
代码示例来源:origin: stackoverflow.com
public class Launcher {
public static void main(String[] args) {
if (System.getProperty("os.name").contains("OS X")){
com.apple.eawt.Application a = com.apple.eawt.Application.getApplication();
Handler_OpenFile h_open = new Handler_OpenFile();
a.setOpenFileHandler(h_open);
Application.launch(Main.class, args);
}
}
}
代码示例来源:origin: org.cytoscape.distribution/karaf-launcher
public static void handleStartupArguments() {
// All Mac EAWT logic
// Intercept session file double-clicked on Mac OS, passed by file association set by install4j
Application application = Application.getApplication();
application.setOpenFileHandler(new OpenFilesHandler() {
@Override
public void openFiles(OpenFilesEvent e) {
if (Launcher.startupArguments.length > 0 || e.getFiles().size()>1){
return;
}
String fileName = e.getFiles().get(0).getAbsolutePath();
if (!fileName.endsWith(".cys")){
return;
}
String[] argsArray = {fileName};
Launcher.startupArguments = argsArray;
}
});
}
}
代码示例来源:origin: stackoverflow.com
import java.io.File;
import java.util.List;
import com.apple.eawt.AppEvent.OpenFilesEvent;
import com.apple.eawt.Application;
import com.apple.eawt.OpenFilesHandler;
public class MacFiles implements OpenFilesHandler{
private List<File> files;
private FileSaving myFiling;
public MacFiles(FileSaving filing) {//
Application.getApplication().setOpenFileHandler(this);
myFiling=filing;
}
public List<File> getFiles() {
return files;
}
@Override
public void openFiles(OpenFilesEvent event) {
files = event.getFiles();
File myFile=new File(files.get(0).getAbsolutePath());
myFiling.readFile(myFile,true);
}
}
代码示例来源:origin: stackoverflow.com
import com.apple.eawt.*;
public class MyMainClass {
private static boolean listenerRegistered = false;
public static void main(String[] args) throws Exception {
if(!listenerRegistered) {
Application.getApplication().setOpenFileHandler(new OpenFilesHandler() {
public void openFiles(AppEvent.OpenFilesEvent evt) {
List<String> filenames = new ArrayList<String>();
for(File f : evt.getFiles()) {
filenames.add(f.getAbsolutePath());
}
MyMainClass.main(filenames.toArray(new String[filenames.size()]));
}
});
listenerRegistered = true;
}
// rest of main goes here
}
}
代码示例来源:origin: stackoverflow.com
if (System.getProperty("os.name").contains("OS X")){
com.apple.eawt.Application a = com.apple.eawt.Application.getApplication();
a.setOpenFileHandler(new com.apple.eawt.OpenFilesHandler() {
@Override
public void openFiles(com.apple.eawt.AppEvent.OpenFilesEvent e) {
for (Object oFile : e.getFiles()){
if (oFile instanceof File) {
File file = (File) oFile;
// do the actual open logic here
} else {
__l.warn("The OS just told us to open a file but handed us "+oFile.toString());
}
}
}
});
代码示例来源:origin: org.scijava/scijava-plugins-platforms
public MacOSAppEventDispatcher(final Application app,
final EventService eventService)
{
this.eventService = eventService;
app.setAboutHandler(this);
app.setPreferencesHandler(this);
app.setPrintFileHandler(this);
app.setQuitHandler(this);
app.addAppEventListener(this);
app.setOpenFileHandler(this);
}
代码示例来源:origin: raydac/netbeans-mmd-plugin
application.setOpenFileHandler(new OpenFilesHandler() {
@Override
public void openFiles(AppEvent.OpenFilesEvent ofe) {
代码示例来源:origin: stackoverflow.com
app.setPreferencesHandler(this);
app.setQuitHandler(this);
app.setOpenFileHandler(this);
app.setOpenURIHandler(this);
内容来源于网络,如有侵权,请联系作者删除!