QUOTE(pbl @ 14 Oct, 2008 - 08:36 PM)

100% sure that you have to overload the init() method even if it does nothing
as far as the start() method is concerned, don't really know what the start() method of Applet does but I have never deployed an applet without having also start() overload even if it does nothing
I don't quite get it. So what do I have to write in init()? And does it mean I have to write the start() method as well?
Below is the code I've written so far.
It works when I run and compile on Netbean, but not on browsers :S
CODE
package betaTest;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;
import javax.swing.JApplet;
/**
*
* @author Raymond
*/
public class possMain extends JApplet implements ActionListener {
private JButton b1;
private JTextArea textArea;
private possCalc possRes;
private final static String newline = "\n";
@Override
public void init() {
setLayout(new GridBagLayout());
possRes = new possCalc(30);
possChance[] possNumList = {
new possChance(10),
new possChance(30),
new possChance(50),
new possChance(70),
new possChance(90),
};
//Create the combo box
JComboBox possList = new JComboBox(possNumList);
possList.setSelectedIndex(1);
possList.addActionListener(this);
//Create text area to show generation details
textArea = new JTextArea(20, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
//Create the generate button
b1 = new JButton("Generate");
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for left-to-right locales
b1.setMnemonic(KeyEvent.VK_G);
b1.setActionCommand("generate");
//Listen for actions on buttons 1 and 3.
b1.addActionListener(this);
b1.setToolTipText("Click to start Generation.");
//Add content to the container
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(b1, gbc);
gbc.fill = GridBagConstraints.HORIZONTAL;
add(possList, gbc);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
add(scrollPane, gbc);
}
@Override
public void start() {
System.out.println("Applet starting.");
}
@Override
public void stop() {
System.out.println("Applet stopping.");
}
@Override
public void destroy() {
System.out.println("Destroy method called.");
}
public void actionPerformed(ActionEvent e) {
//JComboBox cb = (JComboBox) e.getSource();
//possChance newPoss = (possChance) cb.getSelectedItem();
//possRes.setPossHold(newPoss.getChance());
if ("generate".equals(e.getActionCommand())) {
possRes.startGen();
textArea.append("(" + possRes.getPoss() + ") " + possRes.getRes() + newline);
} else {
JComboBox cb = (JComboBox) e.getSource();
possChance newPoss = (possChance) cb.getSelectedItem();
possRes.setPossHold(newPoss.getChance());
}
}
}
Same problem "Applet XXXXX notinitied" ... OTZ