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"?
4 Answers
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. E.G. of top level containers..
- AWT -
Frame
,Window
,Dialog
.. - Swing -
JFrame
,JWindow
,JDialog
,JOptionPane
.. - Java-FX -
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.

- 1
- 1

- 168,117
- 40
- 217
- 433
-
1The JavaFX equivalent would be `Stage` and `Window` (though it seems not all sub-classes are top-level windows). – Puce Mar 06 '17 at 21:26
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.

- 37,247
- 13
- 80
- 152
-
-
@Daij-Djan I don't have a specific source of definition. But I just checked the official Java tutorial and Javadoc. They have a similar view: http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html – Puce Mar 06 '17 at 13:55
-
a window without a parent.
a window can have child windows alright and they have a parent then

- 49,552
- 17
- 113
- 135
-
-
well it is different in all toolkits I know but Im willing to grant you the benefit of the doubt concerning java ;) – Daij-Djan Mar 06 '17 at 13:23
-
in my mind this definition is right still :) but it seems java seems to say 'only windows backed by separate native windows are top-level" – Daij-Djan Mar 06 '17 at 15:47
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.

- 2,523
- 1
- 18
- 28
-
1and? decoration don't define either.. I can have a window without anything thats still top level – Daij-Djan Mar 06 '17 at 13:22