Entering / Exiting FullscreenMode

Hello everyone,

I would like to switch from fullscreenmode to windowed mode and windowed mode to fullscreen mode.

I have tried

  • Fullscreen to Windowed :

setFullScreenWindow(null);
setSize(800, 600);

but there i can’t use setUndecorated(false) because the window is displayable. Is there a way to make a JFrame not Dispayable without destroying it (i tried setVisible(false) didn’t work) ?

  • Windowed to FullScreen :

after using the setSize(800, 600) it seems that there is no way back to fullscreen.

Thanks for your help.

Don’t even bother trying; its bugged to hell.

With a good number of hacks its possible to get it almost working, however there is still 1 bug (a disposer crash in the GC) that is unworkroundable :stuck_out_tongue:

I think the promise is ‘it will be fixed in Java1.5’. We can only hope :-/

“unworkaroundable” nice word :slight_smile:

I hope it’ll be fixed in 1.5… “please restart” doesn’t really cut it :-/

you have to dispose() and pack() it again. Works, but sometimes has some flaws.

There is a Tutorial on suns site

howto switch to fullscreen and vice versa

also look here

http://javaalmanac.com/egs/java.awt/screen_FullWin.html

when switching back from fullscreen to windowed mode DO NOT SET DISPLAY MODE

use this

setFullScreenWindow(null)

and everything will be fine

Fullscreen to Windowed Mode switching is not perfect at the moment, but it works in my app without crashing, but i cant post any code here.

Also look for old posts from me here, we discussed this problem earlier

that example doesn’t deal with turning decoration on/off.

That is the root of all the problems.

the website is a good resource for beginners, maybe its helps him.

abuse i solved the decoration problem, switching is no problem.

[quote]the website is a good resource for beginners, maybe its helps him.

abuse i solved the decoration problem, switching is no problem.
[/quote]
So you’ve found a workaround for the Disposer crash?!

Yes from Fullscreen to Windowed

simply call setFullscreen(null)

DO NOT change Display with setDisplayMode

In rare cases it crashs the app

I use one window ( not the 2 window workaround )

P.S.: I use same bitdepth in windowed and fullscreen ( 16bit )

My problem wasn’t to use setFullScreen(null).

It was after when I try to put decoration back with :

setUndecorated(false)

it throws an exception telling me that the window is displayable…

Thanks for the site anyway it answered others questions.

So Many bugs to fix, So little Time !

A displayable window cannot have its decoration changed.
Therefor you have to call dispose() on the window to release it from its native screen resources.
You can then change the decoration, and make the window visible again.
However, im 99.9% sure its still buggy and will cause a crash.

Whoua my best java crash ever !!!

java.awt.IllegalComponentStateException: The frame is displayable.
at java.awt.Frame.setUndecorated(Frame.java:800)
at GameKeyListener.keyReleased(GameKeyListener.java:37)
at java.awt.AWTEventMulticaster.keyReleased(AWTEventMulticaster.java:201)
at java.awt.AWTEventMulticaster.keyReleased(AWTEventMulticaster.java:201)
at java.awt.AWTEventMulticaster.keyReleased(AWTEventMulticaster.java:201)
at java.awt.Component.processKeyEvent(Component.java:5061)
at java.awt.Component.processEvent(Component.java:4909)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Window.processEvent(Window.java:1092)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
at java.awt.Component.dispatchEventImpl(Component.java:3506)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException: component argument pData
at sun.awt.windows.Win32BackBufferSurfaceData.initSurface(Native Method)
at sun.awt.windows.Win32BackBufferSurfaceData.createData(Win32BackBufferSurfaceData.java:49)
at sun.awt.windows.Win32BackBuffer.createHWData(Win32BackBuffer.java:28)
at sun.awt.windows.WVolatileImage.initAcceleratedBackground(WVolatileImage.java:100)
at sun.awt.windows.Win32BackBuffer.displayChanged(Win32BackBuffer.java:35)
at sun.awt.SunDisplayChanger.notifyListeners(SunDisplayChanger.java:102)
at sun.awt.Win32GraphicsEnvironment.displayChanged(Win32GraphicsEnvironment.java:98)
at sun.awt.windows.WToolkit$4.run(WToolkit.java:734)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x2CAB3DC
Function=Java_sun_print_Win32PrintJob_endPrintRawData+0x52A8
Library=C:\j2sdk1.4.2_01\jre\bin\awt.dll

Current Java thread:
at sun.java2d.loops.MaskBlit.MaskBlit(Native Method)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(AlphaPaintPipe.java:138)
at sun.java2d.pipe.SpanShapeRenderer$Composite.renderBox(SpanShapeRenderer.java:42)
at sun.java2d.pipe.SpanShapeRenderer.renderRect(SpanShapeRenderer.java:168)
at sun.java2d.pipe.SpanShapeRenderer.fill(SpanShapeRenderer.java:119)
at sun.java2d.pipe.PixelToShapeConverter.fillRect(PixelToShapeConverter.java:44)
at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2065)
at HitPoints.draw(HitPoints.java:35)
at Jeu.render(Jeu.java:117)
at Jeu.run(Jeu.java:187)
at java.lang.Thread.run(Thread.java:534)

Dynamic libraries:
0x00400000 - 0x00407000 C:\j2sdk1.4.2_01\bin\javaw.exe
0x77F40000 - 0x77FEE000 C:\WINDOWS\System32\ntdll.dll
0x77E40000 - 0x77F36000 C:\WINDOWS\system32\kernel32.dll
0x77DA0000 - 0x77E3E000 C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x7807E000 C:\WINDOWS\system32\RPCRT4.dll
0x77D10000 - 0x77D9C000 C:\WINDOWS\system32\USER32.dll
0x77C40000 - 0x77C80000 C:\WINDOWS\system32\GDI32.dll
0x77BE0000 - 0x77C33000 C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08136000 C:\j2sdk1.4.2_01\jre\bin\client\jvm.dll
0x76AE0000 - 0x76B0E000 C:\WINDOWS\System32\WINMM.dll
0x6BD00000 - 0x6BD0D000 C:\WINDOWS\System32\SYNCOR11.DLL
0x10000000 - 0x10007000 C:\j2sdk1.4.2_01\jre\bin\hpi.dll
0x00820000 - 0x0082E000 C:\j2sdk1.4.2_01\jre\bin\verify.dll
0x00830000 - 0x00848000 C:\j2sdk1.4.2_01\jre\bin\java.dll
0x00850000 - 0x0085D000 C:\j2sdk1.4.2_01\jre\bin\zip.dll
0x02C40000 - 0x02D4F000 C:\j2sdk1.4.2_01\jre\bin\awt.dll
0x72F50000 - 0x72F73000 C:\WINDOWS\System32\WINSPOOL.DRV
0x76320000 - 0x7633C000 C:\WINDOWS\System32\IMM32.dll
0x77170000 - 0x77287000 C:\WINDOWS\system32\ole32.dll
0x5B090000 - 0x5B0C4000 C:\WINDOWS\System32\uxtheme.dll
0x02FC0000 - 0x03010000 C:\j2sdk1.4.2_01\jre\bin\fontmanager.dll
0x736B0000 - 0x736F4000 C:\WINDOWS\System32\ddraw.dll
0x73B10000 - 0x73B16000 C:\WINDOWS\System32\DCIMAN32.dll
0x73890000 - 0x73957000 C:\WINDOWS\System32\D3DIM700.DLL
0x74690000 - 0x746D4000 C:\WINDOWS\System32\MSCTF.dll
0x07470000 - 0x07492000 C:\j2sdk1.4.2_01\jre\bin\dcpr.dll
0x76C40000 - 0x76C62000 C:\WINDOWS\system32\imagehlp.dll
0x6D9E0000 - 0x6DA5D000 C:\WINDOWS\system32\DBGHELP.dll
0x77BD0000 - 0x77BD7000 C:\WINDOWS\system32\VERSION.dll
0x76BA0000 - 0x76BAB000 C:\WINDOWS\System32\PSAPI.DLL

Heap at VM Abort:
Heap
def new generation total 576K, used 220K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 36% used [0x10010000, 0x1003f2e8, 0x10090000)
from space 64K, 49% used [0x100a0000, 0x100a7ee0, 0x100b0000)
to space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
tenured generation total 3284K, used 2473K [0x104f0000, 0x10825000, 0x14010000)
the space 3284K, 75% used [0x104f0000, 0x1075a480, 0x1075a600, 0x10825000)
compacting perm gen total 4096K, used 3589K [0x14010000, 0x14410000, 0x18010000)
the space 4096K, 87% used [0x14010000, 0x14391468, 0x14391600, 0x14410000)

Local Time = Sat Oct 11 13:02:31 2003
Elapsed Time = 26

The exception above was detected in native code outside the VM

Java VM: Java HotSpot™ Client VM (1.4.2_01-b06 mixed mode)

An error report file has been saved as hs_err_pid1872.log.

Please refer to the file for further information.

Nice isn’t it ?

Maybe … i should not do anything with a disposed component :wink: