ConMan318
May 18th, 2008, 11:58 PM
I have just begun learning Java and I typed this code:
import javax.swing.*;
public class TestJava {
public static void main(String[] args) {
JFrame frame = new JFrame("Hello, Java!");
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER);
frame.getContentPane().add(label);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
Upon compiling, this error is generated:
connor@connor-laptop:~/Documents/programs/java$ javac TestJava.java
TestJava.java:6: warning: The static field SwingConstants.CENTER should be accessed directly
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER);
^^^^^^
1 problem (1 warning)
It still runs the program, except when the window opens it doesn't close, then it grays out and I have to force a quit. I'm not sure if this problem is related to the error or not.
But how can I access the static field SwingConstants directly?
import javax.swing.*;
public class TestJava {
public static void main(String[] args) {
JFrame frame = new JFrame("Hello, Java!");
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER);
frame.getContentPane().add(label);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
Upon compiling, this error is generated:
connor@connor-laptop:~/Documents/programs/java$ javac TestJava.java
TestJava.java:6: warning: The static field SwingConstants.CENTER should be accessed directly
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER);
^^^^^^
1 problem (1 warning)
It still runs the program, except when the window opens it doesn't close, then it grays out and I have to force a quit. I'm not sure if this problem is related to the error or not.
But how can I access the static field SwingConstants directly?