0

I am finding it hard to convert my JPanel into a lwjgl fullscreen display? is there another way or a guide on what you need to change:

This is what i am currently calling it with:

public void TowerDefence() {
    setLayout(new GridLayout(1, 1, 0, 0));

    Window window = new Window(this);
    add(window);

    setVisible(true);
}

And this is what is called to initialize the JPanel:

public Window(Frame frame) {
    frame.addMouseListener(new KeyHandler());
    frame.addMouseMotionListener(new KeyHandler());

    thread.start();
}

Do i need to change only inside this constructor? And what needs to be added in order for fullscreen to work?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
core16
  • 113
  • 2
  • 17

2 Answers2

1

See the lesson on the Full-Screen Exclusive Mode API in the tutorial.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Could you provide an example? I don't understand the documentation and when i try it it doesn't work? – core16 May 25 '12 at 11:57
  • What I could provide is irrelevant, since I don't intend to. Show some effort, post an SSCCE, and I might look further into it. Also note that "doesn't work" is about as useful as a screen-door on a submarine at describing the actual problem. What did you expect to happen? What actually happened? – Andrew Thompson May 25 '12 at 11:59
  • 1
    [`FullScreenTest`](http://stackoverflow.com/a/7457102/230513) may help you create your SSCCE. – trashgod May 25 '12 at 14:27
0

Try this:

frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
Vova
  • 160
  • 2
  • 12
  • What operation system is the code running on? I think there are some platforms on which this method is not supported... take a look the javadocs for this method – Vova May 25 '12 at 14:03