Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (499)
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  
  Anyone else have problem when switching to and from full screen?  (Read 1079 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2006-12-22 00:07:45 »

I use

graphicsDevice.setFullScreenWindow(null);  /*switching to windowed mode*/

and graphicsDevice.setFullScreenWindow(window); /*switching to full screen*/

i also set the display to 1024, 768, 32, 60

The problem arrises when i start switching frmo or to full screen.
My app is using 1024, 768 resolution, i use 1152x864 for my desktop and that is the problem. When switching TO full screen i find myself having a 1152x768 or whatever i.e extra width added to my JFrame, the resolution is still 1024, 768 so my  JFrame actually goes outside the screen.

What is the setMaximumsSize for anyway if they do not work. I want my maximum and only JFrame size to be 1024, 768 and I do not know how to ensure it.
of 1024x768 and that is despite me using updateUI(), setSize(1024, 768) or repaint() afterwards.

Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #1 - Posted 2006-12-22 04:21:15 »

Using setSize is not how to set the correct size when going to fullscreen.  You need to use GraphicsDevice.setDisplayMode().  And to make sure you have the correct DisplayMode, you should call GraphicsDevice. getDisplayModes(), which returns an array of all the DisplayModes that the graphics card is capable of.

Offline fletchergames

Senior Member





« Reply #2 - Posted 2006-12-22 17:10:33 »

setMaximumSize and so forth are only for use by Layouts, not to be used on the main frame.  If you don't want the main frame to be resizable at all, use setResizable.  If you want it to be resizable but only to certain sizes, you probably need to use a ComponentListener or WindowListener or something.

Also, many layouts don't use the values set by methods like setMaximumSize.

It's pretty messed up how it's organized, but it's never going to change.  Since minimum/maximum/preferred sizes are used by layouts (not components), they should be stored by the layouts, not the components themselves.  There would be a little extra overhead (probably from creating an object storing a Component and its various sizes and constraits), but it would be much better organized.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zappsweden

Junior Member




Java games rock!


« Reply #3 - Posted 2006-12-22 22:39:04 »

Using setSize is not how to set the correct size when going to fullscreen.  You need to use GraphicsDevice.setDisplayMode().  And to make sure you have the correct DisplayMode, you should call GraphicsDevice. getDisplayModes(), which returns an array of all the DisplayModes that the graphics card is capable of.

i did that already (sorry i did not explain), i used setDisplayMode to 1024, 768, 32, 60 and it did exist in the DisplayModes also (looped them through). I also have my JFrame as setresizable(false)

in fact i have a TheScreen class that extends JFrame and is the one I use always, then the screens of the game are big 1024, 768 JPanel that i put into the TheScreen




public void showWindow(JPanel jf)
  {
    this.jPanel1.removeAll();
    this.jPanel1.add(jf, BorderLayout.CENTER);
    this.jPanel1.updateUI();
    jf.requestFocus();

  }

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2006-12-22 23:09:57 »

eh... updateUI() is for changing the L&F, use repaint() and revalidate() to update your components

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zappsweden

Junior Member




Java games rock!


« Reply #5 - Posted 2006-12-22 23:17:16 »

eh... updateUI() is for changing the L&F, use repaint() and revalidate() to update your components
I tried that one, still does not work.
Offline zappsweden

Junior Member




Java games rock!


« Reply #6 - Posted 2006-12-22 23:56:22 »

I came up with a unorthodox solution.
I use jPanel1 as north, to guarantie that the heigh is the height of jPanel 1 (which is 768). Then i creatse jPanel 2 and put it in jPanel1 in the WEST so that jPanel 2 guaranties width 1024. so, VOILA jPanel2 will be 1024x768.

So, i use my game screens now into JPanel2 and it works!
So, in summary i have one TheScreen extends JFrame with a method for showing a game screen into, the method puts the game screen into JPanel2. Only problem now is, after switching off and on full screen in game, the second time i push it off, it does not change size, i.e my window xp is at 1152, 864 and my game is at 1024x768 , after the toggles the windows xp seem to be at 1024x768 too.

Solved this by storing the windows xp resolution when starting up the game

 private static GraphicsDevice graphicsDevice=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  private static DisplayMode defaultDisplayMode = graphicsDevice.getDisplayMode();

so whenever i switch full screen OFF, i will call back the windows xp resolution

graphicsDevice.setDisplayMode(defaultDisplayMode)

which means i go to 1152, 864


IT WORKS NOW AND FEELS FANTASTIC!
Well, i wont see if it works until the testers run anyway.
 
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (44 views)
2014-04-15 18:08:23

BurntPizza (40 views)
2014-04-15 03:46:01

UprightPath (56 views)
2014-04-14 17:39:50

UprightPath (38 views)
2014-04-14 17:35:47

Porlus (54 views)
2014-04-14 15:48:38

tom_mai78101 (77 views)
2014-04-10 04:04:31

BurntPizza (136 views)
2014-04-08 23:06:04

tom_mai78101 (236 views)
2014-04-05 13:34:39

trollwarrior1 (197 views)
2014-04-04 12:06:45

CJLetsGame (205 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!