|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1999, 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 | +import java.awt.Dimension; |
| 25 | +import java.awt.Font; |
| 26 | +import javax.swing.BorderFactory; |
| 27 | +import javax.swing.Box; |
| 28 | +import javax.swing.JComponent; |
| 29 | +import javax.swing.JPanel; |
| 30 | +import javax.swing.border.TitledBorder; |
| 31 | + |
24 | 32 | /*
|
25 | 33 | * @test
|
26 | 34 | * @bug 4243289
|
27 | 35 | * @summary Tests that TitledBorder do not draw line through its caption
|
28 |
| - * @author Peter Zhelezniakov |
29 |
| - * @run applet/manual=yesno Test4243289.html |
| 36 | + * @library /java/awt/regtesthelpers |
| 37 | + * @build PassFailJFrame |
| 38 | + * @run main/manual Test4243289 |
30 | 39 | */
|
31 | 40 |
|
32 |
| -import java.awt.Font; |
33 |
| -import javax.swing.BorderFactory; |
34 |
| -import javax.swing.JApplet; |
35 |
| -import javax.swing.JPanel; |
36 |
| -import javax.swing.border.TitledBorder; |
| 41 | +public class Test4243289 { |
| 42 | + public static void main(String[] args) throws Exception { |
| 43 | + String testInstructions = """ |
| 44 | + If TitledBorder with title "Panel Title" is overstruck with |
| 45 | + the border line, test fails, otherwise it passes. |
| 46 | + """; |
| 47 | + |
| 48 | + PassFailJFrame.builder() |
| 49 | + .title("Test Instructions") |
| 50 | + .instructions(testInstructions) |
| 51 | + .rows(3) |
| 52 | + .columns(35) |
| 53 | + .splitUI(Test4243289::init) |
| 54 | + .build() |
| 55 | + .awaitAndCheck(); |
| 56 | + } |
37 | 57 |
|
38 |
| -public class Test4243289 extends JApplet { |
39 |
| - public void init() { |
40 |
| - Font font = new Font("Dialog", Font.PLAIN, 12); // NON-NLS: the font name |
| 58 | + public static JComponent init() { |
| 59 | + Font font = new Font(Font.DIALOG, Font.PLAIN, 12); |
41 | 60 | TitledBorder border = BorderFactory.createTitledBorder(
|
42 | 61 | BorderFactory.createEtchedBorder(),
|
43 |
| - "Panel Title", // NON-NLS: the title of the border |
| 62 | + "Panel Title", |
44 | 63 | TitledBorder.DEFAULT_JUSTIFICATION,
|
45 | 64 | TitledBorder.DEFAULT_POSITION,
|
46 | 65 | font);
|
47 | 66 |
|
48 | 67 | JPanel panel = new JPanel();
|
49 | 68 | panel.setBorder(border);
|
50 |
| - getContentPane().add(panel); |
| 69 | + panel.setPreferredSize(new Dimension(100, 100)); |
| 70 | + Box main = Box.createVerticalBox(); |
| 71 | + main.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
| 72 | + main.add(panel); |
| 73 | + return main; |
51 | 74 | }
|
52 | 75 | }
|
0 commit comments