Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-18 19:11:03
Quote
The way I got it working (clean and fast) was to NOT extend JFrame (like GameFrame) and maintain 2 protected JFrames.  The other key was to remove the Insets for the Windowed frame, as below (an extension of JFrame that has this method):


One slight problem with this is that the Insets are not set if you call:
1  
JFrame.setDefaultLookAndFeelDecorated(true);


I added a comment about this to this bug report:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050922

As a side note, when using a KeyListener to switch modes (with ALT-ENTER), it is necessary to put the code in keyReleased instead of keyTyped, as the keyTyped never gets an "ALT-ENTER" key.
1  
2  
3  
4  
5  
            public void keyReleased(KeyEvent event)
            {
                  if(event.isAltDown() && (event.getKeyCode() == VK_ENTER))
                        toggleFullScreen();
            }

2  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-18 19:06:22
Quote
It seems there are still 2 bugs present in the disposing of Frames.


I am not currently overriding dispose() at all. I do however have the RuntimeShutdownHook (from http://fivedots.coe.psu.ac.th/~ad/jg/ch03/index.html):

called during init:
1  
            readyForTermination();

and then...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
      protected void readyForTermination()
      {
            Runtime.getRuntime().addShutdownHook(
                  new Thread()
                  {
                        public void run()
                        {
                              fpsTimer.end();
                              setFullScreen(false);
                        }
                  }
            );
      }


this ensures that it is back in the original windowed display mode.
3  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-18 17:06:56
Ok, I got it working. I had been trying to extend JFrame and either modify it or use it with another protected instance of JFrame.

I looked over the Balls.jar example a few times, and couldn't find where setFullScreen was actually doing anything.  I realized that SOME of the source files were not included.  Using FrontEndPlus, I reversed the other class files (specifically GameFrame), and saw where those changes were.

The way I got it working (clean and fast) was to NOT extend JFrame (like GameFrame) and maintain 2 protected JFrames.  The other key was to remove the Insets for the Windowed frame, as below (an extension of JFrame that has this method):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      public Rectangle getInsetBounds()
      {
            Rectangle bounds = this.getBounds();
            Insets fi = this.getInsets();
            return new Rectangle(
                  bounds.x + fi.left,
                  bounds.y + fi.top,
                  bounds.width - (fi.left + fi.right),
                  bounds.height - (fi.top + fi.bottom)
            );
      }


I would like to say, for any Sun developers who might be watching this, that I think it would be of great benefit (and cleanness of code) to be able to toggle between fullscreen and windowed modes on a single JFrame.  The gfxDevice.setFullScreen(boolean) does not allow for this because of the inability to call setUndecorated(boolean) after the Peer has been created (without calling removeNotify/addNotify).

Thanks everyone for the assistance.
4  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-18 15:01:07
Quote
I'd post the code (which is quite different from the original balls now..), if only I had the time to create a project on java.net..

I'm not saying that there's no bug there, though.. Please file one..


How do I find that code?

Thanks.
5  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-18 14:58:51
Quote
I have  a test, which is a derivative from the infamous Balls,which automatically changes to and from fullscreen mode for all display modes available, and that thing runs through a whole night of switching.. =)


You know, I tried the original Balls.jar, and it worked OK -- but windowed mode was still fullscreen (ie: no decorations)....
6  Java Game APIs & Engines / Java 2D / Re: Fullscreen/Windowed mode toggling on: 2004-06-17 17:03:41
I am using 1.5.0b2 right now. I looked through the docs on b3, but it did not appear there were any changes to the FSEM handling.

I was however doing the mode change from the mouseListener.... hmm, I will take a look at that.
7  Java Game APIs & Engines / Java 2D / Fullscreen/Windowed mode toggling on: 2004-06-17 16:26:54
I've looked through the various JavaGaming posts (including the Balls.jar example) and the Java Forums. I can't seem to find any information on how to correctly toggle between Fullscreen (and undecorated) and Windowed (and decorated) modes.

I have tried a few different ways. I have tried using 2 JFrames (one decorated and one not) as well as using the addNotify/removeNotify so that I could call setUndecorated on a single JFrame.  In either case, it sometimes goes blank when switching back into Fullscreen, even though the Active Rendering loop continues to process.

Does anyone have a simplistic example of how to switch back and forth between the two modes?
8  Discussions / Jobs and Resumes / Malachi de AElfweald on: 2002-11-03 23:41:00
Resume, work history, and references are available at http://eoti.org/~malachi/resume
Pages: [1]
 

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 (22 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (189 views)
2014-04-01 02:16:10
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

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!