On Friday 21 September 2007, Aryeh Friedman wrote:
On every JDK (linux-sun-jdk14,jdk15,diablo-jdk15,linux-sun-jdk16 and
jdk16) I have tried this on it opens the JFrame then just dies
(immediatly):
import javax.swing.JFrame;
public class Main
{
public static void main(String[] args)
{
JFrame frame=new JFrame();
frame.pack();
frame.setVisible(true);
while(true)
;
}
}
I am using FreeBSD 7-Current with xorg 7.3 (gnome)
Your code is wrong. You cannot do GUI creation / updating outside the
Swing/AWT event dispatching thread. Also, the while(true); is unnessecary
(and a waste of CPU time) because java does not terminate while there are
active threads.
For more information:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/
Example:
import javax.swing.*;
public class Main {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame(Hello);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setVisible(true);
}
});
}
}
Regards,
Pieter de Goeje
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]