Re: why won't my applet run on all platforms?

Harry_Boswell_at_@deq.state.ms.us
Date: 10/20/04


Date: Wed, 20 Oct 2004 16:19:22 -0500

On Wed, 20 Oct 2004 13:53:55 -0700, Paul Lutus <nospam@nosite.zzz>
wrote:

>Harry_Boswell@@deq.state.ms.us wrote:
>
>> 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.
>
>The problem is most likely your code. Because you did not post any code,
>this concludes the help we can offer you.

No problem posting code. But since it ran on several platforms -
Solaris 2.6, Red Hat 9, and another XP Pro box, but not on my XP Pro
box, I was more suspicious of some Java config issue.

Code follows:

//PnlCounter.java
// action handling with multiple events

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class PnlCounter extends Applet implements ActionListener{
  Button btnOne = new Button("One");
  Button btnTwo = new Button("Two");
  Button btnThree = new Button("Three");
  Button btnFour = new Button("Four");
  Panel pnlControls = new Panel();
  Label lblDisplay = new Label();
  
  
  public void init(){
    
    this.setLayout(new BorderLayout());
    add(lblDisplay, BorderLayout.CENTER);
    add(pnlControls,BorderLayout.SOUTH);
    
    // set up the panel
    pnlControls.setLayout(new GridLayout(1,0));
    pnlControls.add(btnOne);
    pnlControls.add(btnTwo);
    pnlControls.add(btnThree);
    pnlControls.add(btnFour);
    
     // register the ActionListener
    btnOne.addActionListener(this);
    btnTwo.addActionListener(this);
    btnThree.addActionListener(this);
    btnFour.addActionListener(this);
   
    // clean up the label
    lblDisplay.setFont(new Font("Trebuchet",Font.BOLD,40));
    lblDisplay.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("One")){
        lblDisplay.setText("Ichi");
      }
      else if (theCommand.equals("Two")){
        lblDisplay.setText("Hii");
      }
      else if (theCommand.equals("Three")){
        lblDisplay.setText("San");
      }
      else if (theCommand.equals("Four")){
        lblDisplay.setText("Shi");
      }
      else {
        lblDisplay.setText("Something unexpected happened");
      } // end if
   } // end ActionPerformed
} // end class def