applet won't run on all platforms
I've written a simple applet that compiles cleanly (apparently), and
will run on Solaris and Red Hat 9 using appletviewer; and it will run
on a friend's WinXP Pro system. But when I try to run it on my WIn XP
Pro system, I get these messages in the appletviewer window:
error:null
then
Start: applet not initialized
and in the DOS box I call appletviewer from, I get a string of
messages :
at Panel.<init>(Panel.java:10)
I'm using J2SE 1.4.1 on my XP system.
Thanks for any help!
Harry
[574 byte] By [
hboswell] at [2007-9-30 20:24:53]

Another thing - I tried these at home last night, also XP Pro, J2SDK 1.4.2_06, and they ran fine. So I replaced JDK 1.4.1 with 1.4.2_06 this morning, and it still doesn't run, although the error message is different.
java.lang.StackOverflowError
java.lang.NullPointerException
at sun.applet.AppletViewer.appletInfo(AppletViewer.java:696)
at sun.applet.AppletViewer.processUserAction(AppletViewer.java:906)
at sun.applet.AppletViewer$UserActionListener.actionPerformed(AppletView
er.java:133)
at java.awt.MenuItem.processActionEvent(MenuItem.java:589)
at java.awt.MenuItem.processEvent(MenuItem.java:548)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:285)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:273)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:458)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
OK, here's the code:
//CardDemo.java
// action handling with multiple events
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class CardDemo extends Applet implements ActionListener{
//Control panel components
Panel pnlControls = new Panel();
Button btnFirst = new Button("|<<");
Button btnPrev = new Button("<==");
Button btnC = new Button("C");
Button btnNext = new Button("==>");
Button btnLast = new Button(">>|");
//The Cards
Panel pnlCards = new Panel();
CardLayout Stack = new CardLayout();
Label lblA = new Label("A");
Label lblB = new Label("B");
Label lblC = new Label("C");
Label lblD = new Label("D");
Label lblE = new Label("E");
public void init(){
//set up the main page
this.setLayout(new BorderLayout());
this.add(pnlControls, BorderLayout.SOUTH);
this.add(pnlCards, BorderLayout.CENTER);
// set up the control panel
pnlControls.setFont(new Font("SanSerif",Font.BOLD, 20));
pnlControls.setLayout(new FlowLayout());
pnlControls.add(btnFirst);
pnlControls.add(btnPrev);
pnlControls.add(btnC);
pnlControls.add(btnNext);
pnlControls.add(btnLast);
// register the ActionListener
btnFirst.addActionListener(this);
btnPrev.addActionListener(this);
btnC.addActionListener(this);
btnNext.addActionListener(this);
btnLast.addActionListener(this);
//set up the card panel
pnlCards.setLayout(Stack);
pnlCards.setFont(new Font("SanSerif",Font.BOLD, 60));
pnlCards.add(lblA,"A");
pnlCards.add(lblB,"B");
pnlCards.add(lblC,"C");
pnlCards.add(lblD,"D");
pnlCards.add(lblE,"E");
//center the labels
lblA.setAlignment(Label.CENTER);
lblB.setAlignment(Label.CENTER);
lblC.setAlignment(Label.CENTER);
lblD.setAlignment(Label.CENTER);
lblE.setAlignment(Label.CENTER);
} // end init
public void actionPerformed(ActionEvent e){
//get the name of the button that was pressed
String theCommand = e.getActionCommand();
//check to see which button was pressed
if (theCommand.equals("|<<")){
Stack.first(pnlCards);
}
else if (theCommand.equals("<==")){
Stack.previous(pnlCards);
}
else if (theCommand.equals("C")){
Stack.show(pnlCards,"C");
}
else if (theCommand.equals("==>")){
Stack.next(pnlCards);
}
else if (theCommand.equals(">>|")){
Stack.last(pnlCards);
} // end if
} // end ActionPerformed
} // end class def