|
1 /* |
|
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 import static java.awt.Color.RED; |
|
25 import java.awt.Component; |
|
26 import java.awt.Dimension; |
|
27 import java.awt.Graphics; |
|
28 import java.awt.Insets; |
|
29 import javax.swing.Icon; |
|
30 import javax.swing.JApplet; |
|
31 import javax.swing.JButton; |
|
32 import javax.swing.JScrollPane; |
|
33 import javax.swing.JSplitPane; |
|
34 import javax.swing.border.MatteBorder; |
|
35 |
|
36 /* |
|
37 * @test |
|
38 * @bug 6910490 |
|
39 * @summary Tests a matte border around a component inside a scroll pane. |
|
40 * @author Sergey Malenkov |
|
41 * @run applet/manual=yesno Test6910490.html |
|
42 */ |
|
43 |
|
44 public class Test6910490 extends JApplet implements Icon { |
|
45 |
|
46 @Override |
|
47 public void init() { |
|
48 Insets insets = new Insets(10, 10, 10, 10); |
|
49 Dimension size = new Dimension(getWidth() / 2, getHeight()); |
|
50 JSplitPane pane = new JSplitPane( |
|
51 JSplitPane.HORIZONTAL_SPLIT, |
|
52 create("Color", size, new MatteBorder(insets, RED)), |
|
53 create("Icon", size, new MatteBorder(insets, this))); |
|
54 pane.setDividerLocation(size.width - pane.getDividerSize() / 2); |
|
55 add(pane); |
|
56 } |
|
57 |
|
58 private JScrollPane create(String name, Dimension size, MatteBorder border) { |
|
59 JButton button = new JButton(name); |
|
60 button.setPreferredSize(size); |
|
61 button.setBorder(border); |
|
62 return new JScrollPane(button); |
|
63 } |
|
64 |
|
65 public int getIconWidth() { |
|
66 return 10; |
|
67 } |
|
68 |
|
69 public int getIconHeight() { |
|
70 return 10; |
|
71 } |
|
72 |
|
73 public void paintIcon(Component c, Graphics g, int x, int y) { |
|
74 g.setColor(RED); |
|
75 g.fillRect(x, y, getIconWidth(), getIconHeight()); |
|
76 } |
|
77 } |