| 发表于:2007-02-25 05:01:24 楼主 |
import javax.swing.*; import java.awt.*; public class nothelloworld { public static void main(string[] args) { nothelloworldframe frame = new nothelloworldframe(); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); } } class nothelloworldframe extends jframe { public nothelloworldframe() { settitle( "nothelloworld "); setsize(default_width,default_height); nothelloworldpanel panel = new nothelloworldpanel(); add(panel); } public static final int default_width = 300; public static final int default_height = 200; } class nothelloworldpanel extends jpanel { public void paintcomponent(graphics g) { //super.paintcomponent(g); g.drawstring( "not a hello ,world program ",message_x,message_y); } public static final int message_x = 75; public static final int message_y = 100; } 这段代码中,第21行的 add(panel); 代表什么意思??? 书上说如果使用的是jdk1.4一下的版本,这句该这么写 getcontentpane().add(panel) 没有分分可以散给大家,但还是希望可以帮忙解答一下啦,谢谢了。 |
|
|
|
|