From 53a83d15a1b5686ed0f2aeb3d30cd46b73f80733 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 17 Jun 2025 14:09:11 +0000 Subject: [PATCH] 8357799: Improve instructions for JFileChooser/HTMLFileName.java Reviewed-by: honkar, tr, kizune --- .../swing/JFileChooser/HTMLFileName.java | 67 +++++++++++-------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/test/jdk/javax/swing/JFileChooser/HTMLFileName.java b/test/jdk/javax/swing/JFileChooser/HTMLFileName.java index 45d9cb4c449..a8bc9525cca 100644 --- a/test/jdk/javax/swing/JFileChooser/HTMLFileName.java +++ b/test/jdk/javax/swing/JFileChooser/HTMLFileName.java @@ -52,24 +52,35 @@ public class HTMLFileName { private static final String INSTRUCTIONS = """
    -
  1. FileChooser shows up a virtual directory and file with name -

    Swing Rocks!. -
  2. On "HTML disabled" frame : +
  3. JFileChooser shows a virtual directory. + The first file in the list has the following name: + <html><h1 color=#ff00ff><font + face="Serif">Swing Rocks! +
    +
    +
  4. In HTML disabled frame:
      -
    1. Verify that the folder and file name must be plain text. -
    2. If the name in file pane window and also in directory - ComboBox remains in plain text, then press Pass. - If it appears to be in HTML format with Pink color as - shown, then press Fail. +
    3. Verify that the first file name displays + as plain text, + that is you see the HTML tags in the file name. +
    4. If the file name in the file pane and + in the navigation combo box above is displayed + as HTML, that is in large font and magenta color, + then press Fail.
    -
  5. On "HTML enabled" frame : +
  6. In HTML enabled frame:
      -
    1. Verify that the folder and file name remains in HTML - format with name "Swing Rocks!" pink in color as shown. -
    2. If the name in file pane window and also in directory - ComboBox remains in HTML format string, then press Pass. - If it appears to be in plain text, then press Fail. +
    3. Verify that the first file name displays as HTML, + that is Swing Rocks! in large font + and magenta color.
      + Note: On macOS in Aqua L&F, the file name with + HTML displays as an empty file name. It is not an error. +
    4. If the file name in the file pane and + in the navigation combo box above is displayed + as HTML, then press Pass.
      + If it is in plain text, then press Fail.
@@ -99,6 +110,7 @@ public class HTMLFileName { PassFailJFrame.builder() .instructions(INSTRUCTIONS) .columns(45) + .rows(20) .testUI(HTMLFileName::initialize) .positionTestUIBottomRowCentered() .build() @@ -110,18 +122,25 @@ public class HTMLFileName { return List.of(createFileChooser(true), createFileChooser(false)); } - private static JFrame createFileChooser(boolean htmlEnabled) { + private static JFrame createFileChooser(boolean htmlDisabled) { JFileChooser jfc = new JFileChooser(new VirtualFileSystemView()); - jfc.putClientProperty("html.disable", htmlEnabled); + jfc.putClientProperty("html.disable", htmlDisabled); jfc.setControlButtonsAreShown(false); - JFrame frame = new JFrame((htmlEnabled) ? "HTML enabled" : "HTML disabled"); + JFrame frame = new JFrame(htmlDisabled ? "HTML disabled" : "HTML enabled"); frame.add(jfc); frame.pack(); return frame; } private static class VirtualFileSystemView extends FileSystemView { + private final File[] files = { + new File("/", "

Swing Rocks!"), + new File("/", "virtualFile1.txt"), + new File("/", "virtualFile2.log") + }; + @Override public File createNewFolder(File containingDir) { return null; @@ -129,12 +148,7 @@ public class HTMLFileName { @Override public File[] getRoots() { - return new File[]{ - new File("/", "

Swing Rocks!"), - new File("/", "virtualFile2.txt"), - new File("/", "virtualFolder") - }; + return files; } @Override @@ -150,12 +164,7 @@ public class HTMLFileName { @Override public File[] getFiles(File dir, boolean useFileHiding) { // Simulate a virtual folder structure - return new File[]{ - new File("/", "

Swing Rocks!"), - new File(dir, "virtualFile2.txt"), - new File(dir, "virtualFolder") - }; + return files; } @Override