What are the differences between a Applet, Canvas, Component, Container, Dialog, Frame, JApplet, JComponent, JContainer, JDialog, JInternalFrame, JPanel, JFrame, JWindow, Panel and Window?
When the following table suggests a Component is for AWT (Advanced Windowing Toolkit) but not Swing, it means there is an improved Swing component. In theory you could use the old AWT component, but normally you would not want to.
When it asks if Components are visible, it means, are the visible by default when first created. Obviously you set do a setVisible( true ) later. The rule of thumb is, freestanding windows start out invisible and everything else starts out visible. Another way of looking at it is, everything derived from Window starts out invisible.
The paned refers to whether you use getContentPane.setLayout or simply setLayout.
|Differences Between Various Types of Windows|
|class||What Is It||AWT||Swing||Visible||Paned||Derived From||Default Layout|
|Applet||represents the featureless Window provided by the browser for an Applet to run in.||Panel||FlowLayout|
|Button||Not a window. It is here is an example of a Component.||Component||n/a|
|Canvas||an area you can use the low level drawing tools on, rather than dropping in components placed with a LayoutManager. Raw material for creating your own components. Just a place you can draw. It cannot contain Components. For Swing, use a JPanel instead.||Component||n/a|
|Component||Not a window. It is an abstract class underlying Buttons etc.||Object||n/a|
|Container||These are the basis on which all the other windows are built. They manage the child Components and LayoutManager. They are missing an addNotify method to create the peer object, so can’t appear on screen. You don’t normally instantiate Containers directly, but some subclass of them.||Component||null|
|Dialog||A pop-up box to deliver an error message or alert. Temporary Window for displaying information or requesting keystrokes. It requires a parent Frame, thus in cannot be used inside an Applet which has no Frame. It can be modal, which means it blocks input to all other Windows until it is dismissed. It must have a Frame mentioned in the constructor.||Window||BorderLayout|
|Frame||A resizable, movable window with title bar and close button. Usually it contains Panels.||Window||BorderLayout|
|JApplet||represents the featureless Window provided by the browser for an Applet to run in.||Applet||FlowLayout|
|JButton||Not a window. It is here is an example of a JComponent.||AbstractButton, JComponent||n/a|
|JComponent||Not a window. It is an abstract class underlying JButtons etc.||Container, not Component, Container!||n/a|
|JContainer||There is no such beast! Since Containers have no on screen aspect, the ordinary AWT Container suffices.||n/a||n/a||n/a||n/a||n/a||n/a|
|JDialog||A pop-up box to deliver an error message or alert. Usually created with JOptionPane methods. Temporary Window for displaying information or requesting keystrokes. It requires a parent JFrame, thus in cannot be used inside an JApplet which has no JFrame. It can be modal, which means it blocks input to all other JWindows until it is dismissed. You can place complex arrays of Components on JDialogs, not just simple error messages.||Dialog||BorderLayout|
|JFrame||A resizable, movable window with title bar and close button. Usually it contains JPanels. The entire application is usually a JFrame.||Frame||BorderLayout|
|JInternalFrame||Independent windows that the user can resized and move, but only within an enclosing JFrame.||JComponent||BorderLayout|
|JOptionPane||A modal pop-up box to deliver an error message or alert. Temporary Window for displaying information or requesting keystrokes. It requires a parent JFrame, thus in cannot be used inside an JApplet which has no JFrame. Unlike a JDialog, JOptionPanes are always modal, which means they block input to all other JWindows until they are dismissed.||JDialog||BorderLayout|
|JPanel||A region internal to a JFrame or another JPanel. Used for grouping components together. Optionally bounded by a visible border. Lives inside some enclosing Container.||JComponent||FlowLayout|
|JWindow||A window without a title bar or move controls. The program can move and resize it, but the user cannot. It has no border at all. It optionally has a parent JFrame||Window||BorderLayout|
|Panel||A region internal to a Frame or another Panel. Used for grouping components together. Not bounded by a visible border. You can change background colour of a panel to delimit it though. Lives inside some enclosing Container.||Container||FlowLayout|
|Window||A window without a title bar or move controls. The program can move and resize it, but the user cannot. Free standing Window, not inside any other Window. It must have a parent Frame mentioned in the constructor.||Container||BorderLayout|
This page is posted
Optional Replicator mirror
Your face IP:[184.108.40.206]
You are visitor number|