On Thu, 19 Feb 2026 03:51:37 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> `JProgressBar` is not printed if JDK 1.1 printing API is used.
>> JDK1.1 printing API `PrintJob ` doesn't support `Graphics2D`. 
>> JProgressBar seems to require Graphics2D as `BasicProgressBarUI` needs 
>> Graphics2D to do
>> `g2.setStroke(new BasicStroke(...))`
>> 
>> Fix is made to not rely on setStroke for non-Graphics2D printing case and 
>> also not to clip progress string
>> Also, a null pagerange check is added for PrintJobDelegate as we reset 
>> PageRanges if range is not set so to prevent NPE when "All" is used in print 
>> dialog instead of "Pages from"
>
> Prasanta Sadhukhan has updated the pull request incrementally with two 
> additional commits since the last revision:
> 
>  - Remove unused imports
>  - Remove unused imports

The bug report says
 "I note that BasicTabbedPaneUI.java also bails if it's not got a Graphics2D."

Is that still an issue ? If yes, can it be fixed here ?
 If yes to the first and no to the second a new bug should be submitted.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java 
line 731:

> 729:         int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
> 730: 
> 731:         Graphics g2 = null;

Naming it g2 implies it is a Graphics2D .. I guess you were trying to minimize 
lines that need to change but it is better to name the Graphics just 'g'. and 
may be use g2d for the Graphics2D ?
So we'll see every line that needs to change.

Also if I'm reading this right you just draw a 1 user space pixel line if its 
not a G2D ?
The use of barRectHeight for the stroke width tells  me that you need something 
more like fillRect as an alternative don't you ?

Also the cellspacing case (lines 749-751)  looks like it needs individual 
fillRect calls.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java 
line 876:

> 874:                 g2.setColor(getSelectionForeground());
> 875:                 g2.clipRect(fillStart, y, amountFull, height);
> 876:                 SwingUtilities2.drawString(progressBar, g2, 
> progressString,

surely you can't just skip the drawString ? 
Also SFAICS that call accepts a Graphics and internally handles printing. Why 
is it excluded here ? 
The explanation in the PR description "not to clip progress string" is way too 
vague.

src/java.desktop/share/classes/sun/print/PrintJobDelegate.java line 532:

> 530:             int[][] members = range.getMembers();
> 531:             jobAttributes.setPageRanges(members);
> 532:         }

Hmm. This seems a very odd thing to include in this PR. It it is unrelated.
 I don't think it should be here and we've managed for 20 years without this 
null check, so why now ?

Is it a regression caused by https://github.com/openjdk/jdk/pull/29312/ ?

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

PR Review: https://git.openjdk.org/jdk/pull/29752#pullrequestreview-3827686047
PR Review Comment: https://git.openjdk.org/jdk/pull/29752#discussion_r2829439935
PR Review Comment: https://git.openjdk.org/jdk/pull/29752#discussion_r2829475969
PR Review Comment: https://git.openjdk.org/jdk/pull/29752#discussion_r2829490964

Reply via email to