RFR: 8370467: BorderFactory.createBevelBorder and createSoftBevelBorder throws NPE for null highlight and shadow
Prasanta Sadhukhan
psadhukhan at openjdk.org
Fri Oct 24 01:38:07 UTC 2025
On Fri, 24 Oct 2025 00:19:52 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:
>> If we pass null as highlight and shadow color to `BorderFactory.createBevelBorder` and `createSoftBevelBorder`
>> it throws NPE which is not mentioned in the spec as the expected outcome.
>> Fixed the NPE and the spec
>
> src/java.desktop/share/classes/javax/swing/BorderFactory.java line 148:
>
>> 146: * uses a brighter shade of the shadow color.
>> 147: * If highlight and shadow color are null, then it will
>> 148: * fallback to create beveled border of the specified type.
>
> If the highlight and shadow color are null, are the colors obtained by UIManager defaults?
No, it will use border of the specified type and there they, as the spec says, will use
using brighter shades of the component's current background color
for highlighting, and darker shading for shadows
> src/java.desktop/share/classes/javax/swing/BorderFactory.java line 161:
>
>> 159: return new BevelBorder(type, highlight, shadow);
>> 160: }
>> 161: return new BevelBorder(type);
>
> Do we need to do something similar for other border types such as EtchedBorder ?
No, there it does not use Color.brighter call on null object
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2458301449
PR Review Comment: https://git.openjdk.org/jdk/pull/27949#discussion_r2458305226
More information about the client-libs-dev
mailing list