method toFront(), can it cause deadlock, freezing

Hi,

Can the use of the method toFront, contained in Frames, JFrames, Windows, JWindows, etc, etc, cause a program to freeze, i.e. - could you please look at my code below and tell me if what i've done is a no-no.

[code]

// the method Screen is the constructor for Class screen which extends a awt Frame,

public Screen(Basil b) {

this.setBackground(new Color(0,0,0));

this.setUndecorated(true);

/// it's this line here, because it's before set visible would it cause a program to freeze, deadlock?

this.toFront();

basil = b;

this.setVisible(true);

}

Any help welcome,

Andy.

[696 byte] By [Andy-D-Dog] at [2007-9-30 4:23:23]
# 1
It sounds a little like http://developer.java.sun.com/developer/bugParade/bugs/4838939.htmlSee if the environment matches yours and try the suggested workaround "java -Dsun.java2d.noddraw=true ..."
legosa at 2007-7-1 12:53:08 > top of Java-index,Archived Forums,Java Programming...
# 2

If you do that from a thread that is not the event dispatcher anything can and will happen.

From your code it is impossible to see if this is in the EDT or some other thread, I would guess that it is in some other thread. Adding something like:

SwingUtilities.invokeLater (new Runnable () {

public void run () {toFront ();}

})

may do the trick

Ernimril at 2007-7-1 12:53:08 > top of Java-index,Archived Forums,Java Programming...
# 3

>It sounds a little like http://developer.java.sun.com/developer/bugParade/bugs/4838939.html

>

>See if the environment matches yours and try the suggested workaround "java ->Dsun.java2d.noddraw=true ..."

Legosa, ur a legend.

You where spot on, i put that extra line when starting the app and now it never freezes. I would of posted earlier to give you much deserved praise but i had to test,test,test to be sure it was working.

Cheers man,

Helious.

P.s. as far as i know you don't need to place things into the main event dispatch thread untill the component is set visible. But for this app it doesn't really matter as I ain't using threads :) Thanks for the suggestion anyhow.

Andy-D-Dog at 2007-7-1 12:53:08 > top of Java-index,Archived Forums,Java Programming...