Empty JFrame when running code

Hi,

I'm trying to build some sort of a progress window with a progressbar and status field in it. Its supposed to update after a number of actions. And then continue with the code. Im trying to display the connection process to a MySQL server here. But when I run the code, the JFrame shows up empty. Not showing any object at all.

Immediatly after this code the window hides (code not shown)

I have narrowed down the problem to one line. This line makes the program halt for half a second or so when executing.

conn = DriverManager.getConnection(url,this.username,this.password)

when I comment out this part I get to see everything..

try{

this.lblStatus.setText("Loading driver...");

this.pgrEen.setValue(0);

Class.forName("org.gjt.mm.mysql.Driver");

this.lblStatus.setText("Connecting...");

this.pgrEen.setValue(50);

String url ="jdbc:mysql://" + this.hostname +":3306/";

conn = DriverManager.getConnection(url,this.username,this.password);

Statement c = conn.createStatement();

c.executeQuery("use `" + this.database +"`;");

this.pgrEen.setValue(100);

this.lblStatus.setText("Connected!");

main =new Main(logon,conn);

}

catch( Exception x ){

System.out.println(x.getMessage());

}

[1731 byte] By [Getaway007a] at [2007-10-2 18:17:07]
# 1
Does it show up greyed out and are you using an ATI graphics card?
vex001@gmail.coma at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 2
Well, your example isn't showing much. But you don't run both the GUI and the connection-making in the same thread, do you?
CeciNEstPasUnProgrammeura at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 3
> are you using an ATI graphics card?Pardon?
CeciNEstPasUnProgrammeura at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 4
Sometimes with an ATI graphics card, the JFrame fails to render. You simply have to Alt-Tab to an application to overlay your frame, then Alt-Tab back to see the frame.
vex001@gmail.coma at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 5

> Sometimes with an ATI graphics card, the JFrame fails

> to render. You simply have to Alt-Tab to an

> application to overlay your frame, then Alt-Tab back

> to see the frame.

I see. Never heard of that problem. Thanks. But I somehow don't think it's the issue here. I'd think it's a blocked AWT thread.

CeciNEstPasUnProgrammeura at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 6

I have an ati card yes but I have not yet had any problems concerning java gui's and my card

--

> Well, your example isn't showing much. But you don't

> run both the GUI and the connection-making in the

> same thread, do you?

what exactly do you mean? The function you see is called from the constructor of the JFrame but after initcomponents etc..

Getaway007a at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 7
> what exactly do you mean? The function you see is> called from the constructor of the JFrame but after> initcomponents etc..Maybe I didn't understand your problem. When do you update the progress bar?
CeciNEstPasUnProgrammeura at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 8
After most of the important actions being taken in the code:loading the driverconnectingyou can see that in the code no?
Getaway007a at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...
# 9

Okay. I can see it.

I expect the following to happen (not entirely sure - I always wonder why people ask their Swing problems here and not in the Swing forum where the Swing experts are):

- You create the frame

- You add the components

- You do stuff

- You change the bar's state

Do you notice that nowhere you get to display/update the JFrame? The thread is always busy doing some stuff and doesn't get the chance to refresh the GUI.

http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html

CeciNEstPasUnProgrammeura at 2007-7-13 19:37:23 > top of Java-index,Java Essentials,Java Programming...