1. /*
  2. * @(#)JDialog.java 1.53 00/08/05
  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.*;
  12. import java.awt.event.*;
  13. import java.beans.PropertyChangeListener;
  14. import java.util.Locale;
  15. import java.util.Vector;
  16. import java.io.Serializable;
  17. import javax.accessibility.*;
  18. import java.applet.Applet;
  19. /**
  20. * The main class for creating a dialog window. You can use this class
  21. * to create a custom dialog, or invoke the many class methods
  22. * in {@link JOptionPane} to create a variety of standard dialogs.
  23. * For information about creating dialogs, see
  24. * <em>The Java Tutorial</em> section
  25. * <a
  26. href="http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html">How
  27. * to Make Dialogs</a>.
  28. *
  29. * <p>
  30. *
  31. * The <code>JDialog</code> component contains a <code>JRootPane</code>
  32. * as its only child.
  33. * The <code>contentPane</code> should be the parent of any children of the
  34. * <code>JDialog</code>. From the older <code>java.awt.Window</code> object
  35. * you would normally do something like this:
  36. * <PRE>
  37. * dialog.add(child);
  38. * </PRE>
  39. * Using <code>JDialog</code> the proper semantic is:
  40. * <PRE>
  41. * dialog.getContentPane().add(child);
  42. * </PRE>
  43. * The same priniciple holds true for setting layout managers, removing
  44. * components, listing children, etc. All these methods should normally be
  45. * sent to the <code>contentPane</code> instead of to the <code>JDialog</code>.
  46. * The <code>contentPane</code> is always non-<code>null</code>.
  47. * Attempting to set it to <code>null</code> generates an exception.
  48. * The default <code>contentPane</code> has a <code>BorderLayout</code>
  49. * manager set on it.
  50. * <p>
  51. * Please see the <code>JRootPane</code> documentation for a complete
  52. * description of the <code>contentPane</code>, <code>glassPane</code>,
  53. * and <code>layeredPane</code> components.
  54. * <p>
  55. * For the keyboard keys used by this component in the standard Look and
  56. * Feel (L&F) renditions, see the
  57. * <a href="doc-files/Key-Index.html#JDialog">JDialog</a> key assignments.
  58. * <p>
  59. * <strong>Warning:</strong>
  60. * Serialized objects of this class will not be compatible with
  61. * future Swing releases. The current serialization support is appropriate
  62. * for short term storage or RMI between applications running the same
  63. * version of Swing. A future release of Swing will provide support for
  64. * long term persistence.
  65. *
  66. * @see JOptionPane
  67. * @see JRootPane
  68. *
  69. * @beaninfo
  70. * attribute: isContainer true
  71. * attribute: containerDelegate getContentPane
  72. * description: A toplevel window for creating dialog boxes.
  73. *
  74. * @version 1.53 08/05/00
  75. * @author David Kloba
  76. * @author James Gosling
  77. * @author Scott Violet
  78. */
  79. public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer
  80. {
  81. private int defaultCloseOperation = HIDE_ON_CLOSE;
  82. /**
  83. * @see #getRootPane
  84. * @see #setRootPane
  85. */
  86. protected JRootPane rootPane;
  87. /**
  88. * @see #isRootPaneCheckingEnabled
  89. * @see #setRootPaneCheckingEnabled
  90. */
  91. protected boolean rootPaneCheckingEnabled = false;
  92. /**
  93. * Creates a non-modal dialog without a title and without a specified
  94. * <code>Frame</code> owner. A shared, hidden frame will be
  95. * set as the owner of the dialog.
  96. */
  97. public JDialog() {
  98. this((Frame)null, false);
  99. }
  100. /**
  101. * Creates a non-modal dialog without a title with the
  102. * specifed <code>Frame</code> as its owner.
  103. *
  104. * @param owner the <code>Frame</code> from which the dialog is displayed
  105. */
  106. public JDialog(Frame owner) {
  107. this(owner, false);
  108. }
  109. /**
  110. * Creates a modal or non-modal dialog without a title and
  111. * with the specified owner <code>Frame</code>.
  112. *
  113. * @param owner the <code>Frame</code> from which the dialog is displayed
  114. * @param modal true for a modal dialog, false for one that allows
  115. * others windows to be active at the same time
  116. */
  117. public JDialog(Frame owner, boolean modal) {
  118. this(owner, null, modal);
  119. }
  120. /**
  121. * Creates a non-modal dialog with the specified title and
  122. * with the specified owner frame.
  123. *
  124. * @param owner the <code>Frame</code> from which the dialog is displayed
  125. * @param title the <code>String</code> to display in the dialog's
  126. * title bar
  127. */
  128. public JDialog(Frame owner, String title) {
  129. this(owner, title, false);
  130. }
  131. /**
  132. * Creates a modal or non-modal dialog with the specified title
  133. * and the specified owner <code>Frame</code>. All constructors
  134. * defer to this one.
  135. * <p>
  136. * NOTE: Any popup components (<code>JComboBox</code>,
  137. * <code>JPopupMenu</code>, <code>JMenuBar</code>)
  138. * created within a modal dialog will be forced to be lightweight.
  139. *
  140. * @param owner the <code>Frame</code> from which the dialog is displayed
  141. * @param title the <code>String</code> to display in the dialog's
  142. * title bar
  143. * @param modal true for a modal dialog, false for one that allows
  144. * other windows to be active at the same time
  145. */
  146. public JDialog(Frame owner, String title, boolean modal) {
  147. super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
  148. title, modal);
  149. dialogInit();
  150. }
  151. /**
  152. * Creates a non-modal dialog without a title with the
  153. * specifed <code>Dialog</code> as its owner.
  154. *
  155. * @param owner the <code>Dialog</code> from which the dialog is displayed
  156. */
  157. public JDialog(Dialog owner) {
  158. this(owner, false);
  159. }
  160. /**
  161. * Creates a modal or non-modal dialog without a title and
  162. * with the specified owner dialog.
  163. * <p>
  164. *
  165. * @param owner the <code>Dialog</code> from which the dialog is displayed
  166. * @param modal true for a modal dialog, false for one that allows
  167. * other windows to be active at the same time
  168. */
  169. public JDialog(Dialog owner, boolean modal) {
  170. this(owner, null, modal);
  171. }
  172. /**
  173. * Creates a non-modal dialog with the specified title and
  174. * with the specified owner dialog.
  175. *
  176. * @param owner the <code>Dialog</code> from which the dialog is displayed
  177. * @param title the <code>String</code> to display in the dialog's
  178. * title bar
  179. */
  180. public JDialog(Dialog owner, String title) {
  181. this(owner, title, false);
  182. }
  183. /**
  184. * Creates a modal or non-modal dialog with the specified title
  185. * and the specified owner frame.
  186. *
  187. * @param owner the <code>Dialog</code> from which the dialog is displayed
  188. * @param title the <code>String</code> to display in the dialog's
  189. * title bar
  190. * @param modal true for a modal dialog, false for one that allows
  191. * other windows to be active at the same time
  192. */
  193. public JDialog(Dialog owner, String title, boolean modal) {
  194. super(owner, title, modal);
  195. dialogInit();
  196. }
  197. /** Called by the constructors to init the <code>JDialog</code> properly. */
  198. protected void dialogInit() {
  199. enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
  200. setRootPane(createRootPane());
  201. setRootPaneCheckingEnabled(true);
  202. }
  203. /**
  204. * Called by the constructor methods to create the default
  205. * <code>rootPane</code>.
  206. */
  207. protected JRootPane createRootPane() {
  208. return new JRootPane();
  209. }
  210. /**
  211. * Processes key events occurring on this component and, if appropriate,
  212. * passes them on to components in the dialog which have registered
  213. * interest in them.
  214. *
  215. * @param e the key event
  216. * @see java.awt.Component#processKeyEvent
  217. */
  218. protected void processKeyEvent(KeyEvent e) {
  219. super.processKeyEvent(e);
  220. if(!e.isConsumed()) {
  221. JComponent.processKeyBindingsForAllComponents(e,this,e.getID() == KeyEvent.KEY_PRESSED);
  222. }
  223. }
  224. /**
  225. * Handles window events depending on the state of the
  226. * <code>defaultCloseOperation</code> property.
  227. *
  228. * @see #setDefaultCloseOperation
  229. */
  230. protected void processWindowEvent(WindowEvent e) {
  231. super.processWindowEvent(e);
  232. if (e.getID() == WindowEvent.WINDOW_CLOSING) {
  233. switch(defaultCloseOperation) {
  234. case HIDE_ON_CLOSE:
  235. setVisible(false);
  236. break;
  237. case DISPOSE_ON_CLOSE:
  238. setVisible(false);
  239. dispose();
  240. break;
  241. case DO_NOTHING_ON_CLOSE:
  242. default:
  243. break;
  244. }
  245. }
  246. }
  247. /**
  248. * Sets the operation which will happen by default when
  249. * the user initiates a "close" on this dialog.
  250. * The possible choices are:
  251. * <ul>
  252. * <li>DO_NOTHING_ON_CLOSE - do not do anything - require the
  253. * program to handle the operation in the <code>windowClosing</code>
  254. * method of a registered <code>WindowListener</code> object.
  255. * <li>HIDE_ON_CLOSE - automatically hide the dialog after
  256. * invoking any registered <code>WindowListener</code> objects
  257. * <li>DISPOSE_ON_CLOSE - automatically hide and dispose the
  258. * dialog after invoking any registered <code>WindowListener</code> objects
  259. * </ul>
  260. * <p>
  261. * The value is set to HIDE_ON_CLOSE by default.
  262. * @see #addWindowListener
  263. * @see #getDefaultCloseOperation
  264. *
  265. * @beaninfo
  266. * preferred: true
  267. * description: The dialog's default close operation.
  268. */
  269. public void setDefaultCloseOperation(int operation) {
  270. this.defaultCloseOperation = operation;
  271. }
  272. /**
  273. * Returns the operation which occurs when the user
  274. * initiates a "close" on this dialog.
  275. *
  276. * @return an integer indicating the window-close operation
  277. * @see #setDefaultCloseOperation
  278. */
  279. public int getDefaultCloseOperation() {
  280. return defaultCloseOperation;
  281. }
  282. /**
  283. * Calls <code>paint(g)</code>. This method was overridden to
  284. * prevent an unneccessary call to clear the background.
  285. */
  286. public void update(Graphics g) {
  287. paint(g);
  288. }
  289. /**
  290. * Sets the menubar for this dialog.
  291. * @param menubar the menubar being placed in the dialog
  292. *
  293. * @see #getJMenuBar
  294. *
  295. * @beaninfo
  296. * hidden: true
  297. * description: The menubar for accessing pulldown menus from this dialog.
  298. */
  299. public void setJMenuBar(JMenuBar menu) {
  300. getRootPane().setMenuBar(menu);
  301. }
  302. /**
  303. * Returns the menubar set on this dialog.
  304. *
  305. * @see #setJMenuBar
  306. */
  307. public JMenuBar getJMenuBar() {
  308. return getRootPane().getMenuBar();
  309. }
  310. /**
  311. * Returns true if the methods <code>add</code> and <code>setLayout</code>
  312. * should be checked.
  313. *
  314. * @return true if <code>add</code> and <code>setLayout</code> should
  315. * be checked
  316. * @see #addImpl
  317. * @see #setLayout
  318. * @see #setRootPaneCheckingEnabled
  319. */
  320. protected boolean isRootPaneCheckingEnabled() {
  321. return rootPaneCheckingEnabled;
  322. }
  323. /**
  324. * If true then calls to <code>add</code> and <code>setLayout</code>
  325. * will cause an exception to be thrown.
  326. *
  327. * @see #addImpl
  328. * @see #setLayout
  329. * @see #isRootPaneCheckingEnabled
  330. * @beaninfo
  331. * hidden: true
  332. * description: Whether the add and setLayout methods throw exceptions when invoked.
  333. */
  334. protected void setRootPaneCheckingEnabled(boolean enabled) {
  335. rootPaneCheckingEnabled = enabled;
  336. }
  337. /**
  338. * Creates a message that can be used as a runtime exception. The
  339. * message will look like the following:
  340. * <pre>
  341. * "Do not use JDialog.add() use JDialog.getContentPane().add() instead"
  342. * </pre>
  343. * @param op a <code>String</code> containing the attempted operation
  344. * @return an <code>Error</code> containing the constructed string
  345. */
  346. private Error createRootPaneException(String op) {
  347. String type = getClass().getName();
  348. return new Error(
  349. "Do not use " + type + "." + op + "() use "
  350. + type + ".getContentPane()." + op + "() instead");
  351. }
  352. /**
  353. * By default, children may not be added directly to a this component,
  354. * they must be added to its <code>contentPane</code> instead.
  355. * For example:
  356. * <pre>
  357. * thisComponent.getContentPane().add(child)
  358. * </pre>
  359. * An attempt to add to directly to this component will cause an
  360. * runtime exception to be thrown if rootPaneCheckingEnabled is true.
  361. * Subclasses can disable this behavior.
  362. *
  363. * @param comp the <code>Component</code> to be enhanced
  364. * @param constraints the constraints to be respected
  365. * @param index the index (an integer)
  366. * @see #setRootPaneCheckingEnabled
  367. * @exception Error if called with rootPaneCheckingEnabled true
  368. */
  369. protected void addImpl(Component comp, Object constraints, int index)
  370. {
  371. if(isRootPaneCheckingEnabled()) {
  372. throw createRootPaneException("add");
  373. }
  374. else {
  375. super.addImpl(comp, constraints, index);
  376. }
  377. }
  378. /**
  379. * Removes the specified component from this container.
  380. * @param comp the component to be removed
  381. * @see #add
  382. */
  383. public void remove(Component comp) {
  384. if (comp == rootPane) {
  385. super.remove(comp);
  386. } else {
  387. // Client mistake, but we need to handle it to avoid a
  388. // common object leak in client applications.
  389. getContentPane().remove(comp);
  390. }
  391. }
  392. /**
  393. * By default the layout of this component may not be set,
  394. * the layout of its <code>contentPane</code> should be set instead.
  395. * For example:
  396. * <pre>
  397. * thisComponent.getContentPane().setLayout(new BorderLayout())
  398. * </pre>
  399. * An attempt to set the layout of this component will cause an
  400. * runtime exception to be thrown if rootPaneCheckingEnabled is true.
  401. * Subclasses can disable this behavior.
  402. *
  403. * @see #setRootPaneCheckingEnabled
  404. * @param manager the <code>LayoutManager</code>
  405. * @exception Error if called with rootPaneChecking true
  406. */
  407. public void setLayout(LayoutManager manager) {
  408. if(isRootPaneCheckingEnabled()) {
  409. throw createRootPaneException("setLayout");
  410. }
  411. else {
  412. super.setLayout(manager);
  413. }
  414. }
  415. /**
  416. * Returns the <code>rootPane</code> object for this dialog.
  417. *
  418. * @see #setRootPane
  419. * @see RootPaneContainer#getRootPane
  420. */
  421. public JRootPane getRootPane() {
  422. return rootPane;
  423. }
  424. /**
  425. * Sets the <code>rootPane</code> property.
  426. * This method is called by the constructor.
  427. * @param root the <code>rootPane</code> object for this dialog
  428. *
  429. * @see #getRootPane
  430. *
  431. * @beaninfo
  432. * hidden: true
  433. * description: the RootPane object for this dialog.
  434. */
  435. protected void setRootPane(JRootPane root) {
  436. if(rootPane != null) {
  437. remove(rootPane);
  438. }
  439. rootPane = root;
  440. if(rootPane != null) {
  441. boolean checkingEnabled = isRootPaneCheckingEnabled();
  442. try {
  443. setRootPaneCheckingEnabled(false);
  444. add(rootPane, BorderLayout.CENTER);
  445. }
  446. finally {
  447. setRootPaneCheckingEnabled(checkingEnabled);
  448. }
  449. }
  450. }
  451. /**
  452. * Returns the <code>contentPane</code> object for this dialog.
  453. * @return the <code>contentPane</code> property
  454. *
  455. * @see #setContentPane
  456. * @see RootPaneContainer#getContentPane
  457. */
  458. public Container getContentPane() {
  459. return getRootPane().getContentPane();
  460. }
  461. /**
  462. * Sets the <code>contentPane</code> property.
  463. * This method is called by the constructor.
  464. *
  465. * @param contentPane the <code>contentPane</code> object for this dialog
  466. *
  467. * @exception java.awt.IllegalComponentStateException (a runtime
  468. * exception) if the content pane parameter is <code>null</code>
  469. * @see #getContentPane
  470. * @see RootPaneContainer#setContentPane
  471. *
  472. * @beaninfo
  473. * hidden: true
  474. * description: The client area of the dialog where child
  475. * components are normally inserted.
  476. */
  477. public void setContentPane(Container contentPane) {
  478. getRootPane().setContentPane(contentPane);
  479. }
  480. /**
  481. * Returns the <code>layeredPane</code> object for this dialog.
  482. * @return the <code>layeredPane</code> property
  483. *
  484. * @see #setLayeredPane
  485. * @see RootPaneContainer#getLayeredPane
  486. */
  487. public JLayeredPane getLayeredPane() {
  488. return getRootPane().getLayeredPane();
  489. }
  490. /**
  491. * Sets the <code>layeredPane</code> property.
  492. * This method is called by the constructor.
  493. *
  494. * @param layeredPane the new <code>layeredPane</code> property
  495. *
  496. * @exception java.awt.IllegalComponentStateException (a runtime
  497. * exception) if the layered pane parameter is null
  498. * @see #getLayeredPane
  499. * @see RootPaneContainer#setLayeredPane
  500. *
  501. * @beaninfo
  502. * hidden: true
  503. * description: The pane which holds the various dialog layers.
  504. */
  505. public void setLayeredPane(JLayeredPane layeredPane) {
  506. getRootPane().setLayeredPane(layeredPane);
  507. }
  508. /**
  509. * Returns the <code>glassPane</code> object for this dialog.
  510. * @return the <code>glassPane</code> property
  511. *
  512. * @see #setGlassPane
  513. * @see RootPaneContainer#getGlassPane
  514. */
  515. public Component getGlassPane() {
  516. return getRootPane().getGlassPane();
  517. }
  518. /**
  519. * Sets the <code>glassPane</code> property.
  520. * This method is called by the constructor.
  521. *
  522. * @param glassPane the <code>glassPane</code> object for this dialog
  523. * @see #getGlassPane
  524. * @see RootPaneContainer#setGlassPane
  525. *
  526. * @beaninfo
  527. * hidden: true
  528. * description: A transparent pane used for menu rendering.
  529. */
  530. public void setGlassPane(Component glassPane) {
  531. getRootPane().setGlassPane(glassPane);
  532. }
  533. /**
  534. * Sets the location of the dialog relative to the specified
  535. * component. If the component is not currently showing, the
  536. * dialog is centered on the screen.
  537. *
  538. * @param c the component in relation to which the dialog's location
  539. * is determined
  540. */
  541. public void setLocationRelativeTo(Component c) {
  542. Container root=null;
  543. if (c != null) {
  544. if (c instanceof Window || c instanceof Applet) {
  545. root = (Container)c;
  546. } else {
  547. Container parent;
  548. for(parent = c.getParent() ; parent != null ; parent = parent.getParent()) {
  549. if (parent instanceof Window || parent instanceof Applet) {
  550. root = parent;
  551. break;
  552. }
  553. }
  554. }
  555. }
  556. if((c != null && !c.isShowing()) || root == null ||
  557. !root.isShowing()) {
  558. Dimension paneSize = getSize();
  559. Dimension screenSize = getToolkit().getScreenSize();
  560. setLocation((screenSize.width - paneSize.width) / 2,
  561. (screenSize.height - paneSize.height) / 2);
  562. } else {
  563. Dimension invokerSize = c.getSize();
  564. Point invokerScreenLocation;
  565. // If this method is called directly after a call to
  566. // setLocation() on the "root", getLocationOnScreen()
  567. // may return stale results (Bug#4181562), so we walk
  568. // up the tree to calculate the position instead
  569. // (unless "root" is an applet, where we cannot walk
  570. // all the way up to a toplevel window)
  571. //
  572. if (root instanceof Applet) {
  573. invokerScreenLocation = c.getLocationOnScreen();
  574. } else {
  575. invokerScreenLocation = new Point(0,0);
  576. Component tc = c;
  577. while (tc != null) {
  578. Point tcl = tc.getLocation();
  579. invokerScreenLocation.x += tcl.x;
  580. invokerScreenLocation.y += tcl.y;
  581. if (tc == root) {
  582. break;
  583. }
  584. tc = tc.getParent();
  585. }
  586. }
  587. Rectangle dialogBounds = getBounds();
  588. int dx = invokerScreenLocation.x+((invokerSize.width-dialogBounds.width)>>1);
  589. int dy = invokerScreenLocation.y+((invokerSize.height - dialogBounds.height)>>1);
  590. Dimension ss = getToolkit().getScreenSize();
  591. if (dy+dialogBounds.height>ss.height) {
  592. dy = ss.height-dialogBounds.height;
  593. dx = invokerScreenLocation.x<(ss.width>>1) ? invokerScreenLocation.x+invokerSize.width :
  594. invokerScreenLocation.x-dialogBounds.width;
  595. }
  596. if (dx+dialogBounds.width>ss.width) dx = ss.width-dialogBounds.width;
  597. if (dx<0) dx = 0;
  598. if (dy<0) dy = 0;
  599. setLocation(dx, dy);
  600. }
  601. }
  602. /**
  603. * Returns a string representation of this <code>JDialog</code>.
  604. * This method
  605. * is intended to be used only for debugging purposes, and the
  606. * content and format of the returned string may vary between
  607. * implementations. The returned string may be empty but may not
  608. * be <code>null</code>.
  609. *
  610. * @return a string representation of this <code>JDialog</code>.
  611. */
  612. protected String paramString() {
  613. String defaultCloseOperationString;
  614. if (defaultCloseOperation == HIDE_ON_CLOSE) {
  615. defaultCloseOperationString = "HIDE_ON_CLOSE";
  616. } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
  617. defaultCloseOperationString = "DISPOSE_ON_CLOSE";
  618. } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
  619. defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
  620. } else defaultCloseOperationString = "";
  621. String rootPaneString = (rootPane != null ?
  622. rootPane.toString() : "");
  623. String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
  624. "true" : "false");
  625. return super.paramString() +
  626. ",defaultCloseOperation=" + defaultCloseOperationString +
  627. ",rootPane=" + rootPaneString +
  628. ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
  629. }
  630. /////////////////
  631. // Accessibility support
  632. ////////////////
  633. protected AccessibleContext accessibleContext = null;
  634. /**
  635. * Gets the AccessibleContext associated with this JDialog.
  636. * For JDialogs, the AccessibleContext takes the form of an
  637. * AccessibleJDialog.
  638. * A new AccessibleJDialog instance is created if necessary.
  639. *
  640. * @return an AccessibleJDialog that serves as the
  641. * AccessibleContext of this JDialog
  642. */
  643. public AccessibleContext getAccessibleContext() {
  644. if (accessibleContext == null) {
  645. accessibleContext = new AccessibleJDialog();
  646. }
  647. return accessibleContext;
  648. }
  649. /**
  650. * This class implements accessibility support for the
  651. * <code>JDialog</code> class. It provides an implementation of the
  652. * Java Accessibility API appropriate to dialog user-interface
  653. * elements.
  654. */
  655. protected class AccessibleJDialog extends AccessibleAWTDialog {
  656. // AccessibleContext methods
  657. //
  658. /**
  659. * Get the accessible name of this object.
  660. *
  661. * @return the localized name of the object -- can be null if this
  662. * object does not have a name
  663. */
  664. public String getAccessibleName() {
  665. if (accessibleName != null) {
  666. return accessibleName;
  667. } else {
  668. if (getTitle() == null) {
  669. return super.getAccessibleName();
  670. } else {
  671. return getTitle();
  672. }
  673. }
  674. }
  675. /**
  676. * Get the state of this object.
  677. *
  678. * @return an instance of AccessibleStateSet containing the current
  679. * state set of the object
  680. * @see AccessibleState
  681. */
  682. public AccessibleStateSet getAccessibleStateSet() {
  683. AccessibleStateSet states = super.getAccessibleStateSet();
  684. if (isResizable()) {
  685. states.add(AccessibleState.RESIZABLE);
  686. }
  687. if (getFocusOwner() != null) {
  688. states.add(AccessibleState.ACTIVE);
  689. }
  690. if (isModal()) {
  691. states.add(AccessibleState.MODAL);
  692. }
  693. return states;
  694. }
  695. } // inner class AccessibleJDialog
  696. }