src/share/classes/javax/swing/plaf/LayerUI.java

Print this page




 593      * this {@code LayerUI} instance is set to.
 594      *
 595      * @param evt the PropertyChangeEvent generated by this {@code LayerUI}
 596      * @param l the {@code JLayer} this LayerUI is set to
 597      */
 598     public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
 599     }
 600 
 601     /**
 602      * If the {@code JLayer}'s view component is not {@code null},
 603      * this calls the view's {@code getBaseline()} method.
 604      * Otherwise, the default implementation is called.
 605      *
 606      * @param c {@code JLayer} to return baseline resize behavior for
 607      * @param width the width to get the baseline for
 608      * @param height the height to get the baseline for
 609      * @return baseline or a value &lt; 0 indicating there is no reasonable
 610      *                  baseline
 611      */
 612     public int getBaseline(JComponent c, int width, int height) {
 613         JLayer l = (JLayer) c;

 614         if (l.getView() != null) {
 615             return l.getView().getBaseline(width, height);
 616         }
 617         return super.getBaseline(c, width, height);
 618      }
 619 
 620     /**
 621      * If the {@code JLayer}'s view component is not {@code null},
 622      * this returns the result of the view's {@code getBaselineResizeBehavior()} method.
 623      * Otherwise, the default implementation is called.
 624      *
 625      * @param c {@code JLayer} to return baseline resize behavior for
 626      * @return an enum indicating how the baseline changes as the component
 627      *         size changes
 628      */
 629     public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
 630         JLayer l = (JLayer) c;

 631         if (l.getView() != null) {
 632             return l.getView().getBaselineResizeBehavior();
 633         }
 634         return super.getBaselineResizeBehavior(c);
 635     }
 636 
 637     /**
 638      * Causes the passed instance of {@code JLayer} to lay out its components.
 639      *
 640      * @param l the {@code JLayer} component where this UI delegate is being installed
 641      */
 642     public void doLayout(JLayer<? extends V> l) {
 643         Component view = l.getView();
 644         if (view != null) {
 645             view.setBounds(0, 0, l.getWidth(), l.getHeight());
 646         }
 647         Component glassPane = l.getGlassPane();
 648         if (glassPane != null) {
 649             glassPane.setBounds(0, 0, l.getWidth(), l.getHeight());
 650         }
 651     }
 652 
 653     /**
 654      * If the {@code JLayer}'s view component is not {@code null},
 655      * this returns the result of  the view's {@code getPreferredSize()} method.
 656      * Otherwise, the default implementation is used.
 657      *
 658      * @param c {@code JLayer} to return preferred size for
 659      * @return preferred size for the passed {@code JLayer}
 660      */
 661     public Dimension getPreferredSize(JComponent c) {
 662         JLayer l = (JLayer) c;

 663         Component view = l.getView();
 664         if (view != null) {
 665             return view.getPreferredSize();
 666         }
 667         return super.getPreferredSize(c);
 668     }
 669 
 670     /**
 671      * If the {@code JLayer}'s view component is not {@code null},
 672      * this returns the result of  the view's {@code getMinimalSize()} method.
 673      * Otherwise, the default implementation is used.
 674      *
 675      * @param c {@code JLayer} to return preferred size for
 676      * @return minimal size for the passed {@code JLayer}
 677      */
 678     public Dimension getMinimumSize(JComponent c) {
 679         JLayer l = (JLayer) c;

 680         Component view = l.getView();
 681         if (view != null) {
 682             return view.getMinimumSize();
 683         }
 684         return super.getMinimumSize(c);
 685     }
 686 
 687     /**
 688      * If the {@code JLayer}'s view component is not {@code null},
 689      * this returns the result of  the view's {@code getMaximumSize()} method.
 690      * Otherwise, the default implementation is used.
 691      *
 692      * @param c {@code JLayer} to return preferred size for
 693      * @return maximum size for the passed {@code JLayer}
 694      */
 695     public Dimension getMaximumSize(JComponent c) {
 696         JLayer l = (JLayer) c;

 697         Component view = l.getView();
 698         if (view != null) {
 699             return view.getMaximumSize();
 700         }
 701         return super.getMaximumSize(c);
 702     }
 703 
 704     /**
 705      * Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately.
 706      * <p>
 707      * This method is to be overridden when the dirty region needs to be changed.
 708      * The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}.
 709      *
 710      * @param x  the x value of the region to be painted
 711      * @param y  the y value of the region to be painted
 712      * @param width  the width of the region to be painted
 713      * @param height  the height of the region to be painted
 714      *
 715      * @see JComponent#paintImmediately(int, int, int, int)
 716      */


 593      * this {@code LayerUI} instance is set to.
 594      *
 595      * @param evt the PropertyChangeEvent generated by this {@code LayerUI}
 596      * @param l the {@code JLayer} this LayerUI is set to
 597      */
 598     public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
 599     }
 600 
 601     /**
 602      * If the {@code JLayer}'s view component is not {@code null},
 603      * this calls the view's {@code getBaseline()} method.
 604      * Otherwise, the default implementation is called.
 605      *
 606      * @param c {@code JLayer} to return baseline resize behavior for
 607      * @param width the width to get the baseline for
 608      * @param height the height to get the baseline for
 609      * @return baseline or a value &lt; 0 indicating there is no reasonable
 610      *                  baseline
 611      */
 612     public int getBaseline(JComponent c, int width, int height) {
 613         @SuppressWarnings("unchecked")
 614         JLayer<?> l = (JLayer) c;
 615         if (l.getView() != null) {
 616             return l.getView().getBaseline(width, height);
 617         }
 618         return super.getBaseline(c, width, height);
 619      }
 620 
 621     /**
 622      * If the {@code JLayer}'s view component is not {@code null},
 623      * this returns the result of the view's {@code getBaselineResizeBehavior()} method.
 624      * Otherwise, the default implementation is called.
 625      *
 626      * @param c {@code JLayer} to return baseline resize behavior for
 627      * @return an enum indicating how the baseline changes as the component
 628      *         size changes
 629      */
 630     public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
 631         @SuppressWarnings("unchecked")
 632         JLayer<?> l = (JLayer) c;
 633         if (l.getView() != null) {
 634             return l.getView().getBaselineResizeBehavior();
 635         }
 636         return super.getBaselineResizeBehavior(c);
 637     }
 638 
 639     /**
 640      * Causes the passed instance of {@code JLayer} to lay out its components.
 641      *
 642      * @param l the {@code JLayer} component where this UI delegate is being installed
 643      */
 644     public void doLayout(JLayer<? extends V> l) {
 645         Component view = l.getView();
 646         if (view != null) {
 647             view.setBounds(0, 0, l.getWidth(), l.getHeight());
 648         }
 649         Component glassPane = l.getGlassPane();
 650         if (glassPane != null) {
 651             glassPane.setBounds(0, 0, l.getWidth(), l.getHeight());
 652         }
 653     }
 654 
 655     /**
 656      * If the {@code JLayer}'s view component is not {@code null},
 657      * this returns the result of  the view's {@code getPreferredSize()} method.
 658      * Otherwise, the default implementation is used.
 659      *
 660      * @param c {@code JLayer} to return preferred size for
 661      * @return preferred size for the passed {@code JLayer}
 662      */
 663     public Dimension getPreferredSize(JComponent c) {
 664         @SuppressWarnings("unchecked")
 665         JLayer<?> l = (JLayer) c;
 666         Component view = l.getView();
 667         if (view != null) {
 668             return view.getPreferredSize();
 669         }
 670         return super.getPreferredSize(c);
 671     }
 672 
 673     /**
 674      * If the {@code JLayer}'s view component is not {@code null},
 675      * this returns the result of  the view's {@code getMinimalSize()} method.
 676      * Otherwise, the default implementation is used.
 677      *
 678      * @param c {@code JLayer} to return preferred size for
 679      * @return minimal size for the passed {@code JLayer}
 680      */
 681     public Dimension getMinimumSize(JComponent c) {
 682         @SuppressWarnings("unchecked")
 683         JLayer<?> l = (JLayer) c;
 684         Component view = l.getView();
 685         if (view != null) {
 686             return view.getMinimumSize();
 687         }
 688         return super.getMinimumSize(c);
 689     }
 690 
 691     /**
 692      * If the {@code JLayer}'s view component is not {@code null},
 693      * this returns the result of  the view's {@code getMaximumSize()} method.
 694      * Otherwise, the default implementation is used.
 695      *
 696      * @param c {@code JLayer} to return preferred size for
 697      * @return maximum size for the passed {@code JLayer}
 698      */
 699     public Dimension getMaximumSize(JComponent c) {
 700         @SuppressWarnings("unchecked")
 701         JLayer<?> l = (JLayer) c;
 702         Component view = l.getView();
 703         if (view != null) {
 704             return view.getMaximumSize();
 705         }
 706         return super.getMaximumSize(c);
 707     }
 708 
 709     /**
 710      * Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately.
 711      * <p>
 712      * This method is to be overridden when the dirty region needs to be changed.
 713      * The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}.
 714      *
 715      * @param x  the x value of the region to be painted
 716      * @param y  the y value of the region to be painted
 717      * @param width  the width of the region to be painted
 718      * @param height  the height of the region to be painted
 719      *
 720      * @see JComponent#paintImmediately(int, int, int, int)
 721      */