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