package einstein;
import javax.swing.JApplet;
import java.awt.*;
启动applett
public class Einstein extends JApplet
{
//--------------------------------------------------------|
//draws a quotation from albert einstein among some shapes|
//--------------------------------------------------------|
@Override
public void paint (Graphics page)
{
下一行非法开始表达
page.drawRect (50, 50, 40, 40,); //square
page.drawRect (60, 80, 225, 30); //rectangle
page.drawOval (75, 65, 20, 20); //circle
page.drawLine (35, 60, 100, 120); //line
page.drawString ("Out of clutter, find simplicity.", 110, 70);
page.drawString ("-- Albert Einstein", 130, 100);
}
}
它最初的油漆(图形页面)有问题,但显然@overide修复了
答案 0 :(得分:0)
Ben只删除你在为page.drawRect传递的第四个值之后输入的额外逗号(50,50,40,40,); //删除逗号:)
如果您想查看自己的小程序,最终的代码应为此:
import javax.swing.JApplet;
import java.awt.*;
public class Einstein extends JApplet
{
//--------------------------------------------------------|
//draws a quotation from albert einstein among some shapes|
//--------------------------------------------------------|
@Override
public void paint (Graphics page)
{
page.drawRect (50, 50, 40, 40); //square
page.drawRect (60, 80, 225, 30); //rectangle
page.drawOval (75, 65, 20, 20); //circle
page.drawLine (35, 60, 100, 120); //line
page.drawString ("Out of clutter, find simplicity.", 110, 70);
page.drawString ("-- Albert Einstein", 130, 100);
}
}
/*<APPLET CODE="Einstein.java" HEIGHT = 400 WIDTH = 400></APPLET>*/
答案 1 :(得分:0)
page.drawRect (50, 50, 40, 40,); // remove extra ,
使用如下
page.drawRect (50, 50, 40, 40);
这不是一个严肃的问题,下次在来之前检查你的代码两次。另外我建议您使用IDE编码,因为它将指导您解决这类问题。