src/share/classes/java/awt/Window.java

Print this page




 751      * @see Component#isDisplayable
 752      * @see #setMinimumSize
 753      */
 754     public void pack() {
 755         Container parent = this.parent;
 756         if (parent != null && parent.getPeer() == null) {
 757             parent.addNotify();
 758         }
 759         if (peer == null) {
 760             addNotify();
 761         }
 762         Dimension newSize = getPreferredSize();
 763         if (peer != null) {
 764             setClientSize(newSize.width, newSize.height);
 765         }
 766 
 767         if(beforeFirstShow) {
 768             isPacked = true;
 769         }
 770 
 771         validate();
 772     }
 773 
 774     /**
 775      * Sets the minimum size of this window to a constant
 776      * value.  Subsequent calls to {@code getMinimumSize}
 777      * will always return this value. If current window's
 778      * size is less than {@code minimumSize} the size of the
 779      * window is automatically enlarged to honor the minimum size.
 780      * <p>
 781      * If the {@code setSize} or {@code setBounds} methods
 782      * are called afterwards with a width or height less than
 783      * that was specified by the {@code setMinimumSize} method
 784      * the window is automatically enlarged to meet
 785      * the {@code minimumSize} value. The {@code minimumSize}
 786      * value also affects the behaviour of the {@code pack} method.
 787      * <p>
 788      * The default behavior is restored by setting the minimum size
 789      * parameter to the {@code null} value.
 790      * <p>
 791      * Resizing operation may be restricted if the user tries


 927     public void setVisible(boolean b) {
 928         super.setVisible(b);
 929     }
 930 
 931     /**
 932      * Makes the Window visible. If the Window and/or its owner
 933      * are not yet displayable, both are made displayable.  The
 934      * Window will be validated prior to being made visible.
 935      * If the Window is already visible, this will bring the Window
 936      * to the front.
 937      * @see       Component#isDisplayable
 938      * @see       #toFront
 939      * @deprecated As of JDK version 1.5, replaced by
 940      * {@link #setVisible(boolean)}.
 941      */
 942     @Deprecated
 943     public void show() {
 944         if (peer == null) {
 945             addNotify();
 946         }
 947         validate();
 948 
 949         isInShow = true;
 950         if (visible) {
 951             toFront();
 952         } else {
 953             beforeFirstShow = false;
 954             closeSplashScreen();
 955             Dialog.checkShouldBeBlocked(this);
 956             super.show();
 957             locationByPlatform = false;
 958             for (int i = 0; i < ownedWindowList.size(); i++) {
 959                 Window child = ownedWindowList.elementAt(i).get();
 960                 if ((child != null) && child.showWithParent) {
 961                     child.show();
 962                     child.showWithParent = false;
 963                 }       // endif
 964             }   // endfor
 965             if (!isModalBlocked()) {
 966                 updateChildrenBlocking();
 967             } else {


2584      *        </li>
2585      *    <li>this Window's always-on-top state("alwaysOnTop")</li>
2586      * </ul>
2587      * Note that if this Window is inheriting a bound property, then no
2588      * event will be fired in response to a change in the inherited property.
2589      * <p>
2590      * If listener is null, no exception is thrown and no action is performed.
2591      *
2592      * @param propertyName one of the property names listed above
2593      * @param listener the PropertyChangeListener to be added
2594      *
2595      * @see #addPropertyChangeListener(java.beans.PropertyChangeListener)
2596      * @see Component#removePropertyChangeListener
2597      */
2598     public void addPropertyChangeListener(String propertyName,
2599                                           PropertyChangeListener listener) {
2600         super.addPropertyChangeListener(propertyName, listener);
2601     }
2602 
2603     /**















2604      * Dispatches an event to this window or one of its sub components.
2605      * @param e the event
2606      */
2607     void dispatchEventImpl(AWTEvent e) {
2608         if (e.getID() == ComponentEvent.COMPONENT_RESIZED) {
2609             invalidate();
2610             validate();
2611         }
2612         super.dispatchEventImpl(e);
2613     }
2614 
2615     /**
2616      * @deprecated As of JDK version 1.1
2617      * replaced by <code>dispatchEvent(AWTEvent)</code>.
2618      */
2619     @Deprecated
2620     public boolean postEvent(Event e) {
2621         if (handleEvent(e)) {
2622             e.consume();
2623             return true;




 751      * @see Component#isDisplayable
 752      * @see #setMinimumSize
 753      */
 754     public void pack() {
 755         Container parent = this.parent;
 756         if (parent != null && parent.getPeer() == null) {
 757             parent.addNotify();
 758         }
 759         if (peer == null) {
 760             addNotify();
 761         }
 762         Dimension newSize = getPreferredSize();
 763         if (peer != null) {
 764             setClientSize(newSize.width, newSize.height);
 765         }
 766 
 767         if(beforeFirstShow) {
 768             isPacked = true;
 769         }
 770 
 771         validateUnconditionally();
 772     }
 773 
 774     /**
 775      * Sets the minimum size of this window to a constant
 776      * value.  Subsequent calls to {@code getMinimumSize}
 777      * will always return this value. If current window's
 778      * size is less than {@code minimumSize} the size of the
 779      * window is automatically enlarged to honor the minimum size.
 780      * <p>
 781      * If the {@code setSize} or {@code setBounds} methods
 782      * are called afterwards with a width or height less than
 783      * that was specified by the {@code setMinimumSize} method
 784      * the window is automatically enlarged to meet
 785      * the {@code minimumSize} value. The {@code minimumSize}
 786      * value also affects the behaviour of the {@code pack} method.
 787      * <p>
 788      * The default behavior is restored by setting the minimum size
 789      * parameter to the {@code null} value.
 790      * <p>
 791      * Resizing operation may be restricted if the user tries


 927     public void setVisible(boolean b) {
 928         super.setVisible(b);
 929     }
 930 
 931     /**
 932      * Makes the Window visible. If the Window and/or its owner
 933      * are not yet displayable, both are made displayable.  The
 934      * Window will be validated prior to being made visible.
 935      * If the Window is already visible, this will bring the Window
 936      * to the front.
 937      * @see       Component#isDisplayable
 938      * @see       #toFront
 939      * @deprecated As of JDK version 1.5, replaced by
 940      * {@link #setVisible(boolean)}.
 941      */
 942     @Deprecated
 943     public void show() {
 944         if (peer == null) {
 945             addNotify();
 946         }
 947         validateUnconditionally();
 948 
 949         isInShow = true;
 950         if (visible) {
 951             toFront();
 952         } else {
 953             beforeFirstShow = false;
 954             closeSplashScreen();
 955             Dialog.checkShouldBeBlocked(this);
 956             super.show();
 957             locationByPlatform = false;
 958             for (int i = 0; i < ownedWindowList.size(); i++) {
 959                 Window child = ownedWindowList.elementAt(i).get();
 960                 if ((child != null) && child.showWithParent) {
 961                     child.show();
 962                     child.showWithParent = false;
 963                 }       // endif
 964             }   // endfor
 965             if (!isModalBlocked()) {
 966                 updateChildrenBlocking();
 967             } else {


2584      *        </li>
2585      *    <li>this Window's always-on-top state("alwaysOnTop")</li>
2586      * </ul>
2587      * Note that if this Window is inheriting a bound property, then no
2588      * event will be fired in response to a change in the inherited property.
2589      * <p>
2590      * If listener is null, no exception is thrown and no action is performed.
2591      *
2592      * @param propertyName one of the property names listed above
2593      * @param listener the PropertyChangeListener to be added
2594      *
2595      * @see #addPropertyChangeListener(java.beans.PropertyChangeListener)
2596      * @see Component#removePropertyChangeListener
2597      */
2598     public void addPropertyChangeListener(String propertyName,
2599                                           PropertyChangeListener listener) {
2600         super.addPropertyChangeListener(propertyName, listener);
2601     }
2602 
2603     /**
2604      * Indicates if this container is a validate root.
2605      * <p>
2606      * {@code Window} objects are the validate roots, and therefore override
2607      * this method to return {@code true}.
2608      *
2609      * @return {@code true}
2610      * @since 1.7
2611      * @see java.awt.Container#isValidateRoot
2612      */
2613     @Override
2614     public boolean isValidateRoot() {
2615         return true;
2616     }
2617 
2618     /**
2619      * Dispatches an event to this window or one of its sub components.
2620      * @param e the event
2621      */
2622     void dispatchEventImpl(AWTEvent e) {
2623         if (e.getID() == ComponentEvent.COMPONENT_RESIZED) {
2624             invalidate();
2625             validate();
2626         }
2627         super.dispatchEventImpl(e);
2628     }
2629 
2630     /**
2631      * @deprecated As of JDK version 1.1
2632      * replaced by <code>dispatchEvent(AWTEvent)</code>.
2633      */
2634     @Deprecated
2635     public boolean postEvent(Event e) {
2636         if (handleEvent(e)) {
2637             e.consume();
2638             return true;