容器和面板之间有什么区别? [英] what is the difference between container and panel?

查看:347
本文介绍了容器和面板之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很困惑容器和面板 我听说我们要添加的组件将被添加到容器对象中,但是 我也听说它会添加到面板中....然后谁在applet上显示组件... 它是按容器显示还是按面板显示? 还告诉我,小程序中的空白白色表面是面板还是容器??? 和什么是容器??? 我还写了有关容器和面板的程序,但不了解这两个概念.

I am really get big confused in container and panel i heard the components which we are adding that will be added to the container object,but also i heard it will added to the panel.... then who display the components on applet... does it display by container or it display by panel?? Also tell me guys the blank white surface are in applet is panel or container??? And What is container???? i also wrote program on container and panel but not understanding the concept of these both..

请澄清我的疑问:

  1. 如果我们不创建面板对象,那么这些组件也会在applet窗口中可见...

  1. if we not create panel object then also the components are visible on applet window...

如果我们不创建容器对象,那么这些组件也会在applet窗口中可见...

if we not create container object then also the components are visible on applet window...

通常我们使用add()在applet上添加组件,但是即使我们不创建面板和容器的对象也如何添加它...我尝试通过不创建面板和容器的对象来运行此程序,并且仍然可以正常工作,并且它显示了applet上的组件...如何??? 请告诉我我知道自己像个愚蠢的人,但是请清除我的疑问..由于这种困惑,我无法继续我的学习....

generally we use add() to add components on applet but how it get added even we not creating object of panel and container...i try this program by without creating object of panel and container and still it works and it shows the components on applet... how??? please tell me guys i know am asking like a stupidity but please clear my doubts.. because of this confusion i cant forward my study....

推荐答案

容器是一个概念,由Panel,JFrame或Applet(在您的情况下)实现.
1)如果我们不创建面板对象,那么这些组件在小程序窗口中也是可见的...
->是的,因为您的Jframe,Applet是主容器,所以他们能够添加不带面板的组件. 2)如果我们不创建容器对象,那么组件也将在小程序窗口中可见...
-> not create container表示不创建jframe/applet/panel.当然,什么也没显示.

Container is a concept and it's implemented by Panel, JFrame or Applet (in your case).
1)if we not create panel object then also the components are visible on applet window...
-> yes, because your Jframe, applet is master container, they are able to add component without panel. 2)if we not create container object then also the components are visible on applet window...
-> not create container means not create jframe/applet/panel. Of course, nothing to display.

您可以在下面看到所有这些都是容器:
Inheritance tree of JFrame:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame

You can see all of them are container in below:
Inheritance tree of JFrame:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame

Inheritance tree of JApplet:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet

Inheritance tree of JApplet:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet

Inheritance tree of JPanel:
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel

Inheritance tree of JPanel:
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel

这篇关于容器和面板之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