Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Code Help!
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lucman909




PostPosted: 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 Smile
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Mon Jul 05, 2010 5:42 pm   Post subject: Re: Java Code Help!

Well, let's see...

code:

import JFrame;

You didn't define the package to get JFrame from (should be javax.swing.JFrame, which is already covered by import javax.swing.*)

code:

frame.setDefaultCloseoperation(Frame.EXIT_ON_CLOSE);

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.

code:

JLable textLable = new Jlable("Put Anything You Wish Here", SwingConstants.CENTER);

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).

code:

textLabel.setPreferredsize(new Dimension(200,100));

...

frame.setvisible(true);

cASe SeNsiTIvE (setPreferredSize, setVisible)
Lucman909




PostPosted: Mon Jul 05, 2010 6:11 pm   Post subject: RE:Java Code Help!

Thanks So Much!
that really helped! Smile
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: