Computer Science Canada Java Code Help! |
Author: | Lucman909 [ Mon Jul 05, 2010 5:18 pm ] |
Post subject: | Java Code Help! |
Hey, kso ive read a lot and for a long time in Java, and i thought i would try to make a simple window. Here is my code. import java.awt.*; import javax.swing.*; import JFrame; public class Window{ private static void creatWindow(){ // The Top Of The Window JFrame frame = new JFrame("simpleWindow"); frame.setDefaultCloseoperation(Frame.EXIT_ON_CLOSE); //The Dimentions And What The Box Will Do JLable textLable = new Jlable("Put Anything You Wish Here", SwingConstants.CENTER); textLable.setPreferredsize(new Dimension(200,100)); frame.getContentPane().add(textLabel, BorderLayout.CENTER); // Displays The Window frame.pack(); frame.setvisible(true); } public static void main(String[] args) { creatWindow(); } } It looks okay to me, but when i try to compile it doesn't ! If you know any Java and think you can help. PLEASE DO SO! Thanks ![]() |
Author: | TheGuardian001 [ Mon Jul 05, 2010 5:42 pm ] | ||||||||
Post subject: | Re: Java Code Help! | ||||||||
Well, let's see...
You didn't define the package to get JFrame from (should be javax.swing.JFrame, which is already covered by import javax.swing.*)
Your window is a JFrame, and you should be using JFrame constants. On top of which, java is Case Sensitive. The "o" at the start of "operation" should be capitalised.
JLabel(el, not le) is spelt incorrectly, and once again, Java is case sensitive. Your second Jlabel should have a capital L. (You also spelt "textLabel" many different ways, check your spelling on each one).
cASe SeNsiTIvE (setPreferredSize, setVisible) |
Author: | Lucman909 [ Mon Jul 05, 2010 6:11 pm ] |
Post subject: | RE:Java Code Help! |
Thanks So Much! that really helped! ![]() |