I found this line on the java docs tutorial site- "A Frame is a top-level window with a title and a border". Here, what is the meaning of "top-level window"?
In GUI toolkits such as AWT, a top-level window is a window which is usually known to the OS (heavy-weight components).
Side note: AWT (and even Swing) is a pretty old technology. I recommend to use JavaFX where possible.
A 'top-level window' or 'top level container' is something that can be shown on screen without having to add it to another component. We would start a GUI with a top level container, and then add panels and components to that TLC. EG of top level containers..
Frame
, Window
, Dialog
.. JFrame
, JWindow
, JDialog
, JOptionPane
.. Stage
(I have not used Java-FX much, so am unfamiliar with the other variants of TLCs, but see the Java-FX API docs for other examples). See also this answer for many good reasons to abandon AWT components in favor of Swing. As to abandoning Swing for Java-FX, I'll be unwilling to do so until Java-FX is promoted to the Java API's Java docs, and makes it into the official Java Tutorial. Sun, then Oracle, has a bad habit of hyping many technologies only to later quietly drop support & development for them.
a window without a parent.
a window can have child windows alright and they have a parent then
Observe difference among these classes.
Frame is top level window because it has border and title. An instance of frame can have a menubar. Without those it is mere is an instance of java.awt.Window class.
Window class: It has neither border not title. Window class is not attached to nor embedded within another container.
Dialog: It has border and title. An instance of the Dialog class cannot exist without an associated instance of the Frame class.
Panel: just a generic container to hold components. Its instance provides a container to which to add components.
Note: Revert me back if further clarification is required.
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.