RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB
Alexey Ivanov
aivanov at openjdk.org
Wed Jun 29 19:28:41 UTC 2022
On Wed, 29 Jun 2022 13:06:21 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.
Changes requested by aivanov (Reviewer).
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 56:
> 54: JFileChooser fc = new JFileChooser();
> 55: try {
> 56: Path currentDir = Paths.get(System.getProperty("java.io.tmpdir"));
Why not create it in the `test.src` value? This property is defined by jtreg. If the property is not set, default to `.`, that is the current directory.
test/jdk/javax/swing/JFileChooser/ZeroFileSizeCheck.java line 66:
> 64: throw new RuntimeException(ex);
> 65: }
> 66: frame.getContentPane().add(fc);
Usually, you don't add [`JFileChooser`](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/JFileChooser.html) to a container but rather use it as a dialog box:
int returnVal = chooser.showOpenDialog(parent);
where `parent` is the parent of the created `JDialog`.
However, it's basically what's done in `showDialog` / `createDialog` methods.
https://github.com/openjdk/jdk/blob/ec4fb47b90c9737dfdc285ebe98367a221c90c79/src/java.desktop/share/classes/javax/swing/JFileChooser.java#L823-L825
-------------
PR: https://git.openjdk.org/jdk/pull/9327
More information about the client-libs-dev
mailing list