RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v3]
Alexey Ivanov
aivanov at openjdk.org
Thu Jul 7 20:07:27 UTC 2022
On Wed, 6 Jul 2022 11:59:31 GMT, Abhishek Kumar <duke at openjdk.org> wrote:
>> JFileChooser - empty file size issue fixed.
>> For empty file, now the size 0 bytes.
>> Manual Test Case "ZeroFileSizeCheck.java" created.
>
> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
>
> Byte entry added to basic.properties, MessageFormat used to format file length
Changes requested by aivanov (Reviewer).
src/java.desktop/share/classes/sun/swing/FilePane.java line 1198:
> 1196: if (listViewWindowsStyle) {
> 1197: len /= 1024L;
> 1198: text = MessageFormat.format(kiloByteString, len + 1);
Does it make sense to address this too?
If len is zero before division, leave it as is so that the size would display "0 KB"; if len is greater than 0, then divide and add 1. At least this is how Windows Explorer displays file sizes.
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 53:
> 51: JFileChooser fc = new JFileChooser();
> 52: try {
> 53: Path currentDir = Paths.get(System.getProperty("test.src"));
`currentDir` is confusing. Would `dir` be enough?
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 60:
> 58: }
> 59: fc.setCurrentDirectory(currentDir.toFile());
> 60: }catch (IOException ex) {
Suggestion:
} catch (IOException ex) {
A space is missing.
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 66:
> 64: }
> 65:
> 66: public static void main(String args[]) throws Exception {
Since the test is applicable to Metal Look-and-Feel, shall the test explicitly set MetalLAF?
Does the issue seen in other Look-and-Feels? Windows L&F isn't affected, Aqua isn't either. Any other?
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 72:
> 70: frame = new JFrame();
> 71: PassFailJFrame.addTestWindow(frame);
> 72: PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
You don't use the frame any more, do you?
-------------
PR: https://git.openjdk.org/jdk/pull/9327
More information about the client-libs-dev
mailing list