1. /*
  2. * @(#)JLayeredPane.java 1.38 00/04/06
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing;
  11. import java.awt.Component;
  12. import java.util.Hashtable;
  13. import java.awt.Color;
  14. import java.awt.Graphics;
  15. import java.awt.Rectangle;
  16. import javax.accessibility.*;
  17. /**
  18. * JLayeredPane adds depth to a JFC/Swing container, allowing components to overlap
  19. * each other when needed. An Integer object specifies each component's depth in the
  20. * container, where higher-numbered components sit "on top" of other
  21. * components.
  22. * For task-oriented documentation and examples of using layered panes see
  23. * <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html">How to Use a Layered Pane</a>,
  24. * a section in <em>The Java Tutorial</em>.
  25. * <P>
  26. * <TABLE ALIGN="RIGHT" BORDER="0">
  27. * <TR>
  28. * <TD ALIGN="CENTER">
  29. * <P ALIGN="CENTER"><IMG SRC="doc-files/JLayeredPane-1.gif" WIDTH="269" HEIGHT="264" ALIGN="BOTTOM" BORDER="0">
  30. * </TD>
  31. * </TR>
  32. * </TABLE>
  33. * For convenience, JLayeredPane divides the depth-range into several different
  34. * layers. Putting a component into one of those layers makes it easy to ensure
  35. * that components overlap properly, without having to worry about specifying
  36. * numbers for specific depths:
  37. * <DL>
  38. * <DT><FONT SIZE="2">DEFAULT_LAYER</FONT></DT>
  39. * <DD>The standard layer, where most components go. This the bottommost
  40. * layer.
  41. * <DT><FONT SIZE="2">PALETTE_LAYER</FONT></DT>
  42. * <DD>The palette layer sits over the default layer. Useful for floating
  43. * toolbars and palettes, so they can be positioned above other components.
  44. * <DT><FONT SIZE="2">MODAL_LAYER</FONT></DT>
  45. * <DD>The layer used for modal dialogs. They will appear on top of any
  46. * toolbars, palettes, or standard components in the container.
  47. * <DT><FONT SIZE="2">POPUP_LAYER</FONT></DT>
  48. * <DD>The popup layer displays above dialogs. That way, the popup windows
  49. * associated with combo boxes, tooltips, and other help text will appear
  50. * above the component, palette, or dialog that generated them.
  51. * <DT><FONT SIZE="2">DRAG_LAYER</FONT></DT>
  52. * <DD>When dragging a component, reassigning it to the drag layer ensures
  53. * that it is positioned over every other component in the container. When
  54. * finished dragging, it can be reassigned to its normal layer.
  55. * </DL>
  56. * The JLayeredPane methods <code>moveToFront(Component)</code>,
  57. * <code>moveToBack(Component)</code> and <code>setPosition</code> can be used
  58. * to reposition a component within its layer. The <code>setLayer</code> method
  59. * can also be used to change the component's current layer.
  60. *
  61. * <h2>Details</h2>
  62. * JLayeredPane manages it's list of children like Container, but
  63. * allows for the definition of a several layers within itself. Children
  64. * in the same layer are managed exactly like the normal Container object,
  65. * with the added feature that when children components overlap, children
  66. * in higher layers display above the children in lower layers.
  67. * <p>
  68. * Each layer is a distinct integer number. The layer attribute can be set
  69. * on a Component by passing an Integer object during the add call.<br>
  70. * For example:
  71. * <PRE>
  72. * layeredPane.add(child, JLayeredPane.DEFAULT_LAYER);
  73. * or
  74. * layeredPane.add(child, new Integer(10));
  75. * </PRE>
  76. * The layer attribute can also be set on a Component by calling<PRE>
  77. * layeredPaneParent.setLayer(child, 10)</PRE>
  78. * on the JLayeredPane that is the parent of component. The layer
  79. * should be set <i>before</i> adding the child to the parent.
  80. * <p>
  81. * Higher number layers display above lower number layers. So, using
  82. * numbers for the layers and letters for individual components, a
  83. * representative list order would look like this:<PRE>
  84. * 5a, 5b, 5c, 2a, 2b, 2c, 1a </PRE>
  85. * where the leftmost components are closest to the top of the display.
  86. * <p>
  87. * A component can be moved to the top or bottom position within its
  88. * layer by calling <code>moveToFront</code> or <code>moveToBack</code>.
  89. * <p>
  90. * The position of a component within a layer can also be specified directly.
  91. * Valid positions range from 0 up to one less than the number of
  92. * components in that layer. A value of -1 indicates the bottommost
  93. * position. A value of 0 indicates the topmost position. Unlike layer
  94. * numbers, higher position values are <i>lower</i> in the display.
  95. * <blockquote>
  96. * <b>Note:</b> This sequence (defined by java.awt.Container) is the reverse
  97. * of the layer numbering sequence. Usually though, you will use <code>moveToFront</code>,
  98. * <code>moveToBack</code>, and <code>setLayer</code>.
  99. * </blockquote>
  100. * Here are some examples using the method add(Component, layer, position):
  101. * Calling add(5x, 5, -1) results in:<PRE>
  102. * 5a, 5b, 5c, 5x, 2a, 2b, 2c, 1a </PRE>
  103. *
  104. * Calling add(5z, 5, 2) results in:<PRE>
  105. * 5a, 5b, 5z, 5c, 5x, 2a, 2b, 2c, 1a </PRE>
  106. *
  107. * Calling add(3a, 3, 7) results in:<PRE>
  108. * 5a, 5b, 5z, 5c, 5x, 3a, 2a, 2b, 2c, 1a </PRE>
  109. *
  110. * Using normal paint/event mechanics results in 1a appearing at the bottom
  111. * and 5a being above all other components.
  112. * <p>
  113. * <b>Note:</b> that these layers are simply a logical construct and LayoutManagers
  114. * will affect all child components of this container without regard for
  115. * layer settings.
  116. * <p>
  117. * <strong>Warning:</strong>
  118. * Serialized objects of this class will not be compatible with
  119. * future Swing releases. The current serialization support is appropriate
  120. * for short term storage or RMI between applications running the same
  121. * version of Swing. A future release of Swing will provide support for
  122. * long term persistence.
  123. *
  124. * @version 1.38 04/06/00
  125. * @author David Kloba
  126. */
  127. public class JLayeredPane extends JComponent implements Accessible {
  128. /// Watch the values in getObjectForLayer()
  129. /** Convenience object defining the Default layer. Equivalent to new Integer(0).*/
  130. public final static Integer DEFAULT_LAYER = new Integer(0);
  131. /** Convenience object defining the Palette layer. Equivalent to new Integer(100).*/
  132. public final static Integer PALETTE_LAYER = new Integer(100);
  133. /** Convenience object defining the Modal layer. Equivalent to new Integer(200).*/
  134. public final static Integer MODAL_LAYER = new Integer(200);
  135. /** Convenience object defining the Popup layer. Equivalent to new Integer(300).*/
  136. public final static Integer POPUP_LAYER = new Integer(300);
  137. /** Convenience object defining the Drag layer. Equivalent to new Integer(400).*/
  138. public final static Integer DRAG_LAYER = new Integer(400);
  139. /** Convenience object defining the Frame Content layer.
  140. * This layer is normally only use to positon the contentPane and menuBar
  141. * components of JFrame.
  142. * Equivalent to new Integer(-30000).
  143. * @see JFrame
  144. */
  145. public final static Integer FRAME_CONTENT_LAYER = new Integer(-30000);
  146. /** Bound property */
  147. public final static String LAYER_PROPERTY = "layeredContainerLayer";
  148. // Hashtable to store layer values for non-JComponent components
  149. private Hashtable componentToLayer;
  150. private boolean optimizedDrawingPossible = true;
  151. //////////////////////////////////////////////////////////////////////////////
  152. //// Container Override methods
  153. //////////////////////////////////////////////////////////////////////////////
  154. /** Create a new JLayeredPane */
  155. public JLayeredPane() {
  156. setLayout(null);
  157. }
  158. private void validateOptimizedDrawing() {
  159. boolean layeredComponentFound = false;
  160. synchronized(getTreeLock()) {
  161. int i,d;
  162. Integer layer = null;
  163. for(i=0,d=getComponentCount();i<d;i++) {
  164. layer = null;
  165. if(getComponent(i) instanceof JInternalFrame ||
  166. (getComponent(i) instanceof JComponent &&
  167. (layer = (Integer)((JComponent)getComponent(i)).getClientProperty(LAYER_PROPERTY)) != null)) {
  168. if(layer != null && layer.equals(FRAME_CONTENT_LAYER))
  169. continue;
  170. layeredComponentFound = true;
  171. break;
  172. }
  173. }
  174. }
  175. if(layeredComponentFound)
  176. optimizedDrawingPossible = false;
  177. else
  178. optimizedDrawingPossible = true;
  179. }
  180. protected void addImpl(Component comp, Object constraints, int index) {
  181. int layer = DEFAULT_LAYER.intValue();
  182. int pos;
  183. if(constraints instanceof Integer) {
  184. layer = ((Integer)constraints).intValue();
  185. setLayer(comp, layer);
  186. } else
  187. layer = getLayer(comp);
  188. pos = insertIndexForLayer(layer, index);
  189. super.addImpl(comp, constraints, pos);
  190. comp.validate();
  191. comp.repaint();
  192. validateOptimizedDrawing();
  193. }
  194. /**
  195. * Remove the indexed component from this pane.
  196. * This is the absolute index, ignoring layers.
  197. *
  198. * @param index an int specifying the component to remove
  199. * @see #getIndexOf
  200. */
  201. public void remove(int index) {
  202. Component c = getComponent(index);
  203. super.remove(index);
  204. validateOptimizedDrawing();
  205. }
  206. /**
  207. * Returns false if components in the pane can overlap, which makes
  208. * optimized drawing impossible. Otherwise, returns true.
  209. *
  210. * @return false if components can overlap, else true
  211. * @see JComponent#isOptimizedDrawingEnabled
  212. */
  213. public boolean isOptimizedDrawingEnabled() {
  214. return optimizedDrawingPossible;
  215. }
  216. //////////////////////////////////////////////////////////////////////////////
  217. //// New methods for managing layers
  218. //////////////////////////////////////////////////////////////////////////////
  219. /** Sets the layer property on a JComponent. This method does not cause
  220. * any side effects like setLayer() (painting, add/remove, etc).
  221. * Normally you should use the instance method setLayer(), in order to
  222. * get the desired side-effects (like repainting).
  223. *
  224. * @param c the JComponent to move
  225. * @param layer an int specifying the layer to move it to
  226. * @see #setLayer
  227. */
  228. public static void putLayer(JComponent c, int layer) {
  229. /// MAKE SURE THIS AND setLayer(Component c, int layer, int position) are SYNCED
  230. Integer layerObj;
  231. layerObj = new Integer(layer);
  232. c.putClientProperty(LAYER_PROPERTY, layerObj);
  233. }
  234. /** Gets the layer property for a JComponent, it
  235. * does not cause any side effects like setLayer(). (painting, add/remove, etc)
  236. * Normally you should use the instance method getLayer().
  237. *
  238. * @param c the JComponent to check
  239. * @return an int specifying the component's layer
  240. */
  241. public static int getLayer(JComponent c) {
  242. Integer i;
  243. if((i = (Integer)c.getClientProperty(LAYER_PROPERTY)) != null)
  244. return i.intValue();
  245. return DEFAULT_LAYER.intValue();
  246. }
  247. /** Convenience method that returns the first JLayeredPane which
  248. * contains the specified component. Note that all JFrames have a
  249. * JLayeredPane at their root, so any component in a JFrame will
  250. * have a JLayeredPane parent.
  251. *
  252. * @param c the Component to check
  253. * @return the JLayeredPane that contains the component, or
  254. * null if no JLayeredPane is found in the component
  255. * hierarchy
  256. * @see JFrame
  257. * @see JRootPane
  258. */
  259. public static JLayeredPane getLayeredPaneAbove(Component c) {
  260. if(c == null) return null;
  261. Component parent = c.getParent();
  262. while(parent != null && !(parent instanceof JLayeredPane))
  263. parent = parent.getParent();
  264. return (JLayeredPane)parent;
  265. }
  266. /** Sets the layer attribute on the specified component,
  267. * making it the bottommost component in that layer.
  268. * Should be called before adding to parent.
  269. *
  270. * @param c the Component to set the layer for
  271. * @param layer an int specifying the layer to set, where
  272. * lower numbers are closer to the bottom
  273. */
  274. public void setLayer(Component c, int layer) {
  275. setLayer(c, layer, -1);
  276. }
  277. /** Sets the layer attribute for the specified component and
  278. * also sets its position within that layer.
  279. *
  280. * @param c the Component to set the layer for
  281. * @param layer an int specifying the layer to set, where
  282. * lower numbers are closer to the bottom
  283. * @param position an int specifying the position within the
  284. * layer, where 0 is the topmost position and -1
  285. * is the bottommost position
  286. */
  287. public void setLayer(Component c, int layer, int position) {
  288. Integer layerObj;
  289. layerObj = getObjectForLayer(layer);
  290. if(layer == getLayer(c) && position == getPosition(c)) {
  291. if(c instanceof JComponent)
  292. repaint(((JComponent)c)._bounds);
  293. else
  294. repaint(c.getBounds());
  295. return;
  296. }
  297. /// MAKE SURE THIS AND putLayer(JComponent c, int layer) are SYNCED
  298. if(c instanceof JComponent)
  299. ((JComponent)c).putClientProperty(LAYER_PROPERTY, layerObj);
  300. else
  301. getComponentToLayer().put((Component)c, layerObj);
  302. if(c.getParent() == null || c.getParent() != this) {
  303. if(c instanceof JComponent)
  304. repaint(((JComponent)c)._bounds);
  305. else
  306. repaint(c.getBounds());
  307. return;
  308. }
  309. // Remove the Component and re-add after re-setting the layer
  310. // this is necessary now because I have no access to the
  311. // components[] in Container, to reorder things.
  312. remove(c);
  313. // ALERT passing NULL here for the constraints may be bad
  314. // the current hacks to fix this smell bad right now.
  315. // Cannot override
  316. add(c, null, position);
  317. if(c instanceof JComponent)
  318. repaint(((JComponent)c)._bounds);
  319. else
  320. repaint(c.getBounds());
  321. }
  322. /**
  323. * Returns the layer attribute for the specified Component.
  324. *
  325. * @param c the Component to check
  326. * @return an int specifying the component's current layer
  327. */
  328. public int getLayer(Component c) {
  329. Integer i;
  330. if(c instanceof JComponent)
  331. i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY);
  332. else
  333. i = (Integer)getComponentToLayer().get((Component)c);
  334. if(i == null)
  335. return DEFAULT_LAYER.intValue();
  336. return i.intValue();
  337. }
  338. /**
  339. * Returns the index of the specified Component.
  340. * This is the absolute index, ignoring layers.
  341. * Index numbers, like position numbers, have the topmost component
  342. * at index zero. Larger numbers are closer to the bottom.
  343. *
  344. * @param c the Component to check
  345. * @return an int specifying the component's index
  346. */
  347. public int getIndexOf(Component c) {
  348. int i, count;
  349. count = getComponentCount();
  350. for(i = 0; i < count; i++) {
  351. if(c == getComponent(i))
  352. return i;
  353. }
  354. return -1;
  355. }
  356. /**
  357. * Moves the component to the top of the components in it's current layer
  358. * (position 0).
  359. *
  360. * @param c the Component to move
  361. * @see #setPosition(Component, int)
  362. */
  363. public void moveToFront(Component c) {
  364. setPosition(c, 0);
  365. }
  366. /**
  367. * Moves the component to the bottom of the components in it's current layer
  368. * (position -1).
  369. *
  370. * @param c the Component to move
  371. * @see #setPosition(Component, int)
  372. */
  373. public void moveToBack(Component c) {
  374. setPosition(c, getComponentCountInLayer(getLayer(c)));
  375. }
  376. /**
  377. * Moves the component to <code>position</code> within it's current layer,
  378. * where 0 is the topmost position within the layer and -1 is the bottommost
  379. * position.
  380. * <p>
  381. * <b>Note:</b> Position numbering is defined by java.awt.Container, and
  382. * is the opposite of layer numbering. Lower position numbers are closer
  383. * to the top (0 is topmost), and higher position numbers are closer to
  384. * the bottom.
  385. *
  386. * @param c the Component to move
  387. * @param position an int in the range -1..N-1, where N is the number of
  388. * components in the component's current layer
  389. */
  390. public void setPosition(Component c, int position) {
  391. setLayer(c, getLayer(c), position);
  392. }
  393. /**
  394. * Get the relative position of the component within its layer.
  395. *
  396. * @param c the Component to check
  397. * @return an int giving the component's position, where 0 is the
  398. * topmost position and the highest index value = the count
  399. * count of components at that layer, minus 1
  400. *
  401. * @see #getComponentCountInLayer
  402. */
  403. public int getPosition(Component c) {
  404. int i, count, startLayer, curLayer, startLocation, pos = 0;
  405. count = getComponentCount();
  406. startLocation = getIndexOf(c);
  407. if(startLocation == -1)
  408. return -1;
  409. startLayer = getLayer(c);
  410. for(i = startLocation - 1; i >= 0; i--) {
  411. curLayer = getLayer(getComponent(i));
  412. if(curLayer == startLayer)
  413. pos++;
  414. else
  415. return pos;
  416. }
  417. return pos;
  418. }
  419. /** Returns the highest layer value from all current children.
  420. * Returns 0 if there are no children.
  421. *
  422. * @return an int indicating the layer of the topmost component in the
  423. * pane, or zero if there are no children
  424. */
  425. public int highestLayer() {
  426. if(getComponentCount() > 0)
  427. return getLayer(getComponent(0));
  428. return 0;
  429. }
  430. /** Returns the lowest layer value from all current children.
  431. * Returns 0 if there are no children.
  432. *
  433. * @return an int indicating the layer of the bottommost component in the
  434. * pane, or zero if there are no children
  435. */
  436. public int lowestLayer() {
  437. int count = getComponentCount();
  438. if(count > 0)
  439. return getLayer(getComponent(count-1));
  440. return 0;
  441. }
  442. /**
  443. * Returns the number of children currently in the specified layer.
  444. *
  445. * @param layer an int specifying the layer to check
  446. * @return an int specifying the number of components in that layer
  447. */
  448. public int getComponentCountInLayer(int layer) {
  449. int i, count, curLayer;
  450. int layerCount = 0;
  451. count = getComponentCount();
  452. for(i = 0; i < count; i++) {
  453. curLayer = getLayer(getComponent(i));
  454. if(curLayer == layer) {
  455. layerCount++;
  456. /// Short circut the counting when we have them all
  457. } else if(layerCount > 0 || curLayer < layer) {
  458. break;
  459. }
  460. }
  461. return layerCount;
  462. }
  463. /**
  464. * Returns an array of the components in the specified layer.
  465. *
  466. * @param layer an int specifying the layer to check
  467. * @return an array of Components contained in that layer
  468. */
  469. public Component[] getComponentsInLayer(int layer) {
  470. int i, count, curLayer;
  471. int layerCount = 0;
  472. Component[] results;
  473. results = new Component[getComponentCountInLayer(layer)];
  474. count = getComponentCount();
  475. for(i = 0; i < count; i++) {
  476. curLayer = getLayer(getComponent(i));
  477. if(curLayer == layer) {
  478. results[layerCount++] = getComponent(i);
  479. /// Short circut the counting when we have them all
  480. } else if(layerCount > 0 || curLayer < layer) {
  481. break;
  482. }
  483. }
  484. return results;
  485. }
  486. /**
  487. * Paints this JLayeredPane within the specified graphics context.
  488. *
  489. * @param g the Graphics context within which to paint
  490. */
  491. public void paint(Graphics g) {
  492. if(isOpaque()) {
  493. Rectangle r = g.getClipBounds();
  494. Color c = getBackground();
  495. if(c == null)
  496. c = Color.lightGray;
  497. g.setColor(c);
  498. g.fillRect(r.x, r.y, r.width, r.height);
  499. }
  500. super.paint(g);
  501. }
  502. //////////////////////////////////////////////////////////////////////////////
  503. //// Implementation Details
  504. //////////////////////////////////////////////////////////////////////////////
  505. /**
  506. * Returns the hashtable that maps components to layers.
  507. *
  508. * @return the Hashtable used to map components to their layers
  509. */
  510. protected Hashtable getComponentToLayer() {
  511. if(componentToLayer == null)
  512. componentToLayer = new Hashtable(4);
  513. return componentToLayer;
  514. }
  515. /**
  516. * Returns the Integer object associated with a specified layer.
  517. *
  518. * @param layer an int specifying the layer
  519. * @return an Integer object for that layer
  520. */
  521. protected Integer getObjectForLayer(int layer) {
  522. Integer layerObj;
  523. switch(layer) {
  524. case 0:
  525. layerObj = DEFAULT_LAYER;
  526. break;
  527. case 100:
  528. layerObj = PALETTE_LAYER;
  529. break;
  530. case 200:
  531. layerObj = MODAL_LAYER;
  532. break;
  533. case 300:
  534. layerObj = POPUP_LAYER;
  535. break;
  536. case 400:
  537. layerObj = DRAG_LAYER;
  538. break;
  539. default:
  540. layerObj = new Integer(layer);
  541. }
  542. return layerObj;
  543. }
  544. /**
  545. * Primative method that determines the proper location to
  546. * insert a new child based on layer and position requests.
  547. *
  548. * @param layer an int specifying the layer
  549. * @param position an int specifying the position within the layer
  550. * @return an int giving the (absolute) insertion-index
  551. *
  552. * @see #getIndexOf
  553. */
  554. protected int insertIndexForLayer(int layer, int position) {
  555. int i, count, curLayer;
  556. int layerStart = -1;
  557. int layerEnd = -1;
  558. count = getComponentCount();
  559. for(i = 0; i < count; i++) {
  560. curLayer = getLayer(getComponent(i));
  561. if(layerStart == -1 && curLayer == layer) {
  562. layerStart = i;
  563. }
  564. if(curLayer < layer ) {
  565. if(i == 0) {
  566. // layer is greater than any current layer
  567. // [ ASSERT(layer > highestLayer()) ]
  568. layerStart = 0;
  569. layerEnd = 0;
  570. } else {
  571. layerEnd = i;
  572. }
  573. break;
  574. }
  575. }
  576. // layer requested is lower than any current layer
  577. // [ ASSERT(layer < lowestLayer()) ]
  578. // put it on the bottom of the stack
  579. if(layerStart == -1 && layerEnd == -1)
  580. return count;
  581. // In the case of a single layer entry handle the degenerative cases
  582. if(layerStart != -1 && layerEnd == -1)
  583. layerEnd = count;
  584. if(layerEnd != -1 && layerStart == -1)
  585. layerStart = layerEnd;
  586. // If we are adding to the bottom, return the last element
  587. if(position == -1)
  588. return layerEnd;
  589. // Otherwise make sure the requested position falls in the
  590. // proper range
  591. if(position > -1 && layerStart + position <= layerEnd)
  592. return layerStart + position;
  593. // Otherwise return the end of the layer
  594. return layerEnd;
  595. }
  596. /**
  597. * Returns a string representation of this JLayeredPane. This method
  598. * is intended to be used only for debugging purposes, and the
  599. * content and format of the returned string may vary between
  600. * implementations. The returned string may be empty but may not
  601. * be <code>null</code>.
  602. *
  603. * @return a string representation of this JLayeredPane.
  604. */
  605. protected String paramString() {
  606. String optimizedDrawingPossibleString = (optimizedDrawingPossible ?
  607. "true" : "false");
  608. return super.paramString() +
  609. ",optimizedDrawingPossible=" + optimizedDrawingPossibleString;
  610. }
  611. /////////////////
  612. // Accessibility support
  613. ////////////////
  614. /**
  615. * Gets the AccessibleContext associated with this JLayeredPane.
  616. * For layered panes, the AccessibleContext takes the form of an
  617. * AccessibleJLayeredPane.
  618. * A new AccessibleJLayeredPane instance is created if necessary.
  619. *
  620. * @return an AccessibleJLayeredPane that serves as the
  621. * AccessibleContext of this JLayeredPane
  622. */
  623. public AccessibleContext getAccessibleContext() {
  624. if (accessibleContext == null) {
  625. accessibleContext = new AccessibleJLayeredPane();
  626. }
  627. return accessibleContext;
  628. }
  629. /**
  630. * This class implements accessibility support for the
  631. * <code>JLayeredPane</code> class. It provides an implementation of the
  632. * Java Accessibility API appropriate to layered pane user-interface
  633. * elements.
  634. * <p>
  635. * <strong>Warning:</strong>
  636. * Serialized objects of this class will not be compatible with
  637. * future Swing releases. The current serialization support is appropriate
  638. * for short term storage or RMI between applications running the same
  639. * version of Swing. A future release of Swing will provide support for
  640. * long term persistence.
  641. */
  642. protected class AccessibleJLayeredPane extends AccessibleJComponent {
  643. /**
  644. * Get the role of this object.
  645. *
  646. * @return an instance of AccessibleRole describing the role of the
  647. * object
  648. * @see AccessibleRole
  649. */
  650. public AccessibleRole getAccessibleRole() {
  651. return AccessibleRole.LAYERED_PANE;
  652. }
  653. }
  654. }