Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Questions (graphic)  (Read 1299 times)
0 Members and 1 Guest are viewing this topic.
Offline Archibald

Junior Devvie

Projects: 1

« Posted 2012-02-26 22:05:28 »

For Java2D/AWT, if some of these are not available with AWT but available with other libraries please mention it.

- how to open application in full screen mode?
- how to switch between full screen/windowed mode?
- how to change screen resolution?
- how to list all available resolutions?
- how to obtain the current resolution of the user's system?

I prefer reading source codes than tutorial/articles. So ideally a link to some example sources that does these things. But I'm not picky Cheesy
Offline 65K
« Reply #1 - Posted 2012-02-26 22:19:26 »

display modes
Component component = ...
GraphicsConfiguration graphicsConfiguration = component.getGraphicsConfiguration();
GraphicsDevice device = graphicsConfiguration.getDevice();
DisplayMode[] modes = device.getDisplayModes();

full screen
Window frame = ...
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Offline ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #2 - Posted 2012-02-27 01:50:50 »

1. To make full screen, you can use the code 65K showed. Do note that JFrame extends Frame, which extends Window so you can set a JFrame full screen.
To make it full screen at the native resolution, don't set a display mode.

2. To switch back to windowed mode, do setFullScreenWindow(null).

3. To switch resolutions, do "device.setDisplayMode(DisplayMode)"

4 and 5. You don't have to rely on a Component to get the available display modes:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice[] devices = ge.getScreenDevices(); // returns the settings for all monitors

GraphicsDevice gd = ge.getDefaultScreenDevice(); // return the default screen device

DisplayMode[] modes = gd.getDisplayModes(); // all supported display modes

DislayMode currentMode = gd.getDisplayMode(); // current display mode

GraphicsConfiguration gc = currentMode.getDefaultConfiguration(); // very useful methods, such as creating compatible BufferedImage that will allow for faster render to the screen

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2012-02-27 02:05:28 »

That's basically it.

Be aware that switching from fullscreen out and in and sometimes cause some vague errors in the window manager, primarily of course in linux
you may have to reset the size and stuff.

do use bufferstrategy

and some commands can only be made in correct order, like you have to set setUndecorated(true) before setfullscreen(true)

Pages: [1]
  ignore  |  Print  

DesertCoockie (21 views)
2018-05-13 18:23:11

nelsongames (69 views)
2018-04-24 18:15:36

nelsongames (66 views)
2018-04-24 18:14:32

ivj94 (750 views)
2018-03-24 14:47:39

ivj94 (80 views)
2018-03-24 14:46:31

ivj94 (596 views)
2018-03-24 14:43:53

Solater (96 views)
2018-03-17 05:04:08

nelsongames (169 views)
2018-03-05 17:56:34

Gornova (379 views)
2018-03-02 22:15:33

buddyBro (1039 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!