0

JFrame右上のほとんどのウィンドウの二重矢印アイコンのようにウィンドウを全画面表示にするアイコンを持つMacでEclipseのウィンドウを作成するにはどうすればよいですか?

4

1 に答える 1

4

を見てみましょう

アップデート

あなたにとって幸運なのJFrameWindow...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();
        }
    }
}
于 2012-10-05T19:03:09.240 に答える