在JFrame中用add()添加了一个JPanel,怎么在JPanel中得到添加它的这个JFrame实例?

[复制链接]
查看11 | 回复3 | 2011-4-9 16:53:52 | 显示全部楼层 |阅读模式
查了下JDK,有个方法getParent,看说明应该就是做这个用的,试试,应该需要类型转换。getParentpublic Container getParent()Gets the parent of this component.Returns:the parent container of this componentSince:JDK1.0
回复

使用道具 举报

千问 | 2011-4-9 16:53:52 | 显示全部楼层
{setOpaque(false); }public void paint(Graphics g){ g.drawImage(image,0,0,getWidth(),getHeight(),this); super.paint(g);}}
回复

使用道具 举报

千问 | 2011-4-9 16:53:52 | 显示全部楼层
自定义JPanel在JFrame 中 JPanel panel =myJPanel(this);public class myJPanel implements JPanel{private JPanel panel;public myJPanel (JPanel p){this.panel = p;}}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行