RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v17]

Abhishek Kumar duke at openjdk.org
Fri Aug 12 14:51:27 UTC 2022


On Thu, 11 Aug 2022 19:11:28 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Smaller file sizes display one decimal precision
>
> src/java.desktop/share/classes/sun/swing/FilePane.java line 1199:
> 
>> 1197:             } else if (value instanceof Long len) {
>> 1198:                 if (listViewWindowsStyle) {
>> 1199:                     updateMessageFormatPattern(kiloByteString, 1);
> 
> Now you always call `updateMessageFormatPattern` with 1 as the second parameter. Maybe you could initialise both MessageFormat and NumberFormat once and then just use the objects. Or switch back to `MessageFormat.format` method.

MessageFormat.format method was truncating "0" from values like "0.0", "1.0" and so on.
Due to that I initialize MessageFormat and NumberFormat instance.

The first parameter in updateMessageFormatPattern  method changes based on file size, so calling it multiple times to update the pattern.
The second parameter can be removed.

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

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



More information about the client-libs-dev mailing list