1

I'm using the following code to create a fullscreen JFrame from my Eclipse plugin. The JFrame is shown, but I can't see my button. I have no idea why not:

public class MainFrame extends JFrame {

    private static final long serialVersionUID = 1L;

    public MainFrame() {
        super();

        createComponents();
        setFullScreen();

        this.setVisible(true);
    }

    private void createComponents() {
        System.out.println("Create components");
        JButton exit = new JButton("Exit");

        exit.setVisible(true);
        exit.setBackground(Color.YELLOW);
        exit.setSize(new Dimension(500, 500));
        exit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                System.out.println("Exit by button");
                System.exit(0);
            }
        });

        this.setBackground(Color.RED);


        this.getContentPane().setLayout(new BorderLayout());
        this.getContentPane().add(exit, BorderLayout.CENTER);
    }

    private void setFullScreen() {

        this.setResizable(false);
        this.setUndecorated(true);
        this.setAlwaysOnTop(true);

        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] devices = env.getScreenDevices();

        devices[0].setFullScreenWindow(this);
    }

}
mKorbel
  • 109,525
  • 20
  • 134
  • 319

1 Answers1

3

For reference, FullScreenTest is a working example.

Addendum: Because an Eclipse plugin must use SWT, you might try the approach shown in Full Screen your RCP Applications. The alternative of running maximized is also mentioned.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045