diff --git a/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.html b/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.html deleted file mode 100644 index 1d24a3523b5..00000000000 --- a/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - InputMethodsTest - - - - -This test is for Linux only. For other platforms please simply push "Pass". - -Test run requires some Japanese input method to be installed. - -To test JDK-7146572 fix please perform the following steps: -1. Switch on input method and type Japanese in the above text fields. -2. Push "Disable Input Methods" button. -3. Try to type Japanese again. If it can be done then the test is failed; otherwise passed. - - diff --git a/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java b/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java index a5665c906b9..a3037e02406 100644 --- a/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java +++ b/test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -21,68 +21,75 @@ * questions. */ +import java.awt.TextArea; +import java.awt.TextField; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComponent; /* - @test - @bug 7146572 8024122 - @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform - @author a.stepanov - @run applet/manual=yesno InputMethodsTest.html + * @test + * @bug 7146572 8024122 + * @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform + * @requires (os.family == "linux") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InputMethodsTest */ +public class InputMethodsTest { -import java.applet.Applet; -import java.awt.*; -import javax.swing.*; -import java.awt.event.*; + private static final String INSTRUCTIONS = """ + Test run requires some Japanese input method to be installed. + To test the JDK-7146572 fix, please follow these steps: + 1. Enable the input method. + 2. Type Japanese in the text area and the text field to the right. + 2. Press the "Disable Input Methods" button. + 3. Try typing Japanese again. + 4. If input methods are not disabled, then press fail; + otherwise, press pass. + """; -public class InputMethodsTest extends Applet { + static boolean inputMethodsEnabled = true; - TextArea txtArea = null; - TextField txtField = null; - JButton btnIM = null; - boolean inputMethodsEnabled = true; - - public void init() { - this.setLayout(new BorderLayout()); + public static void main(String[] args) throws Exception { + PassFailJFrame + .builder() + .title("InputMethodsTest Instructions") + .instructions(INSTRUCTIONS) + .splitUIRight(InputMethodsTest::createPanel) + .testTimeOut(10) + .rows(10) + .columns(40) + .build() + .awaitAndCheck(); } - public void start() { + public static JComponent createPanel() { + Box verticalBox = Box.createVerticalBox(); - setSize(350, 200); + TextArea textArea = new TextArea(); + verticalBox.add(textArea); - JPanel panel = new JPanel(); - panel.setLayout(new GridLayout(2, 1)); + TextField textField = new TextField(); + verticalBox.add(textField); - txtArea = new TextArea(); - panel.add(txtArea); + JButton btnIM = new JButton(); + setBtnText(btnIM); - txtField = new TextField(); - panel.add(txtField); - - add(panel, BorderLayout.CENTER); - - btnIM = new JButton(); - setBtnText(); - - btnIM.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - inputMethodsEnabled = !inputMethodsEnabled; - setBtnText(); - txtArea.enableInputMethods(inputMethodsEnabled); - txtField.enableInputMethods(inputMethodsEnabled); - } + btnIM.addActionListener(e -> { + inputMethodsEnabled = !inputMethodsEnabled; + setBtnText(btnIM); + textArea.enableInputMethods(inputMethodsEnabled); + textField.enableInputMethods(inputMethodsEnabled); }); - add(btnIM, BorderLayout.SOUTH); - - validate(); - setVisible(true); + verticalBox.add(btnIM); + return verticalBox; } - private void setBtnText() { + private static void setBtnText(JButton btnIM) { String s = inputMethodsEnabled ? "Disable" : "Enable"; btnIM.setText(s + " Input Methods"); }