2 errors in an applet, & outcome is "Welcome To Java!!'

I tried to write this so I could use an applet and it be accesable on the web instead of just the text box I had earlier. This is only my second writing of a program and first with an applet attempt. Well I did something wrong some where. Because all I get is "Welcome to Java!" when I exicute it and after serveral partial rewrittings I get 2 errors. I am using JCreator as my ide.

I get the error message "line 110 <identifier expected>" and then "line 143 ')' expected."

Line 110:

publicvoid textValueChanged (TextEvent){

Line 143:

}

Entire code:

import java.awt.*;

import java.applet.*;

class creditsextends Appletimplements TextListener{

TextField LAField =new TextField("0.00", 15),

MMField =new TextField("0.00", 6),

ScienceField =new TextField("0", 3),

WHField =new TextField("0.00", 15),

AHField =new TextField("0.00", 15),

EconomicsField =new TextField("0.00", 6),

AGField =new TextField("0", 3),

ArtsField =new TextField("0.00", 15),

LMSField =new TextField("0.00", 15),

PFField =new TextField("0.00", 6),

PEField =new TextField("0", 3),

ElectivesField =new TextField("0.00", 15);

Double creditsn, credits, LA, MM, Science, WH, AH;

Double Economics, AG, Arts, LMS, PF, PE, Electives;

publicvoid init(){

{resize(320,240);}

Label LALabel =new Label("Language Art Credit ");

MMLabel =new Label("Mathematic Credit ");

ScienceLabel =new Label("Science Credit ");

WHLabel =new Label("World History Credit");

AHLabel =new Label("American history Credit ");

EconomicsLabel =new Label("Economic Credits ");

AGLabel =new Label("American Government Credits ");

ArtsLabel =new Label("Practical/Fine Arts Credits ");

LMSLabel =new Label("Life Management Credits ");

PFLabel =new Label("Persional Fitness Credits ");

PELabel =new Label("Pysical Education Credits ");

ElectivesLabel =new Label("Elective Credits");

CreditsLabel =new Label("Pysical Education Credits ");

LALabelPanel.add(principalLabel);

LAFieldPanel.add(principalField);

MMLabelPanel.add(rateLabel);

MMFieldPanel.add(rateField);

ScienceLabelPanel.add(yearsLabel);

SciecneFieldPanel.add(yearsField);

WHLablePanel.add(paymentLabel);

WHFieldPanel.add(paymentField);

AHLablePanel.add(paymentLabel);

AHFieldPanel.add(paymentField);

EconomicsLablePanel.add(paymentLabel);

EconomicsFieldPanel.add(paymentField);

AGLablePanel.add(paymentLabel);

AGFieldPanel.add(paymentField);

ArtsLablePanel.add(paymentLabel);

ArtsFieldPanel.add(paymentField);

LMSLablePanel.add(paymentLabel);

LMSFieldPanel.add(paymentField);

PFLablePanel.add(paymentLabel);

PFFieldPanel.add(paymentField);

PELLablePanel.add(paymentLabel);

PEFieldPanel.add(paymentField);

ElectivesLablePanel.add(paymentLabel);

ElectivesFieldPanel.add(paymentField);

CreditsLablePanel.add(paymentLabel);

CreditsFieldPanel.add(paymentField);

add(LALabelPanel);

add(LAFieldPanel);

add(MMLabelPanel);

add(MMFieldPanel);

add(ScienceLabelPanel);

add(ScienceFieldPanel);

add(WHLabelPanel);

add(WHFieldPanel);

add(AHLabelPanel);

add(AHFieldPanel);

add(EconomicsLabelPanel);

add(EconomicsFieldPanel);

add(AGLabelPanel);

add(AGFieldPanel);

add(ArtsLabelPanel);

add(ArtsFieldPanel);

add(LMSLabelPanel);

add(LMSFieldPanel);

add(PFLabelPanel);

add(PFFieldPanel);

add(PELabelPanel);

add(PEFieldPanel);

add(ElectivesLabelPanel);

add(ElectivesFieldPanel);

add(CreditsLabelPanel);

add(CreditsFieldPanel);

LAField.addTextListener(this);

MMField.addTextListener(this);

ScienceField.addTextListener(this);

WHField.addTextListener(this);

AHField.addTextListener(this);

EconomicsField.addTextListener(this);

AGField.addTextListener(this);

ArtsField.addTextListener(this);

LMSField.addTextListener(this);

PFField.addTextListener(this);

PEField.addTextListener(this);

ElectivesField.addTextListener(this);

CreditsField.addTextListener(this);

}

publicvoid textValueChanged (TextEvent){

Object source=e.getSource();

if (source == LAField ||

source == MMField ||

source == ScienceField ||

source == WHField ||

source == AHField ||

source == EconomicsField ||

source == AGField ||

source == ArtsField ||

source == LMSField ||

source == PFField ||

source == PEField ||

source == Electives ||

source == Credits)

try{

LA = 4 - Double.valueOf(LAField.getText()).doubleValue();

MM = 3 - Double.valueOf(MMField.getText()).doubleValue();

Science = 3 - Double.valueOf(ScienceField.getText()).doubleValue();

WH = 1 - Double.valueOf(WHField.getText()).doubleValue();

AH = 1 - Double.valueOf(AHField.getText()).doubleValue();

Ecomincs = .5 - Double.valueOf(EconomicsField.getText()).doubleValue();

AG = .5 - Double.valueOf(AGField.getText()).doubleValue();

Arts = 1 - Double.valueOf(ArtsField.getText()).doubleValue();

LMS = .5 - Double.valueOf(LMSField.getText()).doubleValue();

PF = .5 - Double.valueOf(PFField.getText()).doubleValue();

PE = .5 - Double.valueOf(PEField.getText()).doubleValue();

Electives = 8.5 - Double.valueOf(ElectivesField.getText()).doubleValue();

Credits = 24 - Double.valueOf(CreditsField.getText()).doubleValue();

}

catch (NumberFormatException ex){}

}

}

