标题:[求助]请问paintComponent要怎么用?
取消只看楼主
apodemas
Rank: 1
等 级:新手上路
帖 子:153
专家分:0
注 册:2005-4-22
 问题点数:0 回复次数:0 
[求助]请问paintComponent要怎么用?
JComponet中的paintComponent要怎么用呢?感觉好象和paint差不多,但------: import java.awt.*; import javax.swing.*; class Mycanvas extends JPanel{ public void paintComponet(Graphics g){ super.paintComponent(g); g.setColor(Color.red); g.drawString("a JPanle used as canvas",50,50); } } public class Apt extends JApplet{ Mycanvas canvas; JPanel panel; JButton button; public void init(){ canvas=new Mycanvas();panel=new JPanel(); button=new JButton("ok"); canvas.setVisible(true); panel.add(button);Container con=getContentPane(); con.add(panel,BorderLayout.NORTH); con.add(canvas,BorderLayout.CENTER); } } 书上的例子,结果看起来和这个方法并没什么关系... 文档上写的: Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect..... 似乎也没写清楚用法,反正是没看明白...
搜索更多相关主题的帖子: void public button import 
2005-10-06 23:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-29461-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041310 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved