Page 1 of 1

Trouble starting Swing app

Posted: Sat Feb 16, 2002 6:52 pm
by Mark Schnitzius
I have a Swing application which I can run just fine from the command line. I can also run a text-only version of it from TextPad. But when I try to run the Swing version, it gets to where it tries to do the setVisible(true) and it just hangs. I have to close TextPad to make it stop.

I even have the problem when I try to run java.sun.com's "First Swing Program":

javax.swing.*;

public class HelloWorldSwing {
public static void main(String[] args) {
JFrame frame = new JFrame("HelloWorldSwing");
final JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}

It just hangs. Any idea why?

Re: Trouble starting Swing app

Posted: Tue Apr 02, 2002 3:45 pm
by Jim Garacci
I've had this problem before (just about as annoying as the Nortons bug/feature). My resolution was to just never run Swing apps from textpad. Not the most elegant solution, I'll grant you.

Surely this is a sign of a process or thread related bug, but one can't be sure without further testing.

Re: Trouble starting Swing app

Posted: Thu Apr 04, 2002 11:42 pm
by dano
I have been working through Deitel&Deitel's book, "Java 2 - Introducing Swing". I have only had one minor bit of weirdness which I will mention later.

In looking at your code:
javax.swing.*;
public class HelloWorldSwing {
public static void main(String ...

I think you need an "import" keyword, before the javax.swing.*

import javax.swing.*;
public class HelloWorldSwing {
public static void main(String ...

Dano