2
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
8
* - Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
11
* - Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* - Neither the name of Oracle nor the names of its
16
* contributors may be used to endorse or promote products derived
17
* from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
* This source code is provided to illustrate the usage of a given feature
34
* or technique and has been deliberately simplified. Additional steps
35
* required for a production-quality application, such as security checks,
36
* input validation and proper error handling, might not be present in
42
import javax.swing.UIDefaults;
43
import javax.swing.border.Border;
44
import javax.swing.border.CompoundBorder;
45
import javax.swing.border.LineBorder;
46
import javax.swing.plaf.BorderUIResource;
47
import javax.swing.plaf.ColorUIResource;
48
import javax.swing.plaf.basic.BasicBorders;
49
import javax.swing.plaf.metal.DefaultMetalTheme;
53
* This class describes a higher-contrast Metal Theme.
55
* @author Michael C. Albers
56
* @author Alexander Kouznetsov
58
public class ContrastMetalTheme extends DefaultMetalTheme {
61
public String getName() {
64
private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);
65
private final ColorUIResource primary2 = new ColorUIResource(204, 204, 204);
66
private final ColorUIResource primary3 = new ColorUIResource(255, 255, 255);
67
private final ColorUIResource primaryHighlight = new ColorUIResource(102,
69
private final ColorUIResource secondary2 =
70
new ColorUIResource(204, 204, 204);
71
private final ColorUIResource secondary3 =
72
new ColorUIResource(255, 255, 255);
75
protected ColorUIResource getPrimary1() {
80
protected ColorUIResource getPrimary2() {
85
protected ColorUIResource getPrimary3() {
90
public ColorUIResource getPrimaryControlHighlight() {
91
return primaryHighlight;
95
protected ColorUIResource getSecondary2() {
100
protected ColorUIResource getSecondary3() {
105
public ColorUIResource getControlHighlight() {
106
return super.getSecondary3();
110
public ColorUIResource getFocusColor() {
115
public ColorUIResource getTextHighlightColor() {
120
public ColorUIResource getHighlightedTextColor() {
125
public ColorUIResource getMenuSelectedBackground() {
130
public ColorUIResource getMenuSelectedForeground() {
135
public ColorUIResource getAcceleratorForeground() {
140
public ColorUIResource getAcceleratorSelectedForeground() {
145
public void addCustomEntriesToTable(UIDefaults table) {
147
Border blackLineBorder =
148
new BorderUIResource(new LineBorder(getBlack()));
149
Border whiteLineBorder =
150
new BorderUIResource(new LineBorder(getWhite()));
152
Object textBorder = new BorderUIResource(new CompoundBorder(
154
new BasicBorders.MarginBorder()));
156
table.put("ToolTip.border", blackLineBorder);
157
table.put("TitledBorder.border", blackLineBorder);
158
table.put("Table.focusCellHighlightBorder", whiteLineBorder);
159
table.put("Table.focusCellForeground", getWhite());
161
table.put("TextField.border", textBorder);
162
table.put("PasswordField.border", textBorder);
163
table.put("TextArea.border", textBorder);
164
table.put("TextPane.font", textBorder);