Path: blob/master/test/jdk/sanity/client/lib/SwingSet2/src/ContrastTheme.java
41161 views
/*1* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.swing.UIDefaults;24import javax.swing.border.Border;25import javax.swing.border.CompoundBorder;26import javax.swing.border.LineBorder;27import javax.swing.plaf.BorderUIResource;28import javax.swing.plaf.ColorUIResource;29import javax.swing.plaf.basic.BasicBorders;30import javax.swing.plaf.metal.DefaultMetalTheme;3132/**33* This class describes a higher-contrast Metal Theme.34*35* @author Michael C. Albers36*/3738public class ContrastTheme extends DefaultMetalTheme {3940public static String NAME = "Contrast";4142public String getName() { return NAME; }4344private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);45private final ColorUIResource primary2 = new ColorUIResource(204, 204, 204);46private final ColorUIResource primary3 = new ColorUIResource(255, 255, 255);47private final ColorUIResource primaryHighlight = new ColorUIResource(102,102,102);4849private final ColorUIResource secondary2 = new ColorUIResource(204, 204, 204);50private final ColorUIResource secondary3 = new ColorUIResource(255, 255, 255);5152protected ColorUIResource getPrimary1() { return primary1; }53protected ColorUIResource getPrimary2() { return primary2; }54protected ColorUIResource getPrimary3() { return primary3; }55public ColorUIResource getPrimaryControlHighlight() { return primaryHighlight;}5657protected ColorUIResource getSecondary2() { return secondary2; }58protected ColorUIResource getSecondary3() { return secondary3; }59public ColorUIResource getControlHighlight() { return super.getSecondary3(); }6061public ColorUIResource getFocusColor() { return getBlack(); }6263public ColorUIResource getTextHighlightColor() { return getBlack(); }64public ColorUIResource getHighlightedTextColor() { return getWhite(); }6566public ColorUIResource getMenuSelectedBackground() { return getBlack(); }67public ColorUIResource getMenuSelectedForeground() { return getWhite(); }68public ColorUIResource getAcceleratorForeground() { return getBlack(); }69public ColorUIResource getAcceleratorSelectedForeground() { return getWhite(); }707172public void addCustomEntriesToTable(UIDefaults table) {7374Border blackLineBorder = new BorderUIResource(new LineBorder( getBlack() ));7576Object textBorder = new BorderUIResource( new CompoundBorder(77blackLineBorder,78new BasicBorders.MarginBorder()));7980table.put( "ToolTip.border", blackLineBorder);81table.put( "TitledBorder.border", blackLineBorder);8283table.put( "TextField.border", textBorder);84table.put( "PasswordField.border", textBorder);85table.put( "TextArea.border", textBorder);86table.put( "TextPane.border", textBorder);87table.put( "EditorPane.border", textBorder);888990}9192}9394