Skip to main content

Plugin2: Applet fullscreen NPE in D3DGraphicsDevice.addFSWindowListener()

15 replies [Last post]
jayv
Offline
Joined: 2007-08-14
Points: 0

I'm trying to get a (JavaFX) applet to true full screen, unfortunately it doesn't work and gives a NPE, on a regular JFrame it works as expected.

GraphicsDevice gd = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
Window win = JOptionPane.getFrameForComponent(applet)
gd.setFullScreenWindow(win);

The window is of type:

javax.swing.SwingUtilities$SharedOwnerFrame[frame1,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=,resizable,normal]

Exception in thread "AWT-EventQueue-3" java.lang.NullPointerException
at sun.java2d.d3d.D3DGraphicsDevice.addFSWindowListener(Unknown Source)
at sun.awt.Win32GraphicsDevice.setFullScreenWindow(Unknown Source)

java version "1.6.0_10-beta"
Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b14)
Java HotSpot(TM) Client VM (build 11.0-b11, mixed mode, sharing)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kbr
Offline
Joined: 2003-06-16
Points: 0

> When I launched IRIS it first asked me to change the
> parameter "-Dsun.java2d.noddraw=true" in
> deployment.properties. At first I didn't do it, and I
> experienced the same issues I was having with the
> exclusive FS mode (drawing issues, mostely black
> covered parts).

I apologize for this. I've been lax in updating Iris to stop messing around with deployment.properties and take advantage of the new plug-in's functionality to turn off DirectDraw acceleration, which conflicts with OpenGL (used by the 3D views in Iris) at the driver level. I'll push this out shortly, which should get rid of that prompt and global modification to deployment.properties.

Please post your issue with your (non-JOGL) applet not rendering correctly on the 6uN early access forum. It sounds like an issue with the new D3D acceleration in 6u10 that may require a workaround for a buggy graphics driver.

jayv
Offline
Joined: 2007-08-14
Points: 0

> I apologize for this. I've been lax in updating Iris

No prob, you guys have more important things to to ;-)

> forum. It sounds like an issue with the new D3D
> acceleration in 6u10 that may require a workaround
> for a buggy graphics driver.

-Edit-
Today I retried the applet without the D2D flag but the weird thing is that I can't reproduce the problem anymore. I guess the NPE I received earlier upon setting the sharedownerframe to Excludive FS mode probably messed up my drivers. Lets mark this one as won't fix ;-)

Thanks,

Jo

kbr
Offline
Joined: 2003-06-16
Points: 0

FYI, Iris is back up and if you visit it with the new Java Plug-In you should never again receive a prompt about modifying deployment.properties to work around the DirectDraw / OpenGL issues.

Iris uses old-style (non-JNLP) applets right now, so I simply added

to the applet tags, FYI.

jayv
Offline
Joined: 2007-08-14
Points: 0

I did various tests and aparently something of about the same size as the applet (700x500) keeps popping in front of the frame's content (in my case a big dark rect) in exclusive mode.
I can only conclude there is still an Exclusive FS issue with applets.
Sometimes when I alt-tab away from the FS frame and back then it draws the FS frame OK.

If you wonder what it looks like: Notice the dark rect in front of my giant button ;-)

http://img528.imageshack.us/img528/7548/exclusivefsnz9.png

demonduck
Offline
Joined: 2008-03-14
Points: 0

I be confused...

The link you provided doesn't look like a fullscreen exclusive mode.

Is that what you are trying to show me? I don't understand what you are trying to demonstrate.

Here's my current use of full screen exclusive mode (ok, it's not really exclusive).

http://pancyl.com/

Enter/Exit -- F1/ESC

jayv
Offline
Joined: 2007-08-14
Points: 0

> I be confused...
>
> The link you provided doesn't look like a fullscreen
> exclusive mode.

How's that? It's as fullscreen as it gets, 1400x1050. As when you play a video fullscreen with media player. This works in a regular Java application.

> Is that what you are trying to show me? I don't
> understand what you are trying to demonstrate.

It's a slimmed down test-case to see what causes the problem, just a JFrame with a JButton, maximum use of space (no toolbars, taskbars, menubars), it's not a real application ;-)

> Here's my current use of full screen exclusive mode

I think we're talking about the same thing...You are using the undecorated JFrame approach with setSize(screenSize); and setLocation(0,0); I presume.

demonduck
Offline
Joined: 2008-03-14
Points: 0

I just see an ordinary browser window. I'm using FF2; Windows2000 SP4; Java 1.6.0.5

It's just a light blue rectangle with a smaller black rectangle at the top -- in an ordinary browser window.

I'm just using a Frame. No Swing components in my applet. And I set the bounds of the Frame to the size returned by the display device. I don't set the location but I do set undecorated and noResize.

I'll post the code if you want to see it.

jayv
Offline
Joined: 2007-08-14
Points: 0

> It's just a light blue rectangle with a smaller black
> rectangle at the top -- in an ordinary browser
> window.

That's because it's a link to a screenshot of my fullscreen mode...
That lightblue thing is a huge JButton, and the black thing is... the BUG ;-)

> I'll post the code if you want to see it.