Thanks,

Shelnutt2

[8625 byte] By [Shelnutt2a] at [2007-10-2 12:46:11]
# 1

You need to have a variable name in the method for the type TextEvent.

public void textValueChanged(final TextEvent event) { }

- Saish

Saisha at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
I put that in and it did not chage anything still get teh same error messages.
Shelnutt2a at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
Post the whole error stack trace.- Saish
Saisha at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

Alright I've managed I think you completely rework my applet and now the only problem I get is

"Load: Credits.class is not public or has no public constructor.

java.lang.IllegalAccessException: Class sun.appler.AppletPanel can not access a member of class Credits with moddifiers ""

At sun.reflect.Reflection.ensureMember Acecss(Reflection.java:65)

At java.lang.Class.NewInstance0(AppletPannel.java:344)

At java.lang.Class.NewInstance(AppletPannel.java:304)

At sun.applet.AppletPanel.creatApplet(AppletPannel.java:721)

At jsun.applet.AppletPanel.runLoader(AppletPannel.java:650)

At jsun.applet.AppletPanel.run(AppletPannel.java:324)

At java.lang.Thread.run(Thread.java:695)"

My source Code:

[CODE]import java.awt.*;

import java.awt.Label;

import java.awt.TextField;

import java.lang.*;

import java.io.*;

import java.text.NumberFormat;

import javax.swing.*;

public class ShowDocument extends JApplet {

public void init() {

//Execute a job on the event-dispatching thread:

//creating this applet's GUI.

try {

SwingUtilities.invokeAndWait(new Runnable() {

public void run() {

createGUI();

}

});

} catch (Exception e) {

System.err.println("createGUI didn't successfully complete");

}

}

private void createGUI() {

JButton button = new JButton("Bring up URL window");

button.addActionListener(this);

add(button);

JFrame.setDefaultLookAndFeelDecorated(true);

urlWindow = new URLWindow(getAppletContext());

urlWindow.pack();

}

public void destroy() {

//Execute a job on the event-dispatching thread:

//creating this applet's GUI.

try {

SwingUtilities.invokeAndWait(new Runnable() {

public void run() {

destroyGUI();

}

});

} catch (Exception e) { }

}

private void destroyGUI() {

urlWindow.setVisible(false);

urlWindow = null;

}

public void actionPerformed(ActionEvent event) {

urlWindow.setVisible(true);

}

}

public static void main(String args[])

{

BufferedReader keyboard =

new BufferedReader(new InputStreamReader(System.in));

Double creditsn, credits, LA, MM, Science, WH, AH;

Double Economics, AG, Arts, LMS, PF, PE, Electives;

System.out.print("How many Language Arts credits do you have?");

LA = Double.parseDouble(keyboard.readLine());

System.out.print("How many Mathematics credits do you have?");

MM = Double.parseDouble(keyboard.readLine());

System.out.print("How many Science credits do you have?");

Science = Double.parseDouble(keyboard.readLine());

System.out.print("How many World History credits do you have?");

WH = Double.parseDouble(keyboard.readLine());

System.out.print("How many American History credits do you have?");

AH = Double.parseDouble(keyboard.readLine());

System.out.print("How many Econimic credits do you have?");

Economics = Double.parseDouble(keyboard.readLine());

System.out.print("How many American Goverment credits do you have?");

AG = Double.parseDouble(keyboard.readLine());

System.out.print("How many Practical/Fine Art credits do you have?");

Arts = Double.parseDouble(keyboard.readLine());

System.out.print("How many Life Management Skill credits do you have?");

LMS = Double.parseDouble(keyboard.readLine());

System.out.print("How many Personal Fitness credits do you have?");

PF = Double.parseDouble(keyboard.readLine());

System.out.print("How many Pyscial Education credits do you have?");

PE = Double.parseDouble(keyboard.readLine());

System.out.print("How many Elective credits do you have?");

Electives = Double.parseDouble(keyboard.readLine());

creditsn = LA + MM + Science + WH + AH + Economics + AG + Arts + LMS + PF + PE + Electives;

System.out.println("");

System.out.print("You need ");

System.out.print(4 - LA );

System.out.println(" more Language Arts credits");

System.out.print("You need ");

System.out.print(3 - MM );

System.out.println(" more Mathematic credits");

System.out.print("You need ");

System.out.print(3 - Science );

System.out.println(" more Science credits");

System.out.print("You need ");

System.out.print(1 - WH);

System.out.println(" more World History credits");

System.out.print("You need ");

System.out.print(1 - AH );

System.out.println(" more American History credits");

System.out.print("You need ");

System.out.print(.5 - Economics );

System.out.println(" more Economics credits");

System.out.print("You need ");

System.out.print(.5 - AG );

System.out.println(" more American Government credits");

System.out.print("You need ");

System.out.print(1 - Arts );

System.out.println(" more Fine/Pratical Arts credits");

System.out.print("You need ");

System.out.print(.5 - LMS );

System.out.println(" more Life Management Skills credits");

System.out.print("You need ");

System.out.print(.5 - PF );

System.out.println(" more Physical Fitness credits");

System.out.print("You need ");

System.out.print(.5 - PE );

System.out.println(" more Pyhiscal Education credits");

System.out.print("You need ");

System.out.print(8.5 - Electives );

System.out.println(" more elective credits");

System.out.print("You need ");

System.out.print(24 - creditsn );

System.out.println(" more total credits");

}[/CODE]

Shelnutt2a at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5
What does the constructor of the Credits object look like? I'm not sure if you can get an InputStream from System.in in an applet.- Saish
Saisha at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6

I am not sure what you mean by constructor of the Credits object. I copied the second part of the code, starting with line 56 from my text version. I was hoping maybe I'd just get an error or to and it be an easy fix and I'd be able to go. The three books I got on Java, Jave 2 for dummies, Java in a Nutshell and Begining Programming all do not really tell me how to build an applet they give you one or 2 examples but thats it and the examples do not show an applet where the user inputs data and then the applet outpus data based on the users input. The examples only show pictures and drawing applets.

Shelnutt2a at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7

I do not believe your code would even compile. Where is the Credit object declared? I see a reference in the main() method, but not declaration in the class. Also, is this an applet or a standalone application? Your main() method is to be run from a command-line, but you wrote an applet, which is odd.

- Saish

Saisha at 2007-7-13 9:55:14 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...