However, Sun has relented somewhat in Java 1.5. You can add to the JFrame and it is treated as if you added to the correspoding contentPane. Be aware of that when debugging code under 1.5 that you also want to run under 1.4 that code won’t work.
Not only does JFrames use panes, so does JApplet, JDialog, JInternalFrame and JWindow but not JPanel.
Note there is no Pane, JPane, ContentPane or GlassPane class.
Pieces of a JFrame | |||
---|---|---|---|
Name | What Is It For? | How Created | Methods |
JFrame | Master object for the frame. Automatically creates the other pieces. | JFrame jframe = new JFrame(); |
getContentPane getGlassPane getRootPane invalidate setBackground setFont setForeground setVisible validate |
ContentPane (Container) |
keeps track of the Components contained in the JFrame or JApplet. | Container contentPane = jframe.getContentPane(); |
add remove setBackground setForeground setLayout |
DesktopPane | A type of LayeredPane where the JinternalFrames live, covering up the JFrame contents, free to move around anywhere inside the JFrame. | DesktopPane d = new DesktopPane(); d.add( anInternalFrame ); jframe.setLayeredPane( d ); |
DesktopPane.add
( child, JLayeredPane.
DEFAULT_LAYER ); remove setSelectedFrame: select which JInternalFrame is the active one. setBounds: it is up to you to size and position everything. There is no layout mananager. setLayer(Component c, int layer, int position) to place a component on a layer and at a depth Z position within that layer. |
LayeredPane | LayeredPanes allow you to place JComponents on top of one another. The LayeredPane is further subdivided into five layers: default, palette, modal, popup and drag. | LayeredPane layeredPane = frame.getLayeredPane(); |
LayeredPane.add
( child, JLayeredPane.
DEFAULT_LAYER ); remove setBounds: it is up to you to size and position everything. There is no layout mananager. setLayer(Component c, int layer, int position) to place a component on a layer and at a depth Z position within that layer. |
GlassPane (Component) |
A transparent canvas overlaying the contentPane. You use it typically for sprite animations. You do much of your drawing with colours with alpha channel values not = 0xff, to allow the contentPane to show through. I have not yet experimented to discover how its coordinate system meshes with the content pane’s. GlassPanes are also used to intercept mouse events for the frame. | Component glassPane = jframe.getGlassPane();Note, the glassPane is a lowly Component, not a Container or JComponent. All you can do is draw on it. You can’t add Components to it. |
paint |
JRootPane | deals with the decoration around the outside of the frame. | JRootPane rootPane = jframe.getRootPane(); |
setJMenuBar setWindowDecorationStyle |
This page is posted |
http://mindprod.com/jgloss/pane.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\pane.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.145.112.23] |
| |
Feedback |
You are visitor number | |