Thx, but it's OK, it's basically the approach I described, and used in the past. But for this application I want 100% fullscreen, also on OSX.

jayv
Offline
Joined: 2007-08-14
Points: 0

> window. The Iris demo (http://iris.dev.java.net/) has
> at least one example of how to do this (for a Java,
> not a JavaFX, applet) and I would encourage you to
> take a look at the source code.

It's interesting that you mention this because Iris has the same issue on my machine...

When I launched IRIS it first asked me to change the parameter "-Dsun.java2d.noddraw=true" in deployment.properties. At first I didn't do it, and I experienced the same issues I was having with the exclusive FS mode (drawing issues, mostely black covered parts).
I then killed all Java processes and the browser and changed my config to include that parameter and since then Iris works very well including Exclusive FS mode. This made me retry my applet and joy it has the same positive effect on my applet.

However this doesn't solve my problem if it's not the default setting in the JRE, so potentially my users could have the same problems don't you think?

-Edit-: In fact I could also add it in the JNLP (still have to get used to the fact that we have a JNLP now :-) But I'd still like to know what the possible consequences of this parameter are and if it's the best (temporary) solution as I don't use JOGL and I do want Java 2D accelerated Scenegraph/JavaFX/Reprise.

demonduck
Offline
Joined: 2008-03-14
Points: 0

>
> However this doesn't solve my problem if it's not the
> default setting in the JRE, so potentially my users
> could have the same problems don't you think?
>

Humm... you really think that the average user would have problems setting a simple thing like a JVM parameter using the Java Control Panel? Gee whiz -- I thought average uses were fully certified Java programmers.

All my users regularly edit and modify all the config and properties files with joy in their heart. And they tell me that they look forward to experimenting with all the different new features of the applet tag. They comment positively about finally being able to configure the runtime environment of applets using jnlp files.

A golden new age dawns!

kbr
Offline
Joined: 2003-06-16
Points: 0

A couple of things are going wrong. The first is that JOptionPane.getFrameForComponent() isn't returning the real frame containing your applet. I'm not sure why this is the case but it may depend upon exactly when you are calling the above code. If you haven't reached Applet.init() or Applet.start() then this is probably why it's returning the "SharedOwnerFrame". I'm working with JavaFX tech lead Chris Oliver to clear up some issues with the implementation of applets inside JavaFX so this should become easier in the long run.

Second, I really don't think you can do the operation you're doing to implement a full-screen applet. For correctness, you need to unparent the applet from its current parent and put it in to a new top-level undecorated Frame and make that Frame the full-screen window. The Iris demo (http://iris.dev.java.net/) has at least one example of how to do this (for a Java, not a JavaFX, applet) and I would encourage you to take a look at the source code.

jayv
Offline
Joined: 2007-08-14
Points: 0

I set fullscreen mode on a button click so Applet.init() should have been called.

I wasn't sure if this was the way to go but I've used this approach in the past (plugin1) to create modal dialogs on applets. So I was kinda hoping it would work for fullscreen mode...

As it didn't work, I was already hacking my way around it like you suggested, by gettting the applet's content pane and dropping it in a new JFrame and resetting it back when exiting full screen mode. It seems to work almost, I'm getting black flashes and other repainting issues... I'll keep you posted...

Oh and I don't want to go for undecorated JFrame, this leaves a menu bar on OSX and I want FULL full screen ;-)

Message was edited by: jayv

demonduck
Offline
Joined: 2008-03-14
Points: 0

You can't do full screen exclusive mode in an applet. I've tried.

This is from the documentation and it's a lie:

[i]When in full-screen exclusive mode, you don't have to worry anymore about the window being resized, moved, exposed, or occluded (unless you've ignored my suggestion to turn off resizing). Instead, the application window is drawn directly to the screen (active rendering). This simplifies painting quite a bit, since you don't ever need to worry about paint events. In fact, paint events delivered by the operating system may even be delivered at inappropriate or unpredictable times when in full-screen exclusive mode.[/i]

1) The full screen window will always have a banner at the bottom that says, "Java Applet Window" You can't turn this off and you can't write to it.

2) You have to get the insets of your frame and subtract the width of the banner to get your drawing area size.

3) On Windows, full screen exclusive mode leaves the task bar showing so that the user can raise any window over your full screen "exclusive mode" frame. So you have to handle paint events.

I used to use setFullScreenWindow(myWindow) as documented in:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html

But now I just use the same window and the same initialization and then just setVisible(true) on the Frame and handle the paint() events.

As far as I can tell, full screen exclusive mode is just another fantasy of the Java Development Team.

Just thought I throw in something else for the Java Development Team to ignore and rationalize away...

jayv
Offline
Joined: 2007-08-14
Points: 0

1) I have no banner... But I do have a signed applet which removes this.

2) n/a, cause no banner ;-)

3) in what I have for now there is no taskbar either

I still do have some drawing problems, I yet have to figure out what's going on, but the (temporary) JFrame that I created does come up in exclusive mode like in a regular application. So I believe it can be done, I'll keep you guys posted if I get it to work.

demonduck
Offline
Joined: 2008-03-14
Points: 0

Ah -- a signed applet. Different breed of applet. Normal unsigned applets behave differently -- apparently.