|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2001, 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 |
| -/* |
25 |
| - * @test |
26 |
| - * @bug 4247606 |
27 |
| - * @summary BorderedPane appears wrong with Title Position Below Bottom |
28 |
| - * @author Andrey Pikalev |
29 |
| - * @run applet/manual=yesno Test4247606.html |
30 |
| - */ |
31 |
| - |
32 | 24 | import java.awt.BorderLayout;
|
33 | 25 | import java.awt.Color;
|
| 26 | +import java.awt.Dimension; |
34 | 27 | import javax.swing.BorderFactory;
|
35 |
| -import javax.swing.JApplet; |
36 | 28 | import javax.swing.JButton;
|
37 | 29 | import javax.swing.JComponent;
|
38 | 30 | import javax.swing.JPanel;
|
39 | 31 | import javax.swing.border.Border;
|
40 | 32 | import javax.swing.border.TitledBorder;
|
41 | 33 |
|
42 |
| -public class Test4247606 extends JApplet { |
43 |
| - public void init() { |
44 |
| - JButton button = new JButton("Button"); // NON-NLS: the button text |
| 34 | +/* |
| 35 | + * @test |
| 36 | + * @bug 4247606 |
| 37 | + * @summary BorderedPane appears wrong with title position below bottom |
| 38 | + * @library /java/awt/regtesthelpers |
| 39 | + * @build PassFailJFrame |
| 40 | + * @run main/manual Test4247606 |
| 41 | + */ |
| 42 | + |
| 43 | +public class Test4247606 { |
| 44 | + public static void main(String[] args) throws Exception { |
| 45 | + String testInstructions = """ |
| 46 | + If the button does not fit into the titled border bounds |
| 47 | + and cover the bottom border's line then test fails. |
| 48 | + Otherwise test passes |
| 49 | + """; |
| 50 | + |
| 51 | + PassFailJFrame.builder() |
| 52 | + .title("Test Instructions") |
| 53 | + .instructions(testInstructions) |
| 54 | + .rows(4) |
| 55 | + .columns(35) |
| 56 | + .splitUI(Test4247606::initializeTest) |
| 57 | + .build() |
| 58 | + .awaitAndCheck(); |
| 59 | + } |
| 60 | + |
| 61 | + public static JComponent initializeTest() { |
| 62 | + JButton button = new JButton("Button"); |
45 | 63 | button.setBorder(BorderFactory.createLineBorder(Color.red, 1));
|
46 | 64 |
|
47 |
| - TitledBorder border = new TitledBorder("Bordered Pane"); // NON-NLS: the panel title |
| 65 | + TitledBorder border = new TitledBorder("Bordered Pane"); |
48 | 66 | border.setTitlePosition(TitledBorder.BELOW_BOTTOM);
|
49 | 67 |
|
50 | 68 | JPanel panel = create(button, border);
|
51 | 69 | panel.setBackground(Color.green);
|
| 70 | + panel.setPreferredSize(new Dimension(200, 150)); |
52 | 71 |
|
53 |
| - getContentPane().add(create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10))); |
| 72 | + return create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
54 | 73 | }
|
55 | 74 |
|
56 | 75 | private static JPanel create(JComponent component, Border border) {
|
|
0 commit comments