为什么这在 Applet 上没有打印显示任何内容?我已经尝试多次编辑它,但似乎没有任何显示。有谁知道发生了什么?我试着画画,但效果不佳。任何提示将非常感谢!
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.awt.Color;
public class StartingPoint extends Applet{
private final int pictureWidth = 1001;
private final int pictureHeight = 50;
private static FormCanvas picture;
private JPanel panel;
private JTextField numLights;
private JTextField whichLight;
private JTextField howLong;
public void lightCreator(){
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
picture = new FormCanvas();
panel.add(picture);
panel.setBackground(Color.BLUE);
numLights = new JTextField("Enter Number of lights total", 20);
whichLight = new JTextField("Enter which lights you want off separated by commas", 30);
howLong = new JTextField("Interval time", 10);
panel.add(numLights);
panel.add(whichLight);
panel.add(howLong);
int light = Integer.parseInt(numLights.getText());
String lights = whichLight.getText();
int lightsOn[] = new int[light];
StringTokenizer str = new StringTokenizer(lights, ",");
int n = 0;
while(str.hasMoreElements()){
lightsOn[n] = Integer.parseInt((String)str.nextElement());
n++;
}
add(panel);
}
class FormCanvas extends Canvas {
// this class paints the GUI
FormCanvas() {
setSize(pictureWidth, pictureHeight);
setBackground(Color.blue);
}
}
}