Skip to content

8327750: Convert javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java applet test to main #3656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,44 +21,57 @@
* questions.
*/

import java.applet.Applet;
import java.io.File;

import java.awt.BorderLayout;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.filechooser.FileFilter;

public final class FileFilterDescription extends Applet {
/*
* @test
* @bug 8029536
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual FileFilterDescription
*/
public final class FileFilterDescription {

@Override
public void init() {
}

@Override
public void start() {
try {
test();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static final String INSTRUCTIONS = """
1) Check that current filter in the opened JFileChooser is a "CustomFileFilter".
2) Close the JFileChooser.
3) Test will repeat steps 1 - 2 for all supported look and feels.
4) If it's true for all look and feels then click Pass else click Fail. """;

public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("JFileChooser Filefilter Instructions")
.instructions(INSTRUCTIONS)
.rows(10)
.columns(35)
.position(PassFailJFrame.Position.TOP_LEFT_CORNER)
.build();

public static void test() throws Exception {
final UIManager.LookAndFeelInfo[] infos = UIManager
.getInstalledLookAndFeels();
for (final UIManager.LookAndFeelInfo info : infos) {
SwingUtilities.invokeAndWait(() -> {
final JFileChooser chooser = new JFileChooser();
setLookAndFeel(info);
JFrame frame = new JFrame("JFileChooser FileFilter test");
final JFileChooser chooser = new JFileChooser();
chooser.setAcceptAllFileFilterUsed(false);
chooser.setFileFilter(new CustomFileFilter());
SwingUtilities.updateComponentTreeUI(chooser);
frame.add(chooser, BorderLayout.CENTER);
frame.pack();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.TOP_LEFT_CORNER);
chooser.showDialog(null, "Open");
});
}
passFailJFrame.awaitAndCheck();
}

private static void setLookAndFeel(final UIManager.LookAndFeelInfo info) {
Expand Down