< prev index next >

src/java.desktop/share/classes/javax/swing/ProgressMonitor.java

Print this page




 448         }
 449     }
 450 
 451 
 452     /**
 453      * Specifies the additional note that is displayed along with the
 454      * progress message.
 455      *
 456      * @return a String specifying the note to display
 457      * @see #setNote
 458      */
 459     public String getNote() {
 460         return note;
 461     }
 462 
 463     /////////////////
 464     // Accessibility support
 465     ////////////////
 466 
 467     /**
 468      * The <code>AccessibleContext</code> for the <code>ProgressMonitor</code>
 469      * @since 1.5
 470      */
 471     protected AccessibleContext accessibleContext = null;
 472 
 473     private AccessibleContext accessibleJOptionPane = null;
 474 
 475     /**
 476      * Gets the <code>AccessibleContext</code> for the
 477      * <code>ProgressMonitor</code>
 478      *
 479      * @return the <code>AccessibleContext</code> for the
 480      * <code>ProgressMonitor</code>
 481      * @since 1.5
 482      */
 483     public AccessibleContext getAccessibleContext() {
 484         if (accessibleContext == null) {
 485             accessibleContext = new AccessibleProgressMonitor();
 486         }
 487         if (pane != null && accessibleJOptionPane == null) {
 488             // Notify the AccessibleProgressMonitor that the
 489             // ProgressOptionPane was created. It is necessary
 490             // to poll for ProgressOptionPane creation because
 491             // the ProgressMonitor does not have a Component
 492             // to add a listener to until the ProgressOptionPane
 493             // is created.
 494             if (accessibleContext instanceof AccessibleProgressMonitor) {
 495                 ((AccessibleProgressMonitor)accessibleContext).optionPaneCreated();
 496             }
 497         }
 498         return accessibleContext;
 499     }
 500 
 501     /**
 502      * <code>AccessibleProgressMonitor</code> implements accessibility
 503      * support for the <code>ProgressMonitor</code> class.
 504      * @since 1.5
 505      */
 506     protected class AccessibleProgressMonitor extends AccessibleContext
 507         implements AccessibleText, ChangeListener, PropertyChangeListener {
 508 
 509         /*
 510          * The accessibility hierarchy for ProgressMonitor is a flattened
 511          * version of the ProgressOptionPane component hierarchy.
 512          *
 513          * The ProgressOptionPane component hierarchy is:
 514          *   JDialog
 515          *     ProgressOptionPane
 516          *       JPanel
 517          *         JPanel
 518          *           JLabel
 519          *           JLabel
 520          *           JProgressBar
 521          *
 522          * The AccessibleProgessMonitor accessibility hierarchy is:
 523          *   AccessibleJDialog


 553          * to the AccessibleJOptionPane.
 554          */
 555         private void optionPaneCreated() {
 556             accessibleJOptionPane =
 557                 ((ProgressOptionPane)pane).getAccessibleJOptionPane();
 558 
 559             // add a listener for progress bar ChangeEvents
 560             if (myBar != null) {
 561                 myBar.addChangeListener(this);
 562             }
 563 
 564             // add a listener for note label PropertyChangeEvents
 565             if (noteLabel != null) {
 566                 noteLabel.addPropertyChangeListener(this);
 567             }
 568         }
 569 
 570         /**
 571          * Invoked when the target of the listener has changed its state.
 572          *
 573          * @param e  a <code>ChangeEvent</code> object. Must not be null.
 574          * @throws NullPointerException if the parameter is null.
 575          */
 576         public void stateChanged(ChangeEvent e) {
 577             if (e == null) {
 578                 return;
 579             }
 580             if (myBar != null) {
 581                 // the progress bar value changed
 582                 Object newModelValue = myBar.getValue();
 583                 firePropertyChange(ACCESSIBLE_VALUE_PROPERTY,
 584                                    oldModelValue,
 585                                    newModelValue);
 586                 oldModelValue = newModelValue;
 587             }
 588         }
 589 
 590         /**
 591          * This method gets called when a bound property is changed.
 592          *
 593          * @param e A <code>PropertyChangeEvent</code> object describing
 594          * the event source and the property that has changed. Must not be null.
 595          * @throws NullPointerException if the parameter is null.
 596          */
 597         public void propertyChange(PropertyChangeEvent e) {
 598             if (e.getSource() == noteLabel && e.getPropertyName() == "text") {
 599                 // the note label text changed
 600                 firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, 0);
 601             }
 602         }
 603 
 604         /* ===== Begin AccessileContext ===== */
 605 
 606         /**
 607          * Gets the accessibleName property of this object.  The accessibleName
 608          * property of an object is a localized String that designates the purpose
 609          * of the object.  For example, the accessibleName property of a label
 610          * or button might be the text of the label or button itself.  In the
 611          * case of an object that doesn't display its name, the accessibleName
 612          * should still be set.  For example, in the case of a text field used
 613          * to enter the name of a city, the accessibleName for the en_US locale




 448         }
 449     }
 450 
 451 
 452     /**
 453      * Specifies the additional note that is displayed along with the
 454      * progress message.
 455      *
 456      * @return a String specifying the note to display
 457      * @see #setNote
 458      */
 459     public String getNote() {
 460         return note;
 461     }
 462 
 463     /////////////////
 464     // Accessibility support
 465     ////////////////
 466 
 467     /**
 468      * The {@code AccessibleContext} for the {@code ProgressMonitor}
 469      * @since 1.5
 470      */
 471     protected AccessibleContext accessibleContext = null;
 472 
 473     private AccessibleContext accessibleJOptionPane = null;
 474 
 475     /**
 476      * Gets the {@code AccessibleContext} for the
 477      * {@code ProgressMonitor}
 478      *
 479      * @return the {@code AccessibleContext} for the
 480      * {@code ProgressMonitor}
 481      * @since 1.5
 482      */
 483     public AccessibleContext getAccessibleContext() {
 484         if (accessibleContext == null) {
 485             accessibleContext = new AccessibleProgressMonitor();
 486         }
 487         if (pane != null && accessibleJOptionPane == null) {
 488             // Notify the AccessibleProgressMonitor that the
 489             // ProgressOptionPane was created. It is necessary
 490             // to poll for ProgressOptionPane creation because
 491             // the ProgressMonitor does not have a Component
 492             // to add a listener to until the ProgressOptionPane
 493             // is created.
 494             if (accessibleContext instanceof AccessibleProgressMonitor) {
 495                 ((AccessibleProgressMonitor)accessibleContext).optionPaneCreated();
 496             }
 497         }
 498         return accessibleContext;
 499     }
 500 
 501     /**
 502      * {@code AccessibleProgressMonitor} implements accessibility
 503      * support for the {@code ProgressMonitor} class.
 504      * @since 1.5
 505      */
 506     protected class AccessibleProgressMonitor extends AccessibleContext
 507         implements AccessibleText, ChangeListener, PropertyChangeListener {
 508 
 509         /*
 510          * The accessibility hierarchy for ProgressMonitor is a flattened
 511          * version of the ProgressOptionPane component hierarchy.
 512          *
 513          * The ProgressOptionPane component hierarchy is:
 514          *   JDialog
 515          *     ProgressOptionPane
 516          *       JPanel
 517          *         JPanel
 518          *           JLabel
 519          *           JLabel
 520          *           JProgressBar
 521          *
 522          * The AccessibleProgessMonitor accessibility hierarchy is:
 523          *   AccessibleJDialog


 553          * to the AccessibleJOptionPane.
 554          */
 555         private void optionPaneCreated() {
 556             accessibleJOptionPane =
 557                 ((ProgressOptionPane)pane).getAccessibleJOptionPane();
 558 
 559             // add a listener for progress bar ChangeEvents
 560             if (myBar != null) {
 561                 myBar.addChangeListener(this);
 562             }
 563 
 564             // add a listener for note label PropertyChangeEvents
 565             if (noteLabel != null) {
 566                 noteLabel.addPropertyChangeListener(this);
 567             }
 568         }
 569 
 570         /**
 571          * Invoked when the target of the listener has changed its state.
 572          *
 573          * @param e  a {@code ChangeEvent} object. Must not be null.
 574          * @throws NullPointerException if the parameter is null.
 575          */
 576         public void stateChanged(ChangeEvent e) {
 577             if (e == null) {
 578                 return;
 579             }
 580             if (myBar != null) {
 581                 // the progress bar value changed
 582                 Object newModelValue = myBar.getValue();
 583                 firePropertyChange(ACCESSIBLE_VALUE_PROPERTY,
 584                                    oldModelValue,
 585                                    newModelValue);
 586                 oldModelValue = newModelValue;
 587             }
 588         }
 589 
 590         /**
 591          * This method gets called when a bound property is changed.
 592          *
 593          * @param e A {@code PropertyChangeEvent} object describing
 594          * the event source and the property that has changed. Must not be null.
 595          * @throws NullPointerException if the parameter is null.
 596          */
 597         public void propertyChange(PropertyChangeEvent e) {
 598             if (e.getSource() == noteLabel && e.getPropertyName() == "text") {
 599                 // the note label text changed
 600                 firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, 0);
 601             }
 602         }
 603 
 604         /* ===== Begin AccessileContext ===== */
 605 
 606         /**
 607          * Gets the accessibleName property of this object.  The accessibleName
 608          * property of an object is a localized String that designates the purpose
 609          * of the object.  For example, the accessibleName property of a label
 610          * or button might be the text of the label or button itself.  In the
 611          * case of an object that doesn't display its name, the accessibleName
 612          * should still be set.  For example, in the case of a text field used
 613          * to enter the name of a city, the accessibleName for the en_US locale


< prev index next >