我如何创建一个JFrame
Mac 上 eclipse 中的窗口有一个图标,可以使窗口全屏显示,就像大多数窗口右上角的双箭头图标一样?
看一眼
- OSX Lion 上 Java 应用程序的全屏功能 https://stackoverflow.com/questions/6873568/fullscreen-feature-for-java-apps-on-osx-lion
- And Java 运行时系统属性 http://developer.apple.com/library/mac/ipad/#documentation/Java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html,可能会感兴趣
- or 如何在 OSX 上用 Java 实现全屏显示 https://stackoverflow.com/questions/1155838/how-can-i-do-full-screen-in-java-on-osx如果这些功能不是您想要的
UPDATE
算你走运JFrame
延伸Window
via Frame
...
public class TestMacFullScreen {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setLayout(new BorderLayout());
JLabel label = new JLabel("Look ma, no hands");
frame.add(label);
enableOSXFullscreen(frame);
frame.setVisible(true);
}
});
}
public static void enableOSXFullscreen(Window window) {
try {
Class util = Class.forName("com.apple.eawt.FullScreenUtilities");
Class params[] = new Class[]{Window.class, Boolean.TYPE};
Method method = util.getMethod("setWindowCanFullScreen", params);
method.invoke(util, window, true);
} catch (ClassNotFoundException exp) {
exp.printStackTrace();
} catch (Exception exp) {
exp.printStackTrace();
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)