Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put JFrame into FullScreen and automatically rescale content

I want go full screen and keep everything inside in order.

How should i put the JFrame into full screen AND rescale everything inside: images, generated drawings etc.(sth like zooming it up so the content will fit the screen).

The problem is I am making full screen app, but I don't know on what screen it will be displayed.

This will put the frame into fullscreen, but the content will not be rescaled

   frame.dispose();
   frame.setUndecorated(true);
   frame.setLocation(0, 0);
   frame.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
   frame.setVisible(true);
   frame.repaint();
like image 865
Yoda Avatar asked Feb 20 '23 13:02

Yoda


1 Answers

Depends on what it is that you want to scale.

  • If its graphics you draw using Java2D, just figure out how much the stuff needs to be scaled up and use Graphics2D.scale() to scale the gfx appropiately.

  • If its something with a Swing layout, use a Layout manager to make an adaptive layout.

  • If its something else, elaborate on your problem

like image 163
Durandal Avatar answered Mar 11 '23 05:03

Durandal