jdk

Форк
0
/
ContrastMetalTheme.java 
168 строк · 5.2 Кб
1
/*
2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
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
 *
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.
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

32
/*
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
37
 * this sample code.
38
 */
39

40

41

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

51

52
/**
53
 * This class describes a higher-contrast Metal Theme.
54
 *
55
 * @author Michael C. Albers
56
 * @author Alexander Kouznetsov
57
 */
58
public class ContrastMetalTheme extends DefaultMetalTheme {
59

60
    @Override
61
    public String getName() {
62
        return "Contrast";
63
    }
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,
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
    }
83

84
    @Override
85
    protected ColorUIResource getPrimary3() {
86
        return primary3;
87
    }
88

89
    @Override
90
    public ColorUIResource getPrimaryControlHighlight() {
91
        return primaryHighlight;
92
    }
93

94
    @Override
95
    protected ColorUIResource getSecondary2() {
96
        return secondary2;
97
    }
98

99
    @Override
100
    protected ColorUIResource getSecondary3() {
101
        return secondary3;
102
    }
103

104
    @Override
105
    public ColorUIResource getControlHighlight() {
106
        return super.getSecondary3();
107
    }
108

109
    @Override
110
    public ColorUIResource getFocusColor() {
111
        return getBlack();
112
    }
113

114
    @Override
115
    public ColorUIResource getTextHighlightColor() {
116
        return getBlack();
117
    }
118

119
    @Override
120
    public ColorUIResource getHighlightedTextColor() {
121
        return getWhite();
122
    }
123

124
    @Override
125
    public ColorUIResource getMenuSelectedBackground() {
126
        return getBlack();
127
    }
128

129
    @Override
130
    public ColorUIResource getMenuSelectedForeground() {
131
        return getWhite();
132
    }
133

134
    @Override
135
    public ColorUIResource getAcceleratorForeground() {
136
        return getBlack();
137
    }
138

139
    @Override
140
    public ColorUIResource getAcceleratorSelectedForeground() {
141
        return getWhite();
142
    }
143

144
    @Override
145
    public void addCustomEntriesToTable(UIDefaults table) {
146

147
        Border blackLineBorder =
148
                new BorderUIResource(new LineBorder(getBlack()));
149
        Border whiteLineBorder =
150
                new BorderUIResource(new LineBorder(getWhite()));
151

152
        Object textBorder = new BorderUIResource(new CompoundBorder(
153
                blackLineBorder,
154
                new BasicBorders.MarginBorder()));
155

156
        table.put("ToolTip.border", blackLineBorder);
157
        table.put("TitledBorder.border", blackLineBorder);
158
        table.put("Table.focusCellHighlightBorder", whiteLineBorder);
159
        table.put("Table.focusCellForeground", getWhite());
160

161
        table.put("TextField.border", textBorder);
162
        table.put("PasswordField.border", textBorder);
163
        table.put("TextArea.border", textBorder);
164
        table.put("TextPane.font", textBorder);
165

166

167
    }
168
}
169

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.