On Wed, 23 Nov 2022 22:40:34 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Updated Metal Border code for JInternalFrame. 
>> 
>> - Added instanceof check before casting Graphics to G2D.
>> - Replaced roundHalfDown with Region.clipRound()
>
> src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java line 
> 253:
> 
>> 251:         public void paintBorder(Component c, Graphics g, int x, int y,
>> 252:                                 int w, int h) {
>> 253:             if (g instanceof Graphics2D) {
> 
> I think it's not the right approach. You should separate the parts of code 
> into those which require `Graphics2D` (resetting transform, stroke width) and 
> those which don't, so that the border is still painted even when `g` is not 
> an instance of `Graphics2D`.
> 
> Take a look at how @alisenchung handled it for `EtchedBorder`:
> https://github.com/openjdk/jdk/blob/b42c1ad1086a5c3f579e27380d23f67f8cebb437/src/java.desktop/share/classes/javax/swing/border/EtchedBorder.java#L159-L171
> 
> The border is still rendered even if the passed in `Graphics` is not 
> `Graphics2D`.

@aivanov-jdk Makes sense. Thanks for reviewing. Will check and make the 
necessary code changes.

-------------

PR: https://git.openjdk.org/jdk/pull/11305

Reply via email to