1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
21
21
* questions.
22
22
*/
23
23
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 ;
30
32
31
- import javax .swing .*;
32
- import java .awt .*;
33
33
import java .net .URL ;
34
34
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
+
36
67
public static final String [] HTML_SAMPLES = new String []{
37
68
"<table border><tr><th>Column1</th><th>Column2</th></tr></table>" ,
38
69
"<table border=\" \" ><tr><th>Column1</th><th>Column2</th></tr></table>" ,
39
70
"<table border=\" 1\" ><tr><th>Column1</th><th>Column2</th></tr></table>" ,
40
71
"<table border=\" 2\" ><tr><th>Column1</th><th>Column2</th></tr></table>" ,
41
72
};
42
73
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 () {
72
75
JPanel result = new JPanel (new GridLayout (HTML_SAMPLES .length + 1 , 3 , 10 , 10 ));
73
76
74
77
result .add (new JLabel ("Html code" ));
@@ -77,22 +80,16 @@ private static Container createContentPane() {
77
80
78
81
for (int i = 0 ; i < HTML_SAMPLES .length ; i ++) {
79
82
String htmlSample = HTML_SAMPLES [i ];
80
-
81
83
JTextArea textArea = new JTextArea (htmlSample );
82
-
83
84
textArea .setLineWrap (true );
84
-
85
85
result .add (textArea );
86
86
87
87
String imageName = "sample" + i + ".png" ;
88
88
URL resource = bug7030332 .class .getResource (imageName );
89
-
90
89
result .add (resource == null ? new JLabel (imageName + " not found" ) :
91
90
new JLabel (new ImageIcon (resource ), SwingConstants .LEFT ));
92
-
93
91
result .add (new JEditorPane ("text/html" , htmlSample ));
94
92
}
95
-
96
93
return result ;
97
94
}
98
95
}
3 commit comments
openjdk-notifier[bot] commentedon Mar 21, 2024
Review
Issues
JesperIRL commentedon Mar 21, 2024
/tag jdk-23+15
openjdk[bot] commentedon Mar 21, 2024
@JesperIRL The tag jdk-23+15 was successfully created.