Topic: 为什么没显示? |
Print this page |
1.为什么没显示? | Copy to clipboard |
Posted by: yangxin Posted on: 2005-10-16 07:40 各位同志好,小弟刚JAVA,因为自学,书后又无答案,所以遇到这问题就给难住了,希望各位能帮帮忙,谢谢了. 我编写了一小段代码,如下: // Created by Rocky // Practice Applet // // /////////////////////////// import java.awt.Graphics; import java.applet.Applet; public class PracticeApplet extends Applet { public void mydraw(Graphics g) { g.drawString("* * * * * * * * * * * * * * * * * * * * * * * * *",25,18); g.drawString("* * Practice makes Perfect!",26,18); g.drawString("* * * * * * * * * * * * * * * * * * * * * * * * *",27,18); } // end of method: mydraw } // end of class: PracticeApplet 编译能通过,但执行时APPLET查看器里并无显示内容,我真想不透是怎么回事.请各位高手帮帮我吧. |
2.Re:为什么没显示?(Applet) [Re: yangxin] | Copy to clipboard |
Posted by: why Posted on: 2005-10-16 08:40 Why would you think it will show anything? public void mydraw(Graphics g) ==> public void paint(Graphics g) |
3.Re:为什么没显示? [Re: yangxin] | Copy to clipboard |
Posted by: yangxin Posted on: 2005-10-16 21:16 Thanks very much. The book use the method name:"paint",but I think it is not important what the method name is,so I created one,and then wrong,wrong again. So it is the problem,I know,thank you! |
4.Re:为什么没显示? [Re: yangxin] | Copy to clipboard |
Posted by: why Posted on: 2005-10-16 22:22 Read and think before you ask a question. How could you possibly think that the method name is not important What made you think that mydraw would be executed, by an intelligent java compiler or VM? |
5.Re:为什么没显示? [Re: yangxin] | Copy to clipboard |
Posted by: rhvic Posted on: 2005-10-17 11:09 You should not ask such questions: first:the who call the method mydraw()? |
6.Re:为什么没显示? [Re: yangxin] | Copy to clipboard |
Posted by: wnhoo Posted on: 2005-10-17 12:14 import java.applet.Applet; import java.awt.Graphics; import java.awt.HeadlessException; public class PracticeApplet extends Applet { public void paint(Graphics g){ g.drawString("* * * * * * * * * * * * * * * * * * * * * * * * *",25,18); g.drawString("* * Practice makes Perfect!",26,18); g.drawString("* * * * * * * * * * * * * * * * * * * * * * * * *",27,18); } public PracticeApplet() throws HeadlessException { super(); // TODO Auto-generated constructor stub } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |