Skip to main content

Applet programming problem

13 replies [Last post]
chamorrus
Offline
Joined: 2007-07-31
Points: 0

Hi all!!

I have an applet developed in Java3D. It works perfectly with java applet viewer, but the problems begins when I try to put it into a web broser.
It loads perfectly but when I loss the focus of the browser window, the applet image seems to be "frozen". Same problem occurs when I try to refresh the web browser. The window stays in gray color and the web browser crashes.

I use the following environment:

- Java 3D 1.4.0_01
- Java 1.6.0_06
- Web browser Firefox 2.0.0.14

I think that I have programming problems... I mean that I think I have to redefine the paint(Graphics g) method but I don't know how to do that...

Any guide, tutorial, help, clues on how to do this?!
Thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chamorrus
Offline
Joined: 2007-07-31
Points: 0

It seems to be that a part of my post disappeared... Or just I can visualize it properly, so I post the piece dropped.

" public static void show(String layerName){
try {
//The code included here connects to another servlet and retrieves the BG of the layerName selected
insertBG(branchGroup);
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}

//The next method adds the BranchGroup to the TransformGroup for showing it
public static void insertBG(BranchGroup bgInsert){
myStaticClass.getTgRoot().addChild(bgInsert);
}

The code posted below works perfectly for the first load, but when I push the refresh button, I get the error commented before..

Thanks for your help Dmitri"

Dmitri Darine

:( Hmm... I don't see anything suspicious...
Except maybe canvas3D = myStaticClass.getInstance();
Maybe you should not initialize the canvas that way... No exception in
the console?

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

Nope, no exception...
How should I initialize canvas3D!?

Dmitri Darine

Can you replace that loadCanvas() with the canvas3D initialization from
java3d tutorials?
http://java.sun.com/developer/onlineTraining/java3d/j3d_tutorial_ch1.pdf
page 20

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

Ok, I'll try later...
Now I'm trying to solve the problem with the JNLPAppletLauncher. I'll post the results later.

Thanks!!!

Dmitri Darine

On 05.05.2008 10:14, java3d-interest@javadesktop.org wrote:
> Hi all!!
>
> I have an applet developed in Java3D. It works perfectly with java applet viewer, but the problems begins when I try to put it into a web broser.
> It loads perfectly but when I loss the focus of the browser window, the applet image seems to be "frozen". Same problem occurs when I try to refresh the web browser. The window stays in gray color and the web browser crashes.
>
>
Check that you have the latest drivers
> I use the following environment:
>
> - Java 3D 1.4.0_01
>
This version is old. Update it to 1.5.1
> - Java 1.6.0_06
> - Web browser Firefox 2.0.0.14
>
> I think that I have programming problems... I mean that I think I have to redefine the paint(Graphics g) method but I don't know how to do that...
>
>
No, you don't need to override the paint(). Just place your Canvas3D
into java.applet.Applet or javax.swing.JApplet

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

Thanks for you reply Dmitri.

That's what I did. I had my Canvas3D into a class that extended java.applet.Applet and I had running problems.

Now it seems to be solved (don't know what I've done but it really works now). The problem that I currently have is when I push the refresh button of the browser (or the F5 key). The Canvas3D turns to gray and the browser seems to be frozen.

Any clues?
Thanks again

Dmitri Darine

On 08.05.2008 12:59, java3d-interest@javadesktop.org wrote:
>
> Any clues?
>
Does it happened for all java3d applets or just for the yours? Try this
one: http://home.earthlink.net/~kduling/Java3D/First/

What videocard are you using?

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

It happens just for my applet... The link you posted works correctly. When I try to refresh the window I see the same black screen than before...

I'm developing on a laptop computer with a NVIDIA GeForce Go 7400

Dmitri Darine

Well :) then it means that something wrong with your code - I guess it
is in the java3d initialization phase.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

What do you mean by that?! Do I have to put the whole initialization code into the start() method of the applet?!

Dmitri Darine

Post the code please

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

chamorrus
Offline
Joined: 2007-07-31
Points: 0

Variable container is a JPanel() and the method included is of a class that extends from java.applet.Applet

public void init() {
Dimension dimension = new Dimension(800,600);
setLayout(new BorderLayout());
container.setMaximumSize(dimension);
container.setLayout(new BorderLayout());
add(container,BorderLayout.CENTER);
loadCanvas();
container.add(canvas3D,BorderLayout.CENTER);
try {
//The code included here connects to a servlet and receives an ArrayList with the name of the layers I want to show.
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
retrieveData();
}

//This method creates a new instance of the Canvas3D class.
private void loadCanvas(){
canvas3D = myStaticClass.getInstance();
}

//The next method uses an ArrayList called layers that contains the name of the layer I want to load.
public static void retrieveData(){
for (int i = 0; i < layers.size(); i++){
String layer = (String)layers.get(i);
show(layer);
}
}

public static void show(String layerName){
try {
//The code included here connects to another servlet and retrieves the BG of the layerName selected
insertBG(branchGroup);
} catch (IOException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}

//The next method adds the BranchGroup to the TransformGroup for showing it
public static void insertBG(BranchGroup bgInsert){
myStaticClass.getTgRoot().addChild(bgInsert);
}

The code posted below works perfectly for the first load, but when I push the refresh button, I get the error commented before..

Thanks for your help Dmitri