BorderFactory.createBevelBorder and createSoftBevelBorder throws NPE for null highlight and shadow

XMLWordPrintable

    • Type: CSR
    • Resolution: Withdrawn
    • Priority: P4
    • 26
    • Component/s: client-libs
    • None
    • behavioral
    • minimal
    • Gracefully avoid NullPointerException and clarify existing behaviour
    • Java API
    • SE

      Summary

      BorderFactory.createBevelBorder, BorderFactory.createSoftBevelBorder and BevelBorder constructor should clarify it will not draw any bevel border if unknown bevelborder type is specified. Also, it needs to be clarified that if highlight and/or shadow color is null, the highlight and/or shadow color will be obtained from the component's background color.

      Problem

      BorderFactory.createBevelBorder, BorderFactory.createSoftBevelBorder and BevelBorder does not specify that no bevel border will be drawn if unknown bevelborder type is specified.

      Solution

      BorderFactory.createBevelBorder, BorderFactory.createSoftBevelBorder and BevelBorder spec is clarified that it will not draw any bevel border if unknown bevelborder type is specified. Also, it is clarified that if highlight and/or shadow color is null, the highlight and/or shadow color will be obtained from the component's background color.

      Specification

      javax.swing.BorderFactory

             * Creates a beveled border of the specified type, using
            * the specified highlighting and shadowing. The outer
            * edge of the highlighted area uses a brighter shade of
            * the highlight color. The inner edge of the shadow area
            * uses a brighter shade of the shadow color.
      +     * If highlight color is {@code null}, the highlight color
      +     * is derived from the specified component's background color.
      +     * If shadow color is {@code null}, the shadow color
      +     * is derived from the specified component's background color.
      +     * If {@code bevelType} is not of known type that is neither
      +     * {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}
      +     * no bevel border will be painted.
      
          
              public static Border createBevelBorder(int type, Color highlight, Color shadow)
          
                * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
            * The outer edge of the highlight area uses
            * a brighter shade of the {@code highlight} color.
            * The inner edge of the shadow area uses
            * a brighter shade of the {@code shadow} color.
      +     * If highlight color is {@code null}, the highlight color
      +     * is derived from the specified component's background color.
      +     * If shadow color is {@code null}, the shadow color
      +     * is derived from the specified component's background color.
      public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) {
      

      javax.swing.border.BevelBorder

              /**
                * Creates a bevel border with the specified type and whose
                * colors will be derived from the background color of the
                * component passed into the paintBorder method.
          +     * If {@code bevelType} is not of known type that is neither
          +     * {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED},
          +     * no bevel border will be painted.
          +     *
                * @param bevelType the type of bevel for the border
                */
               public BevelBorder(int bevelType) {
          
               * shadow colors.
            * The bevel outer highlight color and bevel inner highlight color
            * will be derived from specified highlight color and
            * bevel outer shadow color and bevel inner shadow color
            * will be derived from specified shadow color.
      +     * If highlight color is {@code null}, the highlight color
      +     * is derived from the specified component's background color.
      +     * If shadow color is {@code null}, the shadow color
      +     * is derived from the specified component's background color.
      +     * If {@code bevelType} is not of known type that is neither
      +     * {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED},
      +     * no bevel border will be painted.
      +     *
            * @param bevelType the type of bevel for the border
            * @param highlight the color to use for the bevel highlight
            * @param shadow the color to use for the bevel shadow
            */
           public BevelBorder(int bevelType, Color highlight, Color shadow) {
      
           /**
            * Creates a bevel border with the specified type, highlight and
            * shadow colors.
      +     * If any of the highlight color is {@code null}, the highlight color
      +     * is derived from the specified component's background color.
      +     * If any of the shadow color is {@code null}, the shadow color
      +     * is derived from the specified component's background color.
      +     * If {@code bevelType} is not of known type that is neither
      +     * {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED},
      +     * no bevel border will be painted.
            *
      public BevelBorder(int bevelType, Color highlightOuterColor,
                              Color highlightInnerColor, Color shadowOuterColor,
                              Color shadowInnerColor) {
          
      
      
         /**
            * Creates a bevel border with the specified type, highlight and
            * shadow colors.
      +     * If any of the highlight color is {@code null}, the highlight color
      +     * is derived from the specified component's background color.
      +     * If any of the shadow color is {@code null}, the shadow color
      +     * is derived from the specified component's background color.
      +     * If {@code bevelType} is not of known type that is neither
      +     * {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED},
      +     * no bevel border will be painted.
      
          
              public BevelBorder(int bevelType, Color highlightOuterColor,  Color highlightInnerColor, Color shadowOuterColor,
                                      Color shadowInnerColor) {
      

            Assignee:
            Prasanta Sadhukhan
            Reporter:
            Prasanta Sadhukhan
            Harshitha Onkar, Tejesh R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: