Skip to content

Commit edf7ea7

Browse files
author
duke
committed
Backport cc5cda558736ffeae2a4611d87dfe280b9a4eac3
1 parent 3f1ba56 commit edf7ea7

File tree

2 files changed

+36
-57
lines changed

2 files changed

+36
-57
lines changed

test/jdk/java/awt/im/JTextFieldTest.html

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,43 +23,50 @@
2323

2424
/*
2525
* @test
26-
* @bug 4226191
26+
* @bug 4226191
27+
* @library /java/awt/regtesthelpers
28+
* @build PassFailJFrame
2729
* @summary Verify that Lightweight text components (like swing JTextField)
2830
* work correctly with IM when there is an uneditable peered
2931
* TextField/TextArea in the same parent Frame
30-
* @author xueming.shen@eng
31-
* @run applet/manual=yesno JTextFieldTest.html
32+
* @run main/manual JTextFieldTest
3233
*/
3334

34-
import java.awt.*;
35-
import java.awt.event.*;
36-
import java.applet.*;
37-
import javax.swing.*;
35+
import java.awt.FlowLayout;
36+
import java.awt.TextField;
3837

39-
public class JTextFieldTest extends Applet implements ActionListener {
38+
import javax.swing.JFrame;
39+
import javax.swing.JTextField;
4040

41-
TextField tf1;
42-
JTextField tf2;
41+
public class JTextFieldTest {
42+
private static final String INSTRUCTIONS =
43+
"""
44+
Please run this test in a CJK (Chinese/Japanese/Korean) locale
45+
with input method support. If you could add input in the swing
46+
JTextField, then the test has passed!
47+
""";
4348

44-
public JTextFieldTest() {
45-
tf1 = new TextField("ABCDEFGH", 10);
46-
tf1.setEditable(false);
47-
tf2 = new JTextField("12345678", 10);
48-
setLayout(new FlowLayout());
49-
add(tf1);
50-
add(tf2);
49+
public static void main(String[] args) throws Exception {
50+
PassFailJFrame
51+
.builder()
52+
.title("JTextFieldTest")
53+
.instructions(INSTRUCTIONS)
54+
.rows(5)
55+
.columns(40)
56+
.testUI(JTextFieldTest::createAndShowGUI)
57+
.build()
58+
.awaitAndCheck();
5159
}
5260

53-
public void actionPerformed(ActionEvent ae) {
54-
55-
}
56-
57-
public static void main(String args[]) {
58-
JFrame win = new JFrame();
59-
JTextFieldTest jtf = new JTextFieldTest();
60-
win.getContentPane().setLayout(new FlowLayout());
61-
win.getContentPane().add(jtf);
62-
win.pack();
63-
win.show();
61+
public static JFrame createAndShowGUI() {
62+
JFrame frame = new JFrame("Test Frame");
63+
frame.setLayout(new FlowLayout());
64+
TextField tf1 = new TextField("ABCDEFGH", 10);
65+
tf1.setEditable(false);
66+
JTextField tf2 = new JTextField("12345678", 10);
67+
frame.getContentPane().add(tf1);
68+
frame.getContentPane().add(tf2);
69+
frame.pack();
70+
return frame;
6471
}
6572
}

0 commit comments

Comments
 (0)