Thank you for your help so far.
Where do I put the TestApplet? Should I try making it a class of its own? I tried sticking it in here and there, but get a message that it should be declared in it own class. I have also tried extends and implements in various places. At times it seems like I am almost trying to nest classes.
Like I said, I only know enough of this at this point to experience the roller coaster ride (valleys=beating head against the wall in frustration; hilltops=YAY! IT WORKED! Dont know how, but it WORKED!!) of programming in
Java. (I do hope someday to be able to take a Java course that can bring me to a point of not having it be such a struggle.)
As it stands this morning, here is my code along with the "error" message:
Code:
import java.applet.Applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CoreButton2 extends Frame //note to self:
//using Applet here
//causes errors in
//the Button part.
{
public CoreButton2()
{ setTitle("ButtonTest");
setLayout(new FlowLayout());
add (new Button("Yes"));
add (new Button("No"));
add (new Button("Ok"));
add (new Button("Cancel"));
add (new Button("Abort"));
add (new Button("Retry"));
add (new Button("Ignore"));
} //end corebutton2 layout
public boolean action(Event evt, Object arg)
{ if (arg.equals("Yes")) setBackground(Color.yellow);
else if (arg.equals("No")) setBackground(Color.blue);
else if (arg.equals("Ok")) setBackground(Color.orange);
else if (arg.equals("Cancel")) setBackground(Color.cyan);
else if (arg.equals("Abort")) setBackground(Color.pink);
else if (arg.equals("Retry")) setBackground(Color.red);
else if (arg.equals("Ignore")) setBackground(Color.white);
else return false;
repaint();
return true;
} //end color changes
public void init(String[] args) {
// TODO Auto-generated method stub
Frame f = new CoreButton2();
f.resize(320, 200);
f.show();
}//end init
} // end class
The Alert Message I get from a regular compile:
Note: C:\Documents and Settings\jenr\Desktop\PIDTree\CoreButton2.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
Finished CoreButton2.
The Error Message I get from Debug:
java.lang.ClassCastException
at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
at sun.applet.AppletPanel.run(AppletPanel.java:298)
at java.lang.Thread.run(Thread.java:534)
Thanks again for helping me get some sort of grip on this.
Jen