JFrame与JPanel的区别

JFrame是顶级容器,而JPanel是普通容器。包含Swing组件的程序必须包含一个顶级容器,而Swing组件不可以直接加入到顶级容器中。Sun文档有下列相关的解释:
1、The containment hierarchy for any window or applet that contains Swing components must have a Swing top-level container at the root of the hierarchy.
2、You don't add components directly to a top-level container such as a Jframe, and you should add components to a container (called the content pane) that is itself contained by the JFrame.
3、Swing provides three generally useful top-level container classes: JFrame, JDialog, and JApplet
至于其他的不同,它们既然是不同的类,自然不同了,可以看看API文档。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值