Skip to content

Commit 481473e

Browse files
author
Tejesh R
committedMar 21, 2024·
8328035: Convert javax/swing/text/html/TableView/7030332/bug7030332.java applet test to main
Reviewed-by: abhiscxk, prr
1 parent dea94f4 commit 481473e

File tree

2 files changed

+42
-80
lines changed

2 files changed

+42
-80
lines changed
 

‎test/jdk/javax/swing/text/html/TableView/7030332/bug7030332.html

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 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
@@ -21,54 +21,57 @@
2121
* questions.
2222
*/
2323

24-
/* @test
25-
@bug 7030332
26-
@summary Default borders in tables looks incorrect JEditorPane
27-
@author Pavel Porvatov
28-
* @run applet/manual=yesno bug7030332.html
29-
*/
24+
import java.awt.GridLayout;
25+
import javax.swing.JComponent;
26+
import javax.swing.JEditorPane;
27+
import javax.swing.JLabel;
28+
import javax.swing.JPanel;
29+
import javax.swing.JTextArea;
30+
import javax.swing.ImageIcon;
31+
import javax.swing.SwingConstants;
3032

31-
import javax.swing.*;
32-
import java.awt.*;
3333
import java.net.URL;
3434

35-
public class bug7030332 extends JApplet {
35+
/* @test
36+
* @bug 7030332
37+
* @summary Default borders in tables looks incorrect
38+
* when rendered using JEditorPane
39+
* @library /java/awt/regtesthelpers
40+
* @build PassFailJFrame
41+
* @run main/manual/othervm -Dsun.java2d.uiScale=1 bug7030332
42+
*/
43+
44+
public class bug7030332 {
45+
public static void main(String[] args) throws Exception {
46+
String testInstructions = """
47+
Compare Golden Images with rendered JEditorPane.
48+
They should look similar in each line.
49+
Pay attention to:
50+
1. Border width around tables
51+
2. Border width around cells
52+
Note: The test was written before there was hidpi.
53+
Hence we are considering the border width being
54+
"similar enough" with 1.0 scaling.
55+
""";
56+
57+
PassFailJFrame.builder()
58+
.title("Test Instructions")
59+
.instructions(testInstructions)
60+
.rows(9)
61+
.columns(35)
62+
.splitUI(bug7030332::createContentPane)
63+
.build()
64+
.awaitAndCheck();
65+
}
66+
3667
public static final String[] HTML_SAMPLES = new String[]{
3768
"<table border><tr><th>Column1</th><th>Column2</th></tr></table>",
3869
"<table border=\"\"><tr><th>Column1</th><th>Column2</th></tr></table>",
3970
"<table border=\"1\"><tr><th>Column1</th><th>Column2</th></tr></table>",
4071
"<table border=\"2\"><tr><th>Column1</th><th>Column2</th></tr></table>",
4172
};
4273

43-
public static void main(String[] args) throws Exception {
44-
SwingUtilities.invokeLater(new Runnable() {
45-
public void run() {
46-
JFrame frame = new JFrame();
47-
48-
frame.setContentPane(createContentPane());
49-
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
50-
frame.setSize(600, 400);
51-
frame.setLocationRelativeTo(null);
52-
53-
frame.setVisible(true);
54-
55-
}
56-
});
57-
}
58-
59-
public void init() {
60-
try {
61-
SwingUtilities.invokeAndWait(new Runnable() {
62-
public void run() {
63-
setContentPane(createContentPane());
64-
}
65-
});
66-
} catch (Exception e) {
67-
throw new RuntimeException(e);
68-
}
69-
}
70-
71-
private static Container createContentPane() {
74+
private static JComponent createContentPane() {
7275
JPanel result = new JPanel(new GridLayout(HTML_SAMPLES.length + 1, 3, 10, 10));
7376

7477
result.add(new JLabel("Html code"));
@@ -77,22 +80,16 @@ private static Container createContentPane() {
7780

7881
for (int i = 0; i < HTML_SAMPLES.length; i++) {
7982
String htmlSample = HTML_SAMPLES[i];
80-
8183
JTextArea textArea = new JTextArea(htmlSample);
82-
8384
textArea.setLineWrap(true);
84-
8585
result.add(textArea);
8686

8787
String imageName = "sample" + i + ".png";
8888
URL resource = bug7030332.class.getResource(imageName);
89-
9089
result.add(resource == null ? new JLabel(imageName + " not found") :
9190
new JLabel(new ImageIcon(resource), SwingConstants.LEFT));
92-
9391
result.add(new JEditorPane("text/html", htmlSample));
9492
}
95-
9693
return result;
9794
}
9895
}

3 commit comments

Comments
 (3)

openjdk-notifier[bot] commented on Mar 21, 2024

@openjdk-notifier[bot]

JesperIRL commented on Mar 21, 2024

@JesperIRL
Member

/tag jdk-23+15

openjdk[bot] commented on Mar 21, 2024

@openjdk[bot]

@JesperIRL The tag jdk-23+15 was successfully created.

Please sign in to comment.