Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 18th, 2006, 6:13 PM   #1
Keiyentai
Newbie
 
Join Date: Aug 2006
Posts: 6
Rep Power: 0 Keiyentai is on a distinguished road
Wierd compile Error. Need help please.

OK I am new to Java and I did a tutorial out of O'Reilly's Java CookBook. I compiled it and got 2 errors Both where typos. Fixed them. Got 3 errors 1 typo 2 unclosed tags. Fixed them...then I get 23 errors o.O

Here is the program code.

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

/** Display your business-card information in a java window
 *
 * This is a first attempt. The Next version should use a GridBagLayout.
 */
 public class BusCard extends JFrame {
 	
 	JLabel nameTF;
 	JComboBox jobChoice;
 	JButon B1, B2, B3, B4;
 	
 	/** "Main Program" method - construct and show */
 	public static void main(string[] av) {
 		
 		// Create a BusCard object, tell it to sho up
 		new BusCard() .setVisable(true);
 		
 	}
 
 /** Construct a object including its GUI */
 public BusCard() {
 	super();
 	
 	Container cp = getContentPane();
 	
 	cp.setLayout(new GridLayout(0, 1));
 	
 	addWindowListener(new WindowAdapter() {
 		public void windowClosing(WindowEvent e){
 			setVisable(false);
 			dispose();
 			system.exit(0);
 		}
 	});
 	
 	JMenubar mb = new JMenuBar();
 	setJMenuBar(mb);
 	
 	ResourceBundle b = Resourcebundle.getBundle("BusCard");
 	
 	JMenu aMenu;
 	aMenu = I18N.mkMenu(b, "filemenu");
 	mb.add(aMenu);
 	JMenuItem mi = I18N.mkMenuItem(b, "filemenu", "exit");
 	aMenu.add(mi);
 	mi.addActionListener(new ActionListener() {
 		public void actionPerformed(ActionEvent e) {
 			system.exit(0);
 		}
 		
    });
    aMenu = I18N.mkMenu(b, "editmenu");
    mb.add(aMenu);
    aMenu = I18N.mkMenu(b, "viewmenu");
    mb.add(aMenu);
    aMenu = I18N.mkMeni(b, "optionmenu");
    mb.add(aMenu);
    //mb.SetHelpMenu(aMenu) ;// needed for portability (Motif, ect.).
    
    setTitle(I18N.getString(b, "card"+"company", "TITLE"));
    
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(0, 1, 50, 10));
    
    nameTF = new JLabel("My Name", JLabel.CENTER);
    nameTF.SetFont(new font("Helvetica", Font.BOLD, 18));
    nameTF.SetText(I18N.getString(b, "card"+".myname", "MYNAME"));
    p1.add(nameTF);
    
    jobChoice = new JComboBox();
    jobChoice.setFont(new Font("Helvetica", font.BOLD, 14));
    
    // Get Job Titles ofrom the Properties files loaded in to "b"!
    String next;
    int i=1;
    do {
    	next = I18N.getString(b, "job_title" + i++, null);
    	if (next !=null)
    		jobChoice.addItem(next);
   } while (next != null);
   p1.add(jobChoice);
   
   cp.add(p1);
   
   JPanel p2 = new JPanel();
   p2.setLayout(new GridLayout(2, 2, 10, 10));
   
   B1 = new JButton();
   B1.setLabel(I18N.getString(b, "button1.label", "BUTTON LABEL"));
   p2.add(B1);
   
   B2 = new JButton();
   B2.setLabel(I18N.getString(b, "button2.label", "BUTTON LABEL"));
   p2.add(B2);
   
   B3 = new JButton();
   B3.setLabel(I18N.getString(b, "button3.label", "BUTTON LABEL"));
   p2.add(B3);
   
   B4 = new JButton();
   B4.setLabel(I18N.getString(b, "button4.label", "BUTTON LABEL"));
   p2.add(B4);
   cp.add(p2);
   
   pack();
   
   }
   
}

and here are the errors.
--------------------Configuration: <Default>--------------------
K:\JavaStuff\BussnissCard.java:10: class BusCard is public, should be declared in a file named BusCard.java
 public class BusCard extends JFrame {
        ^
K:\JavaStuff\BussnissCard.java:14: cannot find symbol
symbol  : class JButon
location: class BusCard
        JButon B1, B2, B3, B4;
        ^
K:\JavaStuff\BussnissCard.java:17: cannot find symbol
symbol  : class string
location: class BusCard
        public static void main(string[] av) {
                                ^
K:\JavaStuff\BussnissCard.java:20: cannot find symbol
symbol  : method setVisable(boolean)
location: class BusCard
                new BusCard() .setVisable(true);
                ^
K:\JavaStuff\BussnissCard.java:34: cannot find symbol
symbol: method setVisable(boolean)
                        setVisable(false);
                        ^
K:\JavaStuff\BussnissCard.java:36: cannot find symbol
symbol: variable system
                        system.exit(0);
                        ^
K:\JavaStuff\BussnissCard.java:40: cannot find symbol
symbol  : class JMenubar
location: class BusCard
        JMenubar mb = new JMenuBar();
        ^
K:\JavaStuff\BussnissCard.java:43: cannot find symbol
symbol  : variable Resourcebundle
location: class BusCard
        ResourceBundle b = Resourcebundle.getBundle("BusCard");
                           ^
K:\JavaStuff\BussnissCard.java:46: cannot find symbol
symbol  : variable I18N
location: class BusCard
        aMenu = I18N.mkMenu(b, "filemenu");
                ^
K:\JavaStuff\BussnissCard.java:48: cannot find symbol
symbol  : variable I18N
location: class BusCard
        JMenuItem mi = I18N.mkMenuItem(b, "filemenu", "exit");
                       ^
K:\JavaStuff\BussnissCard.java:52: cannot find symbol
symbol: variable system
                        system.exit(0);
                        ^
K:\JavaStuff\BussnissCard.java:56: cannot find symbol
symbol  : variable I18N
location: class BusCard
    aMenu = I18N.mkMenu(b, "editmenu");
            ^
K:\JavaStuff\BussnissCard.java:58: cannot find symbol
symbol  : variable I18N
location: class BusCard
    aMenu = I18N.mkMenu(b, "viewmenu");
            ^
K:\JavaStuff\BussnissCard.java:60: cannot find symbol
symbol  : variable I18N
location: class BusCard
    aMenu = I18N.mkMeni(b, "optionmenu");
            ^
K:\JavaStuff\BussnissCard.java:64: cannot find symbol
symbol  : variable I18N
location: class BusCard
    setTitle(I18N.getString(b, "card"+"company", "TITLE"));
             ^
K:\JavaStuff\BussnissCard.java:70: cannot find symbol
symbol  : class font
location: class BusCard
    nameTF.SetFont(new font("Helvetica", Font.BOLD, 18));
                       ^
K:\JavaStuff\BussnissCard.java:71: cannot find symbol
symbol  : variable I18N
location: class BusCard
    nameTF.SetText(I18N.getString(b, "card"+".myname", "MYNAME"));
                   ^
K:\JavaStuff\BussnissCard.java:75: font is not public in java.awt.Component; cannot be accessed from outside package
    jobChoice.setFont(new Font("Helvetica", font.BOLD, 14));
                                            ^
K:\JavaStuff\BussnissCard.java:81: cannot find symbol
symbol  : variable I18N
location: class BusCard
        next = I18N.getString(b, "job_title" + i++, null);
               ^
K:\JavaStuff\BussnissCard.java:93: cannot find symbol
symbol  : variable I18N
location: class BusCard
   B1.setLabel(I18N.getString(b, "button1.label", "BUTTON LABEL"));
               ^
K:\JavaStuff\BussnissCard.java:97: cannot find symbol
symbol  : variable I18N
location: class BusCard
   B2.setLabel(I18N.getString(b, "button2.label", "BUTTON LABEL"));
               ^
K:\JavaStuff\BussnissCard.java:101: cannot find symbol
symbol  : variable I18N
location: class BusCard
   B3.setLabel(I18N.getString(b, "button3.label", "BUTTON LABEL"));
               ^
K:\JavaStuff\BussnissCard.java:105: cannot find symbol
symbol  : variable I18N
location: class BusCard
   B4.setLabel(I18N.getString(b, "button4.label", "BUTTON LABEL"));
               ^
23 errors

Process completed.

Like I said I am a Java noob and maybe it's something simople I over looked but If some one could help me out I would be verry thankful
Keiyentai is offline   Reply With Quote
Old Aug 18th, 2006, 6:24 PM   #2
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
I'm not amazing at java, but you might want to consider starting with the first error.

Quote:
--------------------Configuration: <Default>--------------------
K:\JavaStuff\BussnissCard.java:10: class BusCard is public, should be declared in a file named BusCard.java
public class BusCard extends JFrame {
Quote:
should be declared in a file named BusCard.java
I'm guessing you haven't done that since it's complaining.
You might find that when you change that, all the, or the moajority of the errors will go away. In my experience, Java tends to me like that. Remember that the class name, has to be the same as the file name.

btw, you also have some more spelling mistakes in there. If you can't spell, it's really goin gto cost you :p ... You also seem to be declaring some things wrong. Look here:
http://java.sun.com/docs/books/tutor.../example2.html
Booooze is offline   Reply With Quote
Old Aug 18th, 2006, 6:33 PM   #3
Random Spirit
Unverified User
 
Join Date: Aug 2006
Posts: 88
Rep Power: 0 Random Spirit is on a distinguished road
Try Spelling JButton with two t's.

String is spelt with a capital S

Visible is not spelt Visable - simple spelling mistake

System is spelt with a capital s in system.exit(0);

JMenuBar is not spelt JMenubar -lowercase b on the word Bar is incorrect

ResourceBundle is not spelt Resourcebundle - same again with the B

These are just a few of the spelling mistakes i have found just looking at your code. Make sure you copy the code exactly from your book. Spelling and case matters in java. Go though it line by line comparing with your book and then post back if you have any more problems. You need to take care with your typing. string is not the same as String in java.

When you get a compile time error sort out the first problem shown. You will find that just having one error in your code can create 2 or 3 compiler errors. So by sorting out one problem will usually get rid of more than one compile error.
Random Spirit is offline   Reply With Quote
Old Aug 18th, 2006, 6:37 PM   #4
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You have a lot of typos. Remember that Java is case-sensitive, so System is not the same as system. As well as altering your file's name, you will need to: correct the spelling for JButon, mkMeni and setVisable; capitalize the first letter of all classes, including String, System, and Font; properly capitalize JMenubar and Resourcebundle; and at some point declare and initialize the variable I18N before using it.

EDIT: Random Spirit beat me to the punch... although the most serious error in your code, as I pointed out, is the uninitialized I18N variable (or class?). It appears your code is attempting to utilize internationalization functionality; see this tutorial for help.
titaniumdecoy is offline   Reply With Quote
Old Aug 18th, 2006, 7:38 PM   #5
Keiyentai
Newbie
 
Join Date: Aug 2006
Posts: 6
Rep Power: 0 Keiyentai is on a distinguished road
Thank you for the pointers. At first when I glanced at it I thought it was something more then mainly spelling errors. I guess I rushed it a bit before I had to go to the store. Thank you though for being helpful and not roasting me. heh. Also thank you for the tutorial links.
Keiyentai is offline   Reply With Quote
Old Aug 18th, 2006, 10:38 PM   #6
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
You might want to get a Java IDE such as JCreator it highlights different keywords when you type them, which in your case would really help, since you can tell right away if its a typo. +All the above pointers
__________________
Pain is just weakness leaving the body.
AntiNinja is offline   Reply With Quote
Old Aug 18th, 2006, 11:04 PM   #7
Keiyentai
Newbie
 
Join Date: Aug 2006
Posts: 6
Rep Power: 0 Keiyentai is on a distinguished road
Actualy I am using JCreator. I was browsing the forum and saw you mentioning it in the Flavors of Java thread I really like it.
Keiyentai is offline   Reply With Quote
Old Aug 19th, 2006, 1:35 AM   #8
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3 Jimbo is on a distinguished road
If you didn't already, make sure the name matches the (main) class in the file, e.g. BusCard is defined in BusCard.java. If you have multiple non-nested classes defined in a file, only one of them can be public and should match the file name. The others are given package level access. The rest of the errors seem pretty easy to fix, and the other members have addressed them...
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
please help me to compile cwl157 C++ 37 Mar 6th, 2006 6:12 PM
MASM32 compile problem Kilo Assembly 3 Nov 20th, 2005 12:39 PM
can't compile code lloydkirk Java 17 Oct 6th, 2005 2:07 AM
Fahrenheit / Celsius compile problem andrewgray C++ 20 Jul 8th, 2005 11:04 PM
C++ Compile gebreil C++ 6 May 29th, 2005 1:30 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC