RE: Exception thrown - 2nd monitor

Hi Bill,
         I found a solution.

Looking in the VisADCanvasJ3D code, there is a static method called
makeConfig() that contains the following lines of code

 GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
 GraphicsDevice d = e.getDefaultScreenDevice();
 GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
 GraphicsConfiguration c = d.getBestConfiguration(template);

So it uses the Graphics Configuration from the default screen device which
is my 1st monitor.

The cause of the bug is that creating a DisplayImplJ3D without specifying a
graphics configuration means that a VisADCanvasJ3D is created using the 1st
(default) monitor's graphics configuration but my JDialog uses the Graphics
configuration of the screen it is about to appear on (2nd monitor).

So to fix the problem I use the above code to get the first monitor's
Graphics Configuration and then pass it to the
constructor of the DisplayImplJ3D and the JDialog that I'm putting the
display in.

So I assume this is a better solution than fixing the problem in
VisADCanvasJ3D by trying to find which screen device the visad canvas is
about to be created on.

Thanks for the help,


There were a couple of machines where the exception never happened...
maybe they had the same graphics configuration on both monitors or just
smarter graphics drivers???

-----Original Message-----
From: Bill Hibbard [mailto:billh@xxxxxxxxxxxxx]
Sent: Friday, 18 July 2003 21:11
To: Scott Anderson
Subject: Re: Exception thrown - 2nd monitor

Hi Scott,

>            The exception shown below is thrown when I open a JFrame with a
> visad display on my 1st monitor, then drag it to my 2nd monitor and click
> button to open a JDialog with another visad display in it.
> I've attached a small sample program that demonstrates this, so to try and
> repeat the bug:
> Run the program
> Drag the JFrame to your second monitor (you'll obviously need a dual head
> display)
> Click the Open JDialog button
>   And you should get an exception!!!
> An exception was thrown on 2 windows machines with Matrox DualHead
> cards
> and also a Linux machine with a dual head nvidia graphics card.
> Not sure if this is VisAD or Java3D, hoping someone could shed some light
> the cause...
> . . .
> java.lang.IllegalArgumentException: adding a container to a container on
> a different GraphicsDevice

It is hard to imagine how this is a VisAD bug.
It could be that the Java3D GraphicsConfiguration
must be different on different heads (although
that would seem to outlaw dragging Canvas3D's
between different heads). You might experiment
with the DisplayImplJ3D constructors that take
non-default GraphicsConfigurations.

I don't have any dual head displays, so someone
with one (you?) will have to work on this. Let us
know what you find.

I also suggest joining and sending this question
to java3d-interest@xxxxxxxxxxxxx

Good luck, Bill