views:

342

answers:

3

hello, how would you make a JComponent (panel, frame, window, etc.) fullscreen so that it also overlaps everything on the screen including the windows startbar?

i dont want to change the resolution or anything with the graphics device like bitdepth etc, i just want to overlap everything else.

thanks!

+6  A: 

You need to use the following API: http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

Going full screen isn't as simple as making a large panel, you need to look into the underlying OS graphics. But your JPanel code should translate just fine.

Sandro
+9  A: 

Check out this tutorial describing Java's Full-Screen mode API.

Example code (taken from the tutorial). Note that the code operates on a Window so you would need to embed your JPanel with a Window (e.g. JFrame) in order to do this.

GraphicsDevice myDevice;
Window myWindow;

try {
    myDevice.setFullScreenWindow(myWindow);
    ...
} finally {
    myDevice.setFullScreenWindow(null);
}
Adamski
+2  A: 

You can try some of the codes in this page, allowing a container to fill the screen (so it is not a solution for an individual component, but for a set of components within a container like a JFrame)

public class MainWindow extends JFrame
{
  public MainWindow()
  {
    super("Fullscreen");
    getContentPane().setPreferredSize( Toolkit.getDefaultToolkit().getScreenSize());
    pack();
    setResizable(false);
    show();

    SwingUtilities.invokeLater(new Runnable() {
      public void run()
      {
        Point p = new Point(0, 0);
        SwingUtilities.convertPointToScreen(p, getContentPane());
        Point l = getLocation();
        l.x -= p.x;
        l.y -= p.y;
        setLocation(l);
      }
    });
  }
  ...
}
VonC