[英]Difference from JFrame and JPanel object int Java Swing?
I know that JFrame is a top level container fro Swing GUI and that I can put a JPanel object inside a JFrame object. 我知道JFrame是Swing GUI的顶级容器,并且我可以将JPanel对象放在JFrame对象中。
But also JPanel is a container...so what is the difference from JFrame and JPanel. 而且JPanel是一个容器...因此,与JFrame和JPanel有什么区别。
I see that, in the GUI implementation, is implement directly a JPanel object, other times I see that is implemented a JFrame in which I put a JPanel. 我看到在GUI实现中,是直接实现JPanel对象,而其他时候,我看到是实现了放置JPanel的JFrame。
What is the difference? 有什么区别?
Tnx 特纳克斯
Andrea 安德里亚
JFrame - Used to represent the features a like a window. JFrame-用于表示功能,例如窗口。 This includes border,titlebar, different controls, and different event handlers.
这包括边框,标题栏,不同的控件和不同的事件处理程序。 refer : http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html
参考: http : //docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html
JPanel - Most Generic class used as a container to gather other elements together. JPanel-最通用的类,用作将其他元素收集在一起的容器。 This is more important with working with the visual layout or one of the provided layout managers.
这对于使用视觉布局或提供的布局管理器之一更为重要。 refer : http://docs.oracle.com/javase/6/docs/api/javax/swing/JPanel.html
请参阅: http : //docs.oracle.com/javase/6/docs/api/javax/swing/JPanel.html
EDIT: Some more 编辑:更多
A JFrame rappresent a window, the jpanel is a part of the gui contained in a window. 一个JFrame表示一个窗口,该jpanel是窗口中包含的gui的一部分。
http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html
Basically, a JFrame represents a framed window and a JPanel represents some area in which controls (eg, buttons, checkboxes, and textfields) and visuals (eg, figures, pictures, and even text) can appear. 基本上,JFrame表示框架的窗口,而JPanel表示可以在其中显示控件(例如按钮,复选框和文本字段)和视觉效果(例如图形,图片甚至文本)的某个区域。
JPanel serves as a general purpose container, while JFrame is a window commonly used for stand-alone applications, like a warning window, or a notification window. JPanel用作通用容器,而JFrame是通常用于独立应用程序的窗口,例如警告窗口或通知窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.