如何在Mac上的eclipse中创建一个JFrame
窗口,该窗口的图标使窗口全屏显示在右上方大多数窗口的双箭头图标上?
答案 0 :(得分:4)
看看
<强>更新强>
幸运的是JFrame
通过Window
... {/ p>延伸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();
}
}
}