11/*
2- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2014, 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
2121 * questions.
2222 */
2323
24+ import javax .swing .JEditorPane ;
25+ import javax .swing .JPanel ;
26+ import javax .swing .JScrollPane ;
27+ import javax .swing .text .MutableAttributeSet ;
28+ import javax .swing .text .SimpleAttributeSet ;
29+ import javax .swing .text .StyleConstants ;
30+ import javax .swing .text .StyledEditorKit ;
31+
2432/* @test
25- @bug 4984669 8002148
26- @summary Tests HTML underlining
27- @author Peter Zhelezniakov
28- @run applet/manual=yesno bug4984669.html
29- */
30- import javax .swing .*;
31- import javax .swing .text .*;
33+ * @bug 4984669 8002148
34+ * @summary Tests HTML underlining
35+ * @library /java/awt/regtesthelpers
36+ * @build PassFailJFrame
37+ * @run main/manual htmlUnderliningTest
38+ */
39+
40+ public class htmlUnderliningTest {
41+ public static void main (String [] args ) throws Exception {
42+ String testInstructions = """
43+ The four lines printed in a bold typeface should all be underlined.
44+ It is a bug if any of these lines is underlined only partially.
45+ The very first line should not be underlined at all.
46+ """ ;
47+
48+ PassFailJFrame .builder ()
49+ .title ("Test Instructions" )
50+ .instructions (testInstructions )
51+ .rows (4 )
52+ .columns (35 )
53+ .splitUI (htmlUnderliningTest ::initializeTest )
54+ .build ()
55+ .awaitAndCheck ();
56+ }
3257
33- public class bug4984669 extends JApplet
34- {
35- public void init () {
58+ public static JPanel initializeTest () {
59+ JPanel panel = new JPanel ();
3660 JEditorPane pane = new JEditorPane ();
37- this . getContentPane () .add (new JScrollPane (pane ));
61+ panel .add (new JScrollPane (pane ));
3862 pane .setEditorKit (new StyledEditorKit ());
3963
4064 try {
41- pane .getDocument ().insertString (0 ,"12 \n " ,null );
65+ pane .getDocument ().insertString (0 , "12 \n " , null );
4266 MutableAttributeSet attrs = new SimpleAttributeSet ();
4367
4468 StyleConstants .setFontSize (attrs , 36 );
@@ -51,5 +75,6 @@ public void init() {
5175 } catch (Exception e ) {
5276 throw new Error ("Failed: Unexpected Exception" , e );
5377 }
78+ return panel ;
5479 }
5580}
0 commit comments