Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems with setFullScreenWindow() - crash to desktop

797060Mar 1 2011 — edited Mar 7 2011
Hello everyone,

I am trying to make my application have an option to go "full screen" (ie without decoration and start menu etc). Everything was going well, untill I tested a bit more thoroughly with dual moniters (which I have to support) I made a moniter chooser and everything - it wall works apart from these random crashes that happen.

The following is a small exmple that shows whats going on (at least it does on my computer):
import java.awt.BorderLayout;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class Test extends JComponent
{
	private JFrame f1;
	private JFrame f2;
	private JLabel l;

	public Test()
	{
		f2 = new JFrame("test");
		f2.setVisible(true);
		f2.setSize(200,200);
		f2.addKeyListener(new EscapeOutKeyListener());
		l = new JLabel("Press ALT+F4 to exit fullscreen.", SwingConstants.CENTER);
 		f2.add(l, BorderLayout.CENTER);
	}
	
	public static void main(String[] args)
	{
		Test t = new Test();
    }
	
	class EscapeOutKeyListener implements KeyListener
	{
		@Override
		public void keyPressed(KeyEvent e)
		{
			if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
			{
				GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
				f1.setVisible(false);
				f2.add(l, BorderLayout.CENTER);
				f2.validate();
			}
			if (e.getKeyCode() == KeyEvent.VK_SPACE)
			{
				f1 = new JFrame("test");
				f1.setUndecorated(true);
				f1.setVisible(true);
				f1.setSize(200,200);
				f1.setResizable(false);
				f1.addKeyListener(new EscapeOutKeyListener());
		 		f1.add(l);
		 		
		 		GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(f1);
			}
		}
		@Override
		public void keyReleased(KeyEvent arg0){}
		@Override
		public void keyTyped(KeyEvent arg0){}
	}
}
The best way of re-producing it I have found is opening the application, pressing "space" (go fullscreen) press "escape" (cancel full screen) then move the window from one moniter to the next. The crash I get is:

-----
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d0b6ad0, pid=18340, tid=17800
#
# JRE version: 6.0_21-b07
# Java VM: Java HotSpot(TM) Client VM (17.0-b17 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [awt.dll+0xb6ad0]
#
# An error report file with more information is saved as:
# C:\Users\tofuser\scworkspace\subclipsejava\hs_err_pid18340.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

I hope someone can help!

Thanks

Edit: I't isn't happening very often with my example program, it happens prety much every time with my main one. It took about 10 tries of maximizing, minimizing and moving from one moniter to the other to get it to happen...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2011
Added on Mar 1 2011
7 comments
557 views