Reputation: 4594
In eclipse I've done this:
import javax.swing.JFrame;
import javax.swing.JLabel;
//import statements
//Check if window closes automatically. Otherwise add suitable code
public class HelloWorldFrame extends JFrame {
public static void main(String args[]) {
new HelloWorldFrame();
}
HelloWorldFrame() {
JLabel jlbHelloWorld = new JLabel("Hello World");
add(jlbHelloWorld);
this.setSize(100, 100);
// pack();
setVisible(true);
}
}
But there is no label shown, I mean nothing appears. Only the console shows this:
JUnit version 4.10
Time: 0.001
OK (0 tests)
Has anyone any idea why?
Upvotes: 0
Views: 772
Reputation: 346417
It looks like you're running your program as a JUnit test suite rather than a Java application. How exactly are you starting it, using what IDE?
Upvotes: 1
Reputation: 274768
Check what you are running, because it looks like you are running a JUnit test, not this class. Check your Run Configurations to make sure that you are running this class as a Java Application.
With this class open in the Eclipse editor, go to the Run menu, select the Run as item and then Java application (or Alt+Shift+X,J
).
Upvotes: 2