author | ysuenaga |
Wed, 13 Nov 2019 10:27:06 +0900 | |
changeset 59045 | 846fee5ea75e |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
8961 | 2 |
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
|
5 |
* modification, are permitted provided that the following conditions |
|
6 |
* are met: |
|
7 |
* |
|
8 |
* - Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* |
|
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. |
|
14 |
* |
|
5506 | 15 |
* - Neither the name of Oracle nor the names of its |
2 | 16 |
* contributors may be used to endorse or promote products derived |
17 |
* from this software without specific prior written permission. |
|
18 |
* |
|
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. |
|
30 |
*/ |
|
31 |
||
10292
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
32 |
/* |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
33 |
* This source code is provided to illustrate the usage of a given feature |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
34 |
* or technique and has been deliberately simplified. Additional steps |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
35 |
* required for a production-quality application, such as security checks, |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
36 |
* input validation and proper error handling, might not be present in |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
37 |
* this sample code. |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
38 |
*/ |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
39 |
|
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
8961
diff
changeset
|
40 |
|
2 | 41 |
|
8961 | 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; |
|
50 |
||
2 | 51 |
|
52 |
/** |
|
53 |
* This class describes a higher-contrast Metal Theme. |
|
54 |
* |
|
55 |
* @author Michael C. Albers |
|
8961 | 56 |
* @author Alexander Kouznetsov |
2 | 57 |
*/ |
58 |
public class ContrastMetalTheme extends DefaultMetalTheme { |
|
59 |
||
8961 | 60 |
@Override |
61 |
public String getName() { |
|
62 |
return "Contrast"; |
|
63 |
} |
|
2 | 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); |
|
8961 | 67 |
private final ColorUIResource primaryHighlight = new ColorUIResource(102, |
68 |
102, 102); |
|
69 |
private final ColorUIResource secondary2 = |
|
70 |
new ColorUIResource(204, 204, 204); |
|
71 |
private final ColorUIResource secondary3 = |
|
72 |
new ColorUIResource(255, 255, 255); |
|
73 |
||
74 |
@Override |
|
75 |
protected ColorUIResource getPrimary1() { |
|
76 |
return primary1; |
|
77 |
} |
|
78 |
||
79 |
@Override |
|
80 |
protected ColorUIResource getPrimary2() { |
|
81 |
return primary2; |
|
82 |
} |
|
2 | 83 |
|
8961 | 84 |
@Override |
85 |
protected ColorUIResource getPrimary3() { |
|
86 |
return primary3; |
|
87 |
} |
|
88 |
||
89 |
@Override |
|
90 |
public ColorUIResource getPrimaryControlHighlight() { |
|
91 |
return primaryHighlight; |
|
92 |
} |
|
2 | 93 |
|
8961 | 94 |
@Override |
95 |
protected ColorUIResource getSecondary2() { |
|
96 |
return secondary2; |
|
97 |
} |
|
98 |
||
99 |
@Override |
|
100 |
protected ColorUIResource getSecondary3() { |
|
101 |
return secondary3; |
|
102 |
} |
|
2 | 103 |
|
8961 | 104 |
@Override |
105 |
public ColorUIResource getControlHighlight() { |
|
106 |
return super.getSecondary3(); |
|
107 |
} |
|
108 |
||
109 |
@Override |
|
110 |
public ColorUIResource getFocusColor() { |
|
111 |
return getBlack(); |
|
112 |
} |
|
2 | 113 |
|
8961 | 114 |
@Override |
115 |
public ColorUIResource getTextHighlightColor() { |
|
116 |
return getBlack(); |
|
117 |
} |
|
118 |
||
119 |
@Override |
|
120 |
public ColorUIResource getHighlightedTextColor() { |
|
121 |
return getWhite(); |
|
122 |
} |
|
2 | 123 |
|
8961 | 124 |
@Override |
125 |
public ColorUIResource getMenuSelectedBackground() { |
|
126 |
return getBlack(); |
|
127 |
} |
|
128 |
||
129 |
@Override |
|
130 |
public ColorUIResource getMenuSelectedForeground() { |
|
131 |
return getWhite(); |
|
132 |
} |
|
2 | 133 |
|
8961 | 134 |
@Override |
135 |
public ColorUIResource getAcceleratorForeground() { |
|
136 |
return getBlack(); |
|
137 |
} |
|
2 | 138 |
|
8961 | 139 |
@Override |
140 |
public ColorUIResource getAcceleratorSelectedForeground() { |
|
141 |
return getWhite(); |
|
142 |
} |
|
2 | 143 |
|
8961 | 144 |
@Override |
2 | 145 |
public void addCustomEntriesToTable(UIDefaults table) { |
146 |
||
8961 | 147 |
Border blackLineBorder = |
148 |
new BorderUIResource(new LineBorder(getBlack())); |
|
149 |
Border whiteLineBorder = |
|
150 |
new BorderUIResource(new LineBorder(getWhite())); |
|
2 | 151 |
|
8961 | 152 |
Object textBorder = new BorderUIResource(new CompoundBorder( |
153 |
blackLineBorder, |
|
154 |
new BasicBorders.MarginBorder())); |
|
2 | 155 |
|
8961 | 156 |
table.put("ToolTip.border", blackLineBorder); |
157 |
table.put("TitledBorder.border", blackLineBorder); |
|
158 |
table.put("Table.focusCellHighlightBorder", whiteLineBorder); |
|
159 |
table.put("Table.focusCellForeground", getWhite()); |
|
2 | 160 |
|
8961 | 161 |
table.put("TextField.border", textBorder); |
162 |
table.put("PasswordField.border", textBorder); |
|
163 |
table.put("TextArea.border", textBorder); |
|
164 |
table.put("TextPane.font", textBorder); |
|
2 | 165 |
|
166 |
||
167 |
} |
|
168 |
} |