Hi,
How do I paint or print an multi-array in applets?
Here is my code:
import java.awt.Graphics;
import javax.swing.*;
import java.applet.*;
public class Applettest extends JApplet {
public void init() {
int Choice = 0;
String userChoice = JOptionPane.showInputDialog("Enter a number, 0 to 2");
Choice = Integer.parseInt(userChoice);
paint(null,Choice);
}
public void paint(Graphics g, int testPass) {
String Multi[][]={{"Line 1","Line 2","Line 3"},{"Line 4","Line 5","Line 6"},{"Line 7","Line 8","Line 9"}};
g.drawString(Multi[testPass][testPass], 10,10);
}
}
My error:
java.lang.NullPointerException
at applets.Applettest.paint(Applettest.java…
at applets.Applettest.init(Applettest.java:…
at sun.applet.AppletPanel.run(AppletPanel.j…
at java.lang.Thread.run(Thread.java:722)