当前位置: 技术问答>java相关
public void paint(Graphics g)该语句对吗?
来源: 互联网 发布时间:2015-07-31
本文导语: 我在看其中有个例子,编译不了呀,小弟有点不理解 // Fig.3-6:WelcomeApplet.java //A first applet in java import javax.swing.JApplet; //import class japplet import java.awt.Graphics;//import class Graphics; public class WelcomeApplet extends JApplet...
我在看其中有个例子,编译不了呀,小弟有点不理解
// Fig.3-6:WelcomeApplet.java
//A first applet in java
import javax.swing.JApplet; //import class japplet
import java.awt.Graphics;//import class Graphics;
public class WelcomeApplet extends JApplet {
public void paint ( Graphics g );
{
g.drawString ("Welcome to java programing!!",25,25);
}
}
报错信息:
--------------------Configuration: JDK version 1.4 --------------------
D:javaprogramWelcomeApplet.java:7: missing method body, or declare abstract
public void paint( Graphics g );
^
D:javaprogramWelcomeApplet.java:9: cannot resolve symbol
symbol : variable g
location: class WelcomeApplet
g.drawString ("Welcome to java programing!!",25,25);
^
2 errors
Process completed.
public void paint(Graphics g)这句是不是有问题呀?还是我的环境变量没有设置好呢?
// Fig.3-6:WelcomeApplet.java
//A first applet in java
import javax.swing.JApplet; //import class japplet
import java.awt.Graphics;//import class Graphics;
public class WelcomeApplet extends JApplet {
public void paint ( Graphics g );
{
g.drawString ("Welcome to java programing!!",25,25);
}
}
报错信息:
--------------------Configuration: JDK version 1.4 --------------------
D:javaprogramWelcomeApplet.java:7: missing method body, or declare abstract
public void paint( Graphics g );
^
D:javaprogramWelcomeApplet.java:9: cannot resolve symbol
symbol : variable g
location: class WelcomeApplet
g.drawString ("Welcome to java programing!!",25,25);
^
2 errors
Process completed.
public void paint(Graphics g)这句是不是有问题呀?还是我的环境变量没有设置好呢?
|
去掉public void paint( Graphics g );分号!!!!
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。