import java.awt.Graphics;
import java.applet.Applet;
public class WelcomeApplet extends Applet{
public void paint( Graphics g )
{
g.drawString("Welcome to Java Programming!",25,25);
g.drawString("wwiilla",25,40);
}
}
这看不到窗口显视结果。
import java.awt.Graphics;
import javax.swing.*;
public class SwitchText extends JApplet{
int choice;
public void init()
{
String input;
input = JOptionPane.showInputDialog(
"Enter 1 to draw lines\n" +
"Enter 2 to draw rectangles\n" +
"Enter 3 to draw ovals\n");
choice = Integer.parseInt( input );
}
public void paint( Graphics g )
{
super.paint( g );
for( int i = 0; i < 10 ; i++){
switch ( choice ){
case 1:
g.drawLine( 10,10,250,10*i);
break;
case 2:
g.drawRect( 10 + i*10,10 + 10*i,50+i*10,50+i*10);
break;
case 3:
g.drawOval(10+i*10,10+i*10,50+i*10,50+i*10);
break;
default:
g.drawString("Invalid value entered",10,20+i*15);
break;
}
}
}
}
//<applet code = " SwitchText.class " width = "500" height =" 300 " > </applet>
帮忙看一下这个程序用appletviewer时什么有错?