I know that JFrame is a top level container fro Swing GUI and that I can put a JPanel object inside a JFrame object.
But also JPanel is a container...so what is the difference from JFrame and 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.
What is the difference?
Tnx
Andrea
JFrame - Used to represent the features a like a window. This includes border,titlebar, different controls, and different event handlers. refer : 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. 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
EDIT: Some more
A JFrame rappresent a window, the jpanel is a part of the gui contained in a window.
http://docs.oracle.com/javase/tutorial/uiswing/components/frame.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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.