1 /*
2  *
3  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  *   - Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *
12  *   - Redistributions in binary form must reproduce the above copyright
13  *     notice, this list of conditions and the following disclaimer in the
14  *     documentation and/or other materials provided with the distribution.
15  *
16  *   - Neither the name of Oracle nor the names of its
17  *     contributors may be used to endorse or promote products derived
18  *     from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 
34 import javax.swing.plaf.*;
35 import javax.swing.plaf.basic.*;
36 import javax.swing.plaf.metal.*;
37 import javax.swing.*;
38 import javax.swing.border.*;
39 import java.awt.*;
40 
41 /**
42  * This class describes a higher-contrast Metal Theme.
43  *
44  * @author Michael C. Albers
45  */
46 
47 public class ContrastTheme extends DefaultMetalTheme {
48 
getName()49     public String getName() { return "Contrast"; }
50 
51     private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);
52     private final ColorUIResource primary2 = new ColorUIResource(204, 204, 204);
53     private final ColorUIResource primary3 = new ColorUIResource(255, 255, 255);
54     private final ColorUIResource primaryHighlight = new ColorUIResource(102,102,102);
55 
56     private final ColorUIResource secondary2 = new ColorUIResource(204, 204, 204);
57     private final ColorUIResource secondary3 = new ColorUIResource(255, 255, 255);
58     private final ColorUIResource controlHighlight = new ColorUIResource(102,102,102);
59 
getPrimary1()60     protected ColorUIResource getPrimary1() { return primary1; }
getPrimary2()61     protected ColorUIResource getPrimary2() { return primary2; }
getPrimary3()62     protected ColorUIResource getPrimary3() { return primary3; }
getPrimaryControlHighlight()63     public ColorUIResource getPrimaryControlHighlight() { return primaryHighlight;}
64 
getSecondary2()65     protected ColorUIResource getSecondary2() { return secondary2; }
getSecondary3()66     protected ColorUIResource getSecondary3() { return secondary3; }
getControlHighlight()67     public ColorUIResource getControlHighlight() { return super.getSecondary3(); }
68 
getFocusColor()69     public ColorUIResource getFocusColor() { return getBlack(); }
70 
getTextHighlightColor()71     public ColorUIResource getTextHighlightColor() { return getBlack(); }
getHighlightedTextColor()72     public ColorUIResource getHighlightedTextColor() { return getWhite(); }
73 
getMenuSelectedBackground()74     public ColorUIResource getMenuSelectedBackground() { return getBlack(); }
getMenuSelectedForeground()75     public ColorUIResource getMenuSelectedForeground() { return getWhite(); }
getAcceleratorForeground()76     public ColorUIResource getAcceleratorForeground() { return getBlack(); }
getAcceleratorSelectedForeground()77     public ColorUIResource getAcceleratorSelectedForeground() { return getWhite(); }
78 
79 
addCustomEntriesToTable(UIDefaults table)80     public void addCustomEntriesToTable(UIDefaults table) {
81 
82         Border blackLineBorder = new BorderUIResource(new LineBorder( getBlack() ));
83 
84         Object textBorder = new BorderUIResource( new CompoundBorder(
85                                                        blackLineBorder,
86                                                        new BasicBorders.MarginBorder()));
87 
88         table.put( "ToolTip.border", blackLineBorder);
89         table.put( "TitledBorder.border", blackLineBorder);
90 
91         table.put( "TextField.border", textBorder);
92         table.put( "PasswordField.border", textBorder);
93         table.put( "TextArea.border", textBorder);
94         table.put( "TextPane.border", textBorder);
95         table.put( "EditorPane.border", textBorder);
96 
97 
98     }
99 
100 }
101