📄 rootpane.html
字号:
The component should return to its regular layer when dropped. For information on the built-in drag-and-drop support, see<a class="TutorialLink" target="_top" href="../dnd/intro.html">Introduction to Drag and Drop and Data Transfer</a>.</td></tr></table><p><a name="examplemods">Here is a picture of RootLayeredPaneDemo,which is a version of <a href="examples/index.html#LayeredPaneDemo">LayeredPaneDemo</a>that uses the root pane's layered pane,rather than creating a new layered pane.</a></p><p><center><IMG SRC="../../figures/uiswing/components/RootLayeredPaneDemo.png" WIDTH="300" HEIGHT="350" ALIGN="BOTTOM" ALT="LayeredPaneDemo modified to use the root pane's layered pane"></center></p><blockquote><hr><strong>Try this:</strong> <ol><li> <a href="http://java.sun.com/docs/books/tutorialJWS/uiswing/components/examples/RootLayeredPaneDemo.jnlp">Run RootLayeredPaneDemo</a> (it requires release 6)using<a class="TutorialLink" target="_top" href="../../information/javawebstart.html">Java Web Start</a>. Or, to compile and run the example yourself, consult the <a href="examples/index.html#RootLayeredPaneDemo">example index</a>.<li> Move the cursor around in the window, so that Duke moves on top of other components. <br> Note that when the cursor is on top of non-label component — whether it's in the content pane or in the Java-look-and-feel provided title bar — Duke's movement is temporarily stopped. This is because mouse-motion events go to the component that's deepest in the containment hierarchy and is interested in mouse events. The mouse-motion listener that moves Duke is registered on the layered pane, and most of the components in that pane (with the exception of the labels) happen to have mouse-motion listeners. When the mouse moves over an interested component in the layered pane, the layered pane doesn't get the event and the interested component does.<li> Making sure the Top Position in Layer check box is selected, change Duke's layer to Yellow (-30000). <br> As before, he appears on top of other components, except for the Magenta (0) and Cyan (301) rectangles.<li> Keeping Duke in the Yellow layer, click the check box to send Duke to the back of layer -30000. <br> Duke disappears because the content pane and all the components in it are now above him.<li> Change Duke's layer to Cyan (301), move Duke down a bit so he's standing on the top edge of the Yellow rectangle, and then press Space to bring up the combo box's drop-down list. <br> If the look and feel implements the drop-down list as a lightweight popup, Duke appears on top of the drop-down list.</ol><hr></blockquote></blockquote><h3><a name="api">The Root Pane API</a></h3><blockquote>The tables that follow list the APIfor using root panes, glass panes,and content panes.For more information on using content panes,go to <a href="toplevel.html">Using Top-Level Containers</a>.Here are the tables in this section:<ul><li><a href="#rootpaneapi">Using a Root Pane</a><li><a href="#contentapi">Setting or Getting the Root Pane's Contents</a></ul><p>The API for using other parts of the root paneis described elsewhere:<ul><li> <a href="layeredpane.html#api">The Layered Pane API</a><li> <a href="menu.html#api">The Menu API</a></ul><p><table border=1> <caption><a name="rootpaneapi">Using a Root Pane</a></caption><tr><th align=left>Method</th><th align=left>Purpose </th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#getRootPane()">JRootPane getRootPane()</a> <br> <em>(in <code>JApplet</code>, <code>JDialog</code>, <code>JFrame</code>, <code>JInternalFrame</code>, and <code>JWindow</code>) </td> <td>Get the root pane of the applet, dialog, frame, internal frame, or window. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/SwingUtilities.html#getRootPane(java.awt.Component)">static JRootPane getRootPane(Component)</a><br> <em>(in <code>SwingUtilities</code>) </td> <td>If the component contains a root pane, return that root pane. Otherwise, return the root pane (if any) that contains the component. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JComponent.html#getRootPane()">JRootPane getRootPane()</a> <br> <em>(in <code>JComponent</code>)</em> </td> <td>Invoke the <code>SwingUtilities</code> <code>getRootPane</code> method for the <code>JComponent</code>. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRootPane.html#setDefaultButton(javax.swing.JButton)">void setDefaultButton(JButton)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRootPane.html#getDefaultButton()">JButton getDefaultButton()</a> </td> <td>Set or get which button (if any) is the default button in the root pane. A look-and-feel-specific action, such as pressing Enter, causes the button's action to be performed. </td> </tr></table><p><table border=1 width=100%> <caption><a name="contentapi">Setting or Getting the Root Pane's Contents</a><br><em>The following methods are defined in <code>JApplet</code>, <code>JDialog</code>, <code>JFrame</code>, <code>JInternalFrame</code>, <code>JRootPane</code>, and <code>JWindow</code>, unless noted otherwise.</em></caption><tr><th align=left>Method</th><th align=left>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setGlassPane(java.awt.Component)">void setGlassPane(Component)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#getGlassPane()">Component getGlassPane()</a> </td> <td>Set or get the glass pane. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setLayeredPane(javax.swing.JLayeredPane)">void setLayeredPane(JLayeredPane)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#getLayeredPane()">Container getLayeredPane()</a> </td> <td>Set or get the layered pane. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setContentPane(java.awt.Container)">void setContentPane(Container)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#getContentPane()">Container getContentPane()</a> </td> <td>Set or get the content pane. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setJMenuBar(javax.swing.JMenuBar)">void setJMenuBar(JMenuBar)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#getJMenuBar()">JMenuBar getJMenuBar()</a><br><em>(not defined in <code>JWindow</code>)</em> </td> <td>Set or get the menu bar. </td> </tr></table></blockquote><h3><a name="eg">Examples that Use Root Panes</a></h3><blockquote>Every Swing program has a root pane,but few reference it directly.The examples in the following listillustrate how to use features of <code>JRootPane</code>or the glass pane.Also see these lists:<ul><li> <a href="layeredpane.html#eg">Examples that Use Layered Panes</a><li> <a href="menu.html#eg">Examples that Use Menus</a><li> <a href="frame.html#eg">Examples that Use Frames</a> (for examples of using content panes)</ul><p><table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr><td><a href="examples/index.html#GlassPaneDemo"><code>GlassPaneDemo</code></a></td><td> This section</td><td> Uses a glass pane that paints a bit and redispatches events.</td></tr><tr><td><a href="examples/index.html#RootLayeredPaneDemo"><code>RootLayeredPaneDemo</code></a></td><td> This section</td><td> Adapts LayeredPaneDemo to use the root pane's layered pane.</td></tr><tr><td><a href="examples/index.html#ListDialog"><code>ListDialog</code></a></td><td> <a href="list.html">How to Use Lists</a></td><td> Sets the default button for a <code>JDialog</code>.</td></tr><tr><td><a href="examples/index.html#FrameDemo2"><code>FrameDemo2</code></a></td><td> <a href="frame.html">How to Make Frames</a></td><td> Sets the default button for a <code>JFrame</code>.</td></tr><tr><td><a href="../misc/examples/index.html#DragFileDemo"><code>DragFileDemo</code></a></td><td> <a class="TutorialLink" target="_top" href="../dnd/intro.html">Introduction to Drag and Drop and Data Transfer</a></td><td> Sets the default button for whatever root pane contains an instance of a particular <code>JPanel</code> subclass. Uses the <code>getRootPane</code> method inherited from <code>JComponent</code>.</td></tr></table> </blockquote> <div class=NavBit> <a target=_top href=progress.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=scrollpane.html>Next »</a> </div> </div> <div id=Footer><div id=TagNotes> Problems with the examples? Try <a target="_blank" href=../../information/run-examples.html>Compiling and Running the Examples: FAQs</a>. <br> Complaints? Compliments? Suggestions? <a target="_blank" href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give us your feedback</a>.<br><br> <a target="_blank" href="../../information/copyright.html">Copyright</a> 1995-2006 Sun Microsystems, Inc. All rights reserved. <span id=Download></span></div> </div> <div class=PrintHeaders> <b>Previous page:</b> How to Use Progress Bars <br><b>Next page:</b> How to Use Scroll Panes </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -