8189656: The Windows L&F should be moved out from the shared folder
Reviewed-by: prr, psadhukhan, erikj
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,436 +0,0 @@
-/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.security.AccessController;
-import sun.security.action.GetBooleanAction;
-
-import java.util.*;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.Prop;
-import com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-import sun.awt.AppContext;
-
-/**
- * A class to help mimic Vista theme animations. The only kind of
- * animation it handles for now is 'transition' animation (this seems
- * to be the only animation which Vista theme can do). This is when
- * one picture fadein over another one in some period of time.
- * According to
- * https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=86852&SiteID=4
- * The animations are all linear.
- *
- * This class has a number of responsibilities.
- * <ul>
- * <li> It trigger rapaint for the UI components involved in the animation
- * <li> It tracks the animation state for every UI component involved in the
- * animation and paints {@code Skin} in new {@code State} over the
- * {@code Skin} in last {@code State} using
- * {@code AlphaComposite.SrcOver.derive(alpha)} where {code alpha}
- * depends on the state of animation
- * </ul>
- *
- * @author Igor Kushnirskiy
- */
-class AnimationController implements ActionListener, PropertyChangeListener {
-
- private static final boolean VISTA_ANIMATION_DISABLED =
- AccessController.doPrivileged(new GetBooleanAction("swing.disablevistaanimation"));
-
-
- private static final Object ANIMATION_CONTROLLER_KEY =
- new StringBuilder("ANIMATION_CONTROLLER_KEY");
-
- private final Map<JComponent, Map<Part, AnimationState>> animationStateMap =
- new WeakHashMap<JComponent, Map<Part, AnimationState>>();
-
- //this timer is used to cause repaint on animated components
- //30 repaints per second should give smooth animation affect
- private final javax.swing.Timer timer =
- new javax.swing.Timer(1000/30, this);
-
- private static synchronized AnimationController getAnimationController() {
- AppContext appContext = AppContext.getAppContext();
- Object obj = appContext.get(ANIMATION_CONTROLLER_KEY);
- if (obj == null) {
- obj = new AnimationController();
- appContext.put(ANIMATION_CONTROLLER_KEY, obj);
- }
- return (AnimationController) obj;
- }
-
- private AnimationController() {
- timer.setRepeats(true);
- timer.setCoalesce(true);
- //we need to dispose the controller on l&f change
- UIManager.addPropertyChangeListener(this);
- }
-
- private static void triggerAnimation(JComponent c,
- Part part, State newState) {
- if (c instanceof javax.swing.JTabbedPane
- || part == Part.TP_BUTTON) {
- //idk: we can not handle tabs animation because
- //the same (component,part) is used to handle all the tabs
- //and we can not track the states
- //Vista theme might have transition duration for toolbar buttons
- //but native application does not seem to animate them
- return;
- }
- AnimationController controller =
- AnimationController.getAnimationController();
- State oldState = controller.getState(c, part);
- if (oldState != newState) {
- controller.putState(c, part, newState);
- if (newState == State.DEFAULTED) {
- // it seems for DEFAULTED button state Vista does animation from
- // HOT
- oldState = State.HOT;
- }
- if (oldState != null) {
- long duration;
- if (newState == State.DEFAULTED) {
- //Only button might have DEFAULTED state
- //idk: do not know how to get the value from Vista
- //one second seems plausible value
- duration = 1000;
- } else {
- XPStyle xp = XPStyle.getXP();
- duration = (xp != null)
- ? xp.getThemeTransitionDuration(
- c, part,
- normalizeState(oldState),
- normalizeState(newState),
- Prop.TRANSITIONDURATIONS)
- : 1000;
- }
- controller.startAnimation(c, part, oldState, newState, duration);
- }
- }
- }
-
- // for scrollbar up, down, left and right button pictures are
- // defined by states. It seems that theme has duration defined
- // only for up button states thus we doing this translation here.
- private static State normalizeState(State state) {
- State rv;
- switch (state) {
- case DOWNPRESSED:
- /* falls through */
- case LEFTPRESSED:
- /* falls through */
- case RIGHTPRESSED:
- rv = UPPRESSED;
- break;
-
- case DOWNDISABLED:
- /* falls through */
- case LEFTDISABLED:
- /* falls through */
- case RIGHTDISABLED:
- rv = UPDISABLED;
- break;
-
- case DOWNHOT:
- /* falls through */
- case LEFTHOT:
- /* falls through */
- case RIGHTHOT:
- rv = UPHOT;
- break;
-
- case DOWNNORMAL:
- /* falls through */
- case LEFTNORMAL:
- /* falls through */
- case RIGHTNORMAL:
- rv = UPNORMAL;
- break;
-
- default :
- rv = state;
- break;
- }
- return rv;
- }
-
- private synchronized State getState(JComponent component, Part part) {
- State rv = null;
- Object tmpObject =
- component.getClientProperty(PartUIClientPropertyKey.getKey(part));
- if (tmpObject instanceof State) {
- rv = (State) tmpObject;
- }
- return rv;
- }
-
- private synchronized void putState(JComponent component, Part part,
- State state) {
- component.putClientProperty(PartUIClientPropertyKey.getKey(part),
- state);
- }
-
- private synchronized void startAnimation(JComponent component,
- Part part,
- State startState,
- State endState,
- long millis) {
- boolean isForwardAndReverse = false;
- if (endState == State.DEFAULTED) {
- isForwardAndReverse = true;
- }
- Map<Part, AnimationState> map = animationStateMap.get(component);
- if (millis <= 0) {
- if (map != null) {
- map.remove(part);
- if (map.size() == 0) {
- animationStateMap.remove(component);
- }
- }
- return;
- }
- if (map == null) {
- map = new EnumMap<Part, AnimationState>(Part.class);
- animationStateMap.put(component, map);
- }
- map.put(part,
- new AnimationState(startState, millis, isForwardAndReverse));
- if (! timer.isRunning()) {
- timer.start();
- }
- }
-
- static void paintSkin(JComponent component, Skin skin,
- Graphics g, int dx, int dy, int dw, int dh, State state) {
- if (VISTA_ANIMATION_DISABLED) {
- skin.paintSkinRaw(g, dx, dy, dw, dh, state);
- return;
- }
- triggerAnimation(component, skin.part, state);
- AnimationController controller = getAnimationController();
- synchronized (controller) {
- AnimationState animationState = null;
- Map<Part, AnimationState> map =
- controller.animationStateMap.get(component);
- if (map != null) {
- animationState = map.get(skin.part);
- }
- if (animationState != null) {
- animationState.paintSkin(skin, g, dx, dy, dw, dh, state);
- } else {
- skin.paintSkinRaw(g, dx, dy, dw, dh, state);
- }
- }
- }
-
- public synchronized void propertyChange(PropertyChangeEvent e) {
- if ("lookAndFeel" == e.getPropertyName()
- && ! (e.getNewValue() instanceof WindowsLookAndFeel) ) {
- dispose();
- }
- }
-
- public synchronized void actionPerformed(ActionEvent e) {
- java.util.List<JComponent> componentsToRemove = null;
- java.util.List<Part> partsToRemove = null;
- for (JComponent component : animationStateMap.keySet()) {
- component.repaint();
- if (partsToRemove != null) {
- partsToRemove.clear();
- }
- Map<Part, AnimationState> map = animationStateMap.get(component);
- if (! component.isShowing()
- || map == null
- || map.size() == 0) {
- if (componentsToRemove == null) {
- componentsToRemove = new ArrayList<JComponent>();
- }
- componentsToRemove.add(component);
- continue;
- }
- for (Part part : map.keySet()) {
- if (map.get(part).isDone()) {
- if (partsToRemove == null) {
- partsToRemove = new ArrayList<Part>();
- }
- partsToRemove.add(part);
- }
- }
- if (partsToRemove != null) {
- if (partsToRemove.size() == map.size()) {
- //animation is done for the component
- if (componentsToRemove == null) {
- componentsToRemove = new ArrayList<JComponent>();
- }
- componentsToRemove.add(component);
- } else {
- for (Part part : partsToRemove) {
- map.remove(part);
- }
- }
- }
- }
- if (componentsToRemove != null) {
- for (JComponent component : componentsToRemove) {
- animationStateMap.remove(component);
- }
- }
- if (animationStateMap.size() == 0) {
- timer.stop();
- }
- }
-
- private synchronized void dispose() {
- timer.stop();
- UIManager.removePropertyChangeListener(this);
- synchronized (AnimationController.class) {
- AppContext.getAppContext()
- .put(ANIMATION_CONTROLLER_KEY, null);
- }
- }
-
- private static class AnimationState {
- private final State startState;
-
- //animation duration in nanoseconds
- private final long duration;
-
- //animatin start time in nanoseconds
- private long startTime;
-
- //direction the alpha value is changing
- //forward - from 0 to 1
- //!forward - from 1 to 0
- private boolean isForward = true;
-
- //if isForwardAndReverse the animation continually goes
- //forward and reverse. alpha value is changing from 0 to 1 then
- //from 1 to 0 and so forth
- private boolean isForwardAndReverse;
-
- private float progress;
-
- AnimationState(final State startState,
- final long milliseconds,
- boolean isForwardAndReverse) {
- assert startState != null && milliseconds > 0;
- assert SwingUtilities.isEventDispatchThread();
-
- this.startState = startState;
- this.duration = milliseconds * 1000000;
- this.startTime = System.nanoTime();
- this.isForwardAndReverse = isForwardAndReverse;
- progress = 0f;
- }
- private void updateProgress() {
- assert SwingUtilities.isEventDispatchThread();
-
- if (isDone()) {
- return;
- }
- long currentTime = System.nanoTime();
-
- progress = ((float) (currentTime - startTime))
- / duration;
- progress = Math.max(progress, 0); //in case time was reset
- if (progress >= 1) {
- progress = 1;
- if (isForwardAndReverse) {
- startTime = currentTime;
- progress = 0;
- isForward = ! isForward;
- }
- }
- }
- void paintSkin(Skin skin, Graphics _g,
- int dx, int dy, int dw, int dh, State state) {
- assert SwingUtilities.isEventDispatchThread();
-
- updateProgress();
- if (! isDone()) {
- Graphics2D g = (Graphics2D) _g.create();
- if (skin.haveToSwitchStates()) {
- skin.paintSkinRaw(g, dx, dy, dw, dh, state);
- g.setComposite(AlphaComposite.SrcOver.derive(1 - progress));
- skin.paintSkinRaw(g, dx, dy, dw, dh, startState);
- } else {
- skin.paintSkinRaw(g, dx, dy, dw, dh, startState);
- float alpha;
- if (isForward) {
- alpha = progress;
- } else {
- alpha = 1 - progress;
- }
- g.setComposite(AlphaComposite.SrcOver.derive(alpha));
- skin.paintSkinRaw(g, dx, dy, dw, dh, state);
- }
- g.dispose();
- } else {
- skin.paintSkinRaw(_g, dx, dy, dw, dh, state);
- skin.switchStates(false);
- }
- }
- boolean isDone() {
- assert SwingUtilities.isEventDispatchThread();
-
- return progress >= 1;
- }
- }
-
- private static class PartUIClientPropertyKey
- implements UIClientPropertyKey {
-
- private static final Map<Part, PartUIClientPropertyKey> map =
- new EnumMap<Part, PartUIClientPropertyKey>(Part.class);
-
- static synchronized PartUIClientPropertyKey getKey(Part part) {
- PartUIClientPropertyKey rv = map.get(part);
- if (rv == null) {
- rv = new PartUIClientPropertyKey(part);
- map.put(part, rv);
- }
- return rv;
- }
-
- private final Part part;
- private PartUIClientPropertyKey(Part part) {
- this.part = part;
- }
- public String toString() {
- return part.toString();
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,577 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * <p>These classes are designed to be used while the
- * corresponding <code>LookAndFeel</code> class has been installed
- * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
- * Using them while a different <code>LookAndFeel</code> is installed
- * may produce unexpected results, including exceptions.
- * Additionally, changing the <code>LookAndFeel</code>
- * maintained by the <code>UIManager</code> without updating the
- * corresponding <code>ComponentUI</code> of any
- * <code>JComponent</code>s may also produce unexpected results,
- * such as the wrong colors showing up, and is generally not
- * encouraged.
- *
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.util.*;
-
-import javax.swing.*;
-
-import sun.awt.windows.ThemeReader;
-
-/**
- * Implements Windows Parts and their States and Properties for the Windows Look and Feel.
- *
- * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp
- * See tmschema.h (or vssym32.h & vsstyle.h for MS Vista)
- *
- * @author Leif Samuelsson
- */
-class TMSchema {
-
- /**
- * An enumeration of the various Windows controls (also known as
- * components, or top-level parts)
- */
- public static enum Control {
- BUTTON,
- COMBOBOX,
- EDIT,
- HEADER,
- LISTBOX,
- LISTVIEW,
- MENU,
- PROGRESS,
- REBAR,
- SCROLLBAR,
- SPIN,
- TAB,
- TOOLBAR,
- TRACKBAR,
- TREEVIEW,
- WINDOW
- }
-
-
- /**
- * An enumeration of the Windows compoent parts
- */
- public static enum Part {
- MENU (Control.MENU, 0), // Special case, not in native
- MP_BARBACKGROUND (Control.MENU, 7),
- MP_BARITEM (Control.MENU, 8),
- MP_POPUPBACKGROUND (Control.MENU, 9),
- MP_POPUPBORDERS (Control.MENU, 10),
- MP_POPUPCHECK (Control.MENU, 11),
- MP_POPUPCHECKBACKGROUND (Control.MENU, 12),
- MP_POPUPGUTTER (Control.MENU, 13),
- MP_POPUPITEM (Control.MENU, 14),
- MP_POPUPSEPARATOR (Control.MENU, 15),
- MP_POPUPSUBMENU (Control.MENU, 16),
-
- BP_PUSHBUTTON (Control.BUTTON, 1),
- BP_RADIOBUTTON(Control.BUTTON, 2),
- BP_CHECKBOX (Control.BUTTON, 3),
- BP_GROUPBOX (Control.BUTTON, 4),
-
- CP_COMBOBOX (Control.COMBOBOX, 0),
- CP_DROPDOWNBUTTON(Control.COMBOBOX, 1),
- CP_BACKGROUND (Control.COMBOBOX, 2),
- CP_TRANSPARENTBACKGROUND (Control.COMBOBOX, 3),
- CP_BORDER (Control.COMBOBOX, 4),
- CP_READONLY (Control.COMBOBOX, 5),
- CP_DROPDOWNBUTTONRIGHT (Control.COMBOBOX, 6),
- CP_DROPDOWNBUTTONLEFT (Control.COMBOBOX, 7),
- CP_CUEBANNER (Control.COMBOBOX, 8),
-
-
- EP_EDIT (Control.EDIT, 0),
- EP_EDITTEXT(Control.EDIT, 1),
-
- HP_HEADERITEM(Control.HEADER, 1),
- HP_HEADERSORTARROW(Control.HEADER, 4),
-
- LBP_LISTBOX(Control.LISTBOX, 0),
-
- LBCP_BORDER_HSCROLL (Control.LISTBOX, 1),
- LBCP_BORDER_HVSCROLL (Control.LISTBOX, 2),
- LBCP_BORDER_NOSCROLL (Control.LISTBOX, 3),
- LBCP_BORDER_VSCROLL (Control.LISTBOX, 4),
- LBCP_ITEM (Control.LISTBOX, 5),
-
- LVP_LISTVIEW(Control.LISTVIEW, 0),
-
- PP_PROGRESS (Control.PROGRESS, 0),
- PP_BAR (Control.PROGRESS, 1),
- PP_BARVERT (Control.PROGRESS, 2),
- PP_CHUNK (Control.PROGRESS, 3),
- PP_CHUNKVERT(Control.PROGRESS, 4),
-
- RP_GRIPPER (Control.REBAR, 1),
- RP_GRIPPERVERT(Control.REBAR, 2),
-
- SBP_SCROLLBAR (Control.SCROLLBAR, 0),
- SBP_ARROWBTN (Control.SCROLLBAR, 1),
- SBP_THUMBBTNHORZ (Control.SCROLLBAR, 2),
- SBP_THUMBBTNVERT (Control.SCROLLBAR, 3),
- SBP_LOWERTRACKHORZ(Control.SCROLLBAR, 4),
- SBP_UPPERTRACKHORZ(Control.SCROLLBAR, 5),
- SBP_LOWERTRACKVERT(Control.SCROLLBAR, 6),
- SBP_UPPERTRACKVERT(Control.SCROLLBAR, 7),
- SBP_GRIPPERHORZ (Control.SCROLLBAR, 8),
- SBP_GRIPPERVERT (Control.SCROLLBAR, 9),
- SBP_SIZEBOX (Control.SCROLLBAR, 10),
-
- SPNP_UP (Control.SPIN, 1),
- SPNP_DOWN(Control.SPIN, 2),
-
- TABP_TABITEM (Control.TAB, 1),
- TABP_TABITEMLEFTEDGE (Control.TAB, 2),
- TABP_TABITEMRIGHTEDGE(Control.TAB, 3),
- TABP_PANE (Control.TAB, 9),
-
- TP_TOOLBAR (Control.TOOLBAR, 0),
- TP_BUTTON (Control.TOOLBAR, 1),
- TP_SEPARATOR (Control.TOOLBAR, 5),
- TP_SEPARATORVERT (Control.TOOLBAR, 6),
-
- TKP_TRACK (Control.TRACKBAR, 1),
- TKP_TRACKVERT (Control.TRACKBAR, 2),
- TKP_THUMB (Control.TRACKBAR, 3),
- TKP_THUMBBOTTOM(Control.TRACKBAR, 4),
- TKP_THUMBTOP (Control.TRACKBAR, 5),
- TKP_THUMBVERT (Control.TRACKBAR, 6),
- TKP_THUMBLEFT (Control.TRACKBAR, 7),
- TKP_THUMBRIGHT (Control.TRACKBAR, 8),
- TKP_TICS (Control.TRACKBAR, 9),
- TKP_TICSVERT (Control.TRACKBAR, 10),
-
- TVP_TREEVIEW(Control.TREEVIEW, 0),
- TVP_GLYPH (Control.TREEVIEW, 2),
-
- WP_WINDOW (Control.WINDOW, 0),
- WP_CAPTION (Control.WINDOW, 1),
- WP_MINCAPTION (Control.WINDOW, 3),
- WP_MAXCAPTION (Control.WINDOW, 5),
- WP_FRAMELEFT (Control.WINDOW, 7),
- WP_FRAMERIGHT (Control.WINDOW, 8),
- WP_FRAMEBOTTOM (Control.WINDOW, 9),
- WP_SYSBUTTON (Control.WINDOW, 13),
- WP_MDISYSBUTTON (Control.WINDOW, 14),
- WP_MINBUTTON (Control.WINDOW, 15),
- WP_MDIMINBUTTON (Control.WINDOW, 16),
- WP_MAXBUTTON (Control.WINDOW, 17),
- WP_CLOSEBUTTON (Control.WINDOW, 18),
- WP_MDICLOSEBUTTON (Control.WINDOW, 20),
- WP_RESTOREBUTTON (Control.WINDOW, 21),
- WP_MDIRESTOREBUTTON(Control.WINDOW, 22);
-
- private final Control control;
- private final int value;
-
- private Part(Control control, int value) {
- this.control = control;
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
-
- public String getControlName(Component component) {
- String str = "";
- if (component instanceof JComponent) {
- JComponent c = (JComponent)component;
- String subAppName = (String)c.getClientProperty("XPStyle.subAppName");
- if (subAppName != null) {
- str = subAppName + "::";
- }
- }
- return str + control.toString();
- }
-
- public String toString() {
- return control.toString()+"."+name();
- }
- }
-
-
- /**
- * An enumeration of the possible component states
- */
- public static enum State {
- ACTIVE,
- ASSIST,
- BITMAP,
- CHECKED,
- CHECKEDDISABLED,
- CHECKEDHOT,
- CHECKEDNORMAL,
- CHECKEDPRESSED,
- CHECKMARKNORMAL,
- CHECKMARKDISABLED,
- BULLETNORMAL,
- BULLETDISABLED,
- CLOSED,
- DEFAULTED,
- DISABLED,
- DISABLEDHOT,
- DISABLEDPUSHED,
- DOWNDISABLED,
- DOWNHOT,
- DOWNNORMAL,
- DOWNPRESSED,
- FOCUSED,
- HOT,
- HOTCHECKED,
- ICONHOT,
- ICONNORMAL,
- ICONPRESSED,
- ICONSORTEDHOT,
- ICONSORTEDNORMAL,
- ICONSORTEDPRESSED,
- INACTIVE,
- INACTIVENORMAL, // See note 1
- INACTIVEHOT, // See note 1
- INACTIVEPUSHED, // See note 1
- INACTIVEDISABLED, // See note 1
- LEFTDISABLED,
- LEFTHOT,
- LEFTNORMAL,
- LEFTPRESSED,
- MIXEDDISABLED,
- MIXEDHOT,
- MIXEDNORMAL,
- MIXEDPRESSED,
- NORMAL,
- PRESSED,
- OPENED,
- PUSHED,
- READONLY,
- RIGHTDISABLED,
- RIGHTHOT,
- RIGHTNORMAL,
- RIGHTPRESSED,
- SELECTED,
- UNCHECKEDDISABLED,
- UNCHECKEDHOT,
- UNCHECKEDNORMAL,
- UNCHECKEDPRESSED,
- UPDISABLED,
- UPHOT,
- UPNORMAL,
- UPPRESSED,
- HOVER,
- UPHOVER,
- DOWNHOVER,
- LEFTHOVER,
- RIGHTHOVER,
- SORTEDDOWN,
- SORTEDHOT,
- SORTEDNORMAL,
- SORTEDPRESSED,
- SORTEDUP;
-
-
- /**
- * A map of allowed states for each Part
- */
- private static EnumMap<Part, State[]> stateMap;
-
- private static synchronized void initStates() {
- stateMap = new EnumMap<Part, State[]>(Part.class);
-
- stateMap.put(Part.EP_EDITTEXT,
- new State[] {
- NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
- });
-
- stateMap.put(Part.BP_PUSHBUTTON,
- new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED });
-
- stateMap.put(Part.BP_RADIOBUTTON,
- new State[] {
- UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
- CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED
- });
-
- stateMap.put(Part.BP_CHECKBOX,
- new State[] {
- UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
- CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED,
- MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
- });
-
- State[] comboBoxStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
- stateMap.put(Part.CP_COMBOBOX, comboBoxStates);
- stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
- stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
- stateMap.put(Part.CP_TRANSPARENTBACKGROUND, comboBoxStates);
- stateMap.put(Part.CP_BORDER, comboBoxStates);
- stateMap.put(Part.CP_READONLY, comboBoxStates);
- stateMap.put(Part.CP_DROPDOWNBUTTONRIGHT, comboBoxStates);
- stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates);
- stateMap.put(Part.CP_CUEBANNER, comboBoxStates);
-
- stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, HOT, PRESSED,
- SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
- ICONNORMAL, ICONHOT, ICONPRESSED,
- ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
-
- stateMap.put(Part.HP_HEADERSORTARROW,
- new State[] {SORTEDDOWN, SORTEDUP});
-
- State[] listBoxStates = new State[] { NORMAL, PRESSED, HOT, DISABLED};
- stateMap.put(Part.LBCP_BORDER_HSCROLL, listBoxStates);
- stateMap.put(Part.LBCP_BORDER_HVSCROLL, listBoxStates);
- stateMap.put(Part.LBCP_BORDER_NOSCROLL, listBoxStates);
- stateMap.put(Part.LBCP_BORDER_VSCROLL, listBoxStates);
-
- State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER };
- stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
- stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates);
- stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates);
- stateMap.put(Part.SBP_GRIPPERVERT, scrollBarStates);
- stateMap.put(Part.SBP_GRIPPERHORZ, scrollBarStates);
-
- stateMap.put(Part.SBP_ARROWBTN,
- new State[] {
- UPNORMAL, UPHOT, UPPRESSED, UPDISABLED,
- DOWNNORMAL, DOWNHOT, DOWNPRESSED, DOWNDISABLED,
- LEFTNORMAL, LEFTHOT, LEFTPRESSED, LEFTDISABLED,
- RIGHTNORMAL, RIGHTHOT, RIGHTPRESSED, RIGHTDISABLED,
- UPHOVER, DOWNHOVER, LEFTHOVER, RIGHTHOVER
- });
-
-
- State[] spinnerStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
- stateMap.put(Part.SPNP_UP, spinnerStates);
- stateMap.put(Part.SPNP_DOWN, spinnerStates);
-
- stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED });
-
- State[] frameButtonStates = new State[] {
- NORMAL, HOT, PUSHED, DISABLED, // See note 1
- INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED,
- };
- // Note 1: The INACTIVE frame button states apply when the frame
- // is inactive. They are not defined in tmschema.h
-
- // Fix for 6316538: Vista has five frame button states
- if (ThemeReader.getInt(Control.WINDOW.toString(),
- Part.WP_CLOSEBUTTON.getValue(), 1,
- Prop.IMAGECOUNT.getValue()) == 10) {
- frameButtonStates = new State[] {
- NORMAL, HOT, PUSHED, DISABLED, null,
- INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
- };
- }
-
- stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
- stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
- stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
- stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates);
-
- // States for Slider (trackbar)
- stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
- stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL });
-
- State[] sliderThumbStates =
- new State[] { NORMAL, HOT, PRESSED, FOCUSED, DISABLED };
- stateMap.put(Part.TKP_THUMB, sliderThumbStates);
- stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates);
- stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates);
- stateMap.put(Part.TKP_THUMBVERT, sliderThumbStates);
- stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates);
-
- // States for Tabs
- State[] tabStates = new State[] { NORMAL, HOT, SELECTED, DISABLED, FOCUSED };
- stateMap.put(Part.TABP_TABITEM, tabStates);
- stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates);
- stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates);
-
-
- stateMap.put(Part.TP_BUTTON,
- new State[] {
- NORMAL, HOT, PRESSED, DISABLED, CHECKED, HOTCHECKED
- });
-
- State[] frameStates = new State[] { ACTIVE, INACTIVE };
- stateMap.put(Part.WP_WINDOW, frameStates);
- stateMap.put(Part.WP_FRAMELEFT, frameStates);
- stateMap.put(Part.WP_FRAMERIGHT, frameStates);
- stateMap.put(Part.WP_FRAMEBOTTOM, frameStates);
-
- State[] captionStates = new State[] { ACTIVE, INACTIVE, DISABLED };
- stateMap.put(Part.WP_CAPTION, captionStates);
- stateMap.put(Part.WP_MINCAPTION, captionStates);
- stateMap.put(Part.WP_MAXCAPTION, captionStates);
-
- stateMap.put(Part.MP_BARBACKGROUND,
- new State[] { ACTIVE, INACTIVE });
- stateMap.put(Part.MP_BARITEM,
- new State[] { NORMAL, HOT, PUSHED,
- DISABLED, DISABLEDHOT, DISABLEDPUSHED });
- stateMap.put(Part.MP_POPUPCHECK,
- new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
- BULLETNORMAL, BULLETDISABLED });
- stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
- new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
- stateMap.put(Part.MP_POPUPITEM,
- new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT });
- stateMap.put(Part.MP_POPUPSUBMENU,
- new State[] { NORMAL, DISABLED });
-
- }
-
-
- public static synchronized int getValue(Part part, State state) {
- if (stateMap == null) {
- initStates();
- }
-
- Enum<?>[] states = stateMap.get(part);
- if (states != null) {
- for (int i = 0; i < states.length; i++) {
- if (state == states[i]) {
- return i + 1;
- }
- }
- }
-
- if (state == null || state == State.NORMAL) {
- return 1;
- }
-
- return 0;
- }
-
- }
-
-
- /**
- * An enumeration of the possible component attributes and the
- * corresponding value type
- */
- public static enum Prop {
- COLOR(Color.class, 204),
- SIZE(Dimension.class, 207),
-
- FLATMENUS(Boolean.class, 1001),
-
- BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
-
- IMAGECOUNT(Integer.class, 2401), // the number of state images in an imagefile
- BORDERSIZE(Integer.class, 2403), // the size of the border line for bgtype=BorderFill
-
- PROGRESSCHUNKSIZE(Integer.class, 2411), // size of progress control chunks
- PROGRESSSPACESIZE(Integer.class, 2412), // size of progress control spaces
-
- TEXTSHADOWOFFSET(Point.class, 3402), // where char shadows are drawn, relative to orig. chars
-
- NORMALSIZE(Dimension.class, 3409), // size of dest rect that exactly source
-
-
- SIZINGMARGINS ( Insets.class, 3601), // margins used for 9-grid sizing
- CONTENTMARGINS(Insets.class, 3602), // margins that define where content can be placed
- CAPTIONMARGINS(Insets.class, 3603), // margins that define where caption text can be placed
-
- BORDERCOLOR(Color.class, 3801), // color of borders for BorderFill
- FILLCOLOR ( Color.class, 3802), // color of bg fill
- TEXTCOLOR ( Color.class, 3803), // color text is drawn in
-
- TEXTSHADOWCOLOR(Color.class, 3818), // color of text shadow
-
- BGTYPE(Integer.class, 4001), // basic drawing type for each part
-
- TEXTSHADOWTYPE(Integer.class, 4010), // type of shadow to draw with text
-
- TRANSITIONDURATIONS(Integer.class, 6000);
-
- private final Class<?> type;
- private final int value;
-
- private Prop(Class<?> type, int value) {
- this.type = type;
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
-
- public String toString() {
- return name()+"["+type.getName()+"] = "+value;
- }
- }
-
-
- /**
- * An enumeration of attribute values for some Props
- */
- public static enum TypeEnum {
- BT_IMAGEFILE (Prop.BGTYPE, "imagefile", 0),
- BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1),
-
- TST_NONE(Prop.TEXTSHADOWTYPE, "none", 0),
- TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1),
- TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2);
-
-
- private TypeEnum(Prop prop, String enumName, int value) {
- this.prop = prop;
- this.enumName = enumName;
- this.value = value;
- }
-
- private final Prop prop;
- private final String enumName;
- private final int value;
-
- public String toString() {
- return prop+"="+enumName+"="+value;
- }
-
- String getName() {
- return enumName;
- }
-
-
- static TypeEnum getTypeEnum(Prop prop, int enumval) {
- for (TypeEnum e : TypeEnum.values()) {
- if (e.prop == prop && e.value == enumval) {
- return e;
- }
- }
- return null;
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-
-import java.awt.Component;
-import java.awt.Insets;
-import java.awt.Color;
-import java.awt.Graphics;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-/**
- * Factory object that can vend Borders appropriate for the Windows 95 {@literal L & F}.
- * @author Rich Schiavi
- */
-
-public class WindowsBorders {
-
- /**
- * Returns a border instance for a Windows Progress Bar
- * @since 1.4
- */
- public static Border getProgressBarBorder() {
- UIDefaults table = UIManager.getLookAndFeelDefaults();
- Border progressBarBorder = new BorderUIResource.CompoundBorderUIResource(
- new WindowsBorders.ProgressBarBorder(
- table.getColor("ProgressBar.shadow"),
- table.getColor("ProgressBar.highlight")),
- new EmptyBorder(1,1,1,1)
- );
- return progressBarBorder;
- }
-
- /**
- * Returns a border instance for a Windows ToolBar
- *
- * @return a border used for the toolbar
- * @since 1.4
- */
- public static Border getToolBarBorder() {
- UIDefaults table = UIManager.getLookAndFeelDefaults();
- Border toolBarBorder = new WindowsBorders.ToolBarBorder(
- table.getColor("ToolBar.shadow"),
- table.getColor("ToolBar.highlight"));
- return toolBarBorder;
- }
-
- /**
- * Returns an new instance of a border used to indicate which cell item
- * has focus.
- *
- * @return a border to indicate which cell item has focus
- * @since 1.4
- */
- public static Border getFocusCellHighlightBorder() {
- return new ComplementDashedBorder();
- }
-
- public static Border getTableHeaderBorder() {
- UIDefaults table = UIManager.getLookAndFeelDefaults();
- Border tableHeaderBorder = new BorderUIResource.CompoundBorderUIResource(
- new BasicBorders.ButtonBorder(
- table.getColor("Table.shadow"),
- table.getColor("Table.darkShadow"),
- table.getColor("Table.light"),
- table.getColor("Table.highlight")),
- new BasicBorders.MarginBorder());
- return tableHeaderBorder;
- }
-
- public static Border getInternalFrameBorder() {
- UIDefaults table = UIManager.getLookAndFeelDefaults();
- Border internalFrameBorder = new
- BorderUIResource.CompoundBorderUIResource(
- BorderFactory.createBevelBorder(BevelBorder.RAISED,
- table.getColor("InternalFrame.borderColor"),
- table.getColor("InternalFrame.borderHighlight"),
- table.getColor("InternalFrame.borderDarkShadow"),
- table.getColor("InternalFrame.borderShadow")),
- new WindowsBorders.InternalFrameLineBorder(
- table.getColor("InternalFrame.activeBorderColor"),
- table.getColor("InternalFrame.inactiveBorderColor"),
- table.getInt("InternalFrame.borderWidth")));
-
- return internalFrameBorder;
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public static class ProgressBarBorder extends AbstractBorder implements UIResource {
- protected Color shadow;
- protected Color highlight;
-
- public ProgressBarBorder(Color shadow, Color highlight) {
- this.highlight = highlight;
- this.shadow = shadow;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y,
- int width, int height) {
- g.setColor(shadow);
- g.drawLine(x,y, width-1,y); // draw top
- g.drawLine(x,y, x,height-1); // draw left
- g.setColor(highlight);
- g.drawLine(x,height-1, width-1,height-1); // draw bottom
- g.drawLine(width-1,y, width-1,height-1); // draw right
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- insets.set(1,1,1,1);
- return insets;
- }
- }
-
- /**
- * A border for the ToolBar. If the ToolBar is floatable then the handle grip is drawn
- *
- * @since 1.4
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
- protected Color shadow;
- protected Color highlight;
-
- public ToolBarBorder(Color shadow, Color highlight) {
- this.highlight = highlight;
- this.shadow = shadow;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y,
- int width, int height) {
- if (!(c instanceof JToolBar)) {
- return;
- }
- g.translate(x, y);
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Border xpBorder = xp.getBorder(c, Part.TP_TOOLBAR);
- if (xpBorder != null) {
- xpBorder.paintBorder(c, g, 0, 0, width, height);
- }
- }
- if (((JToolBar)c).isFloatable()) {
- boolean vertical = ((JToolBar)c).getOrientation() == VERTICAL;
-
- if (xp != null) {
- Part part = vertical ? Part.RP_GRIPPERVERT : Part.RP_GRIPPER;
- Skin skin = xp.getSkin(c, part);
- int dx, dy, dw, dh;
- if (vertical) {
- dx = 0;
- dy = 2;
- dw = width - 1;
- dh = skin.getHeight();
- } else {
- dw = skin.getWidth();
- dh = height - 1;
- dx = c.getComponentOrientation().isLeftToRight() ? 2 : (width-dw-2);
- dy = 0;
- }
- skin.paintSkin(g, dx, dy, dw, dh, State.NORMAL);
-
- } else {
-
- if (!vertical) {
- if (c.getComponentOrientation().isLeftToRight()) {
- g.setColor(shadow);
- g.drawLine(4, 3, 4, height - 4);
- g.drawLine(4, height - 4, 2, height - 4);
-
- g.setColor(highlight);
- g.drawLine(2, 3, 3, 3);
- g.drawLine(2, 3, 2, height - 5);
- } else {
- g.setColor(shadow);
- g.drawLine(width - 3, 3, width - 3, height - 4);
- g.drawLine(width - 4, height - 4, width - 4, height - 4);
-
- g.setColor(highlight);
- g.drawLine(width - 5, 3, width - 4, 3);
- g.drawLine(width - 5, 3, width - 5, height - 5);
- }
- } else { // Vertical
- g.setColor(shadow);
- g.drawLine(3, 4, width - 4, 4);
- g.drawLine(width - 4, 2, width - 4, 4);
-
- g.setColor(highlight);
- g.drawLine(3, 2, width - 4, 2);
- g.drawLine(3, 2, 3, 3);
- }
- }
- }
-
- g.translate(-x, -y);
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- insets.set(1,1,1,1);
- if (!(c instanceof JToolBar)) {
- return insets;
- }
- if (((JToolBar)c).isFloatable()) {
- int gripInset = (XPStyle.getXP() != null) ? 12 : 9;
- if (((JToolBar)c).getOrientation() == HORIZONTAL) {
- if (c.getComponentOrientation().isLeftToRight()) {
- insets.left = gripInset;
- } else {
- insets.right = gripInset;
- }
- } else {
- insets.top = gripInset;
- }
- }
- return insets;
- }
- }
-
- /**
- * This class is an implementation of a dashed border.
- * @since 1.4
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public static class DashedBorder extends LineBorder implements UIResource {
- public DashedBorder(Color color) {
- super(color);
- }
-
- public DashedBorder(Color color, int thickness) {
- super(color, thickness);
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- Color oldColor = g.getColor();
- int i;
-
- g.setColor(lineColor);
- for(i = 0; i < thickness; i++) {
- BasicGraphicsUtils.drawDashedRect(g, x+i, y+i, width-i-i, height-i-i);
- }
- g.setColor(oldColor);
- }
- }
-
- /**
- * A dashed border that paints itself in the complementary color
- * of the component's background color.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- static class ComplementDashedBorder extends LineBorder implements UIResource {
- private Color origColor;
- private Color paintColor;
-
- public ComplementDashedBorder() {
- super(null);
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- Color color = c.getBackground();
-
- if (origColor != color) {
- origColor = color;
- paintColor = new Color(~origColor.getRGB());
- }
-
- g.setColor(paintColor);
- BasicGraphicsUtils.drawDashedRect(g, x, y, width, height);
- }
- }
-
- /**
- * This class is an implementation of the InternalFrameLine border.
- * @since 1.4
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public static class InternalFrameLineBorder extends LineBorder implements
- UIResource {
- protected Color activeColor;
- protected Color inactiveColor;
-
- public InternalFrameLineBorder(Color activeBorderColor,
- Color inactiveBorderColor,
- int thickness) {
- super(activeBorderColor, thickness);
- activeColor = activeBorderColor;
- inactiveColor = inactiveBorderColor;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y,
- int width, int height) {
-
- JInternalFrame jif = null;
- if (c instanceof JInternalFrame) {
- jif = (JInternalFrame)c;
- } else if (c instanceof JInternalFrame.JDesktopIcon) {
- jif = ((JInternalFrame.JDesktopIcon)c).getInternalFrame();
- } else {
- return;
- }
-
- if (jif.isSelected()) {
- // Set the line color so the line border gets the correct
- // color.
- lineColor = activeColor;
- super.paintBorder(c, g, x, y, width, height);
- } else {
- lineColor = inactiveColor;
- super.paintBorder(c, g, x, y, width, height);
- }
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonListener.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.java.swing.plaf.windows;
-
-import java.beans.PropertyChangeEvent;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.*;
-
-/**
- * Button Listener
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Rich Schiavi
- */
-public class WindowsButtonListener extends BasicButtonListener {
- public WindowsButtonListener(AbstractButton b) {
- super(b);
- }
- /*
- This class is currently not used, but exists in case customers
- were subclassing it.
- */
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,321 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.border.*;
-import javax.swing.plaf.*;
-import javax.swing.*;
-
-import java.awt.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.TMSchema.Part.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-import sun.awt.AppContext;
-
-
-/**
- * Windows button.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Jeff Dinkins
- *
- */
-public class WindowsButtonUI extends BasicButtonUI
-{
- protected int dashedRectGapX;
- protected int dashedRectGapY;
- protected int dashedRectGapWidth;
- protected int dashedRectGapHeight;
-
- protected Color focusColor;
-
- private boolean defaults_initialized = false;
-
- private static final Object WINDOWS_BUTTON_UI_KEY = new Object();
-
- // ********************************
- // Create PLAF
- // ********************************
- public static ComponentUI createUI(JComponent c) {
- AppContext appContext = AppContext.getAppContext();
- WindowsButtonUI windowsButtonUI =
- (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
- if (windowsButtonUI == null) {
- windowsButtonUI = new WindowsButtonUI();
- appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
- }
- return windowsButtonUI;
- }
-
-
- // ********************************
- // Defaults
- // ********************************
- protected void installDefaults(AbstractButton b) {
- super.installDefaults(b);
- if(!defaults_initialized) {
- String pp = getPropertyPrefix();
- dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
- dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
- dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
- dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
- focusColor = UIManager.getColor(pp + "focus");
- defaults_initialized = true;
- }
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- b.setBorder(xp.getBorder(b, getXPButtonType(b)));
- LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
- }
- }
-
- protected void uninstallDefaults(AbstractButton b) {
- super.uninstallDefaults(b);
- defaults_initialized = false;
- }
-
- protected Color getFocusColor() {
- return focusColor;
- }
-
- // ********************************
- // Paint Methods
- // ********************************
-
- /**
- * Overridden method to render the text without the mnemonic
- */
- protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
- WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
- }
-
- protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
-
- // focus painted same color as text on Basic??
- int width = b.getWidth();
- int height = b.getHeight();
- g.setColor(getFocusColor());
- BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
- width - dashedRectGapWidth, height - dashedRectGapHeight);
- }
-
- protected void paintButtonPressed(Graphics g, AbstractButton b){
- setTextShiftOffset();
- }
-
- // ********************************
- // Layout Methods
- // ********************************
- public Dimension getPreferredSize(JComponent c) {
- Dimension d = super.getPreferredSize(c);
-
- /* Ensure that the width and height of the button is odd,
- * to allow for the focus line if focus is painted
- */
- AbstractButton b = (AbstractButton)c;
- if (d != null && b.isFocusPainted()) {
- if(d.width % 2 == 0) { d.width += 1; }
- if(d.height % 2 == 0) { d.height += 1; }
- }
- return d;
- }
-
-
- /* These rectangles/insets are allocated once for all
- * ButtonUI.paint() calls. Re-using rectangles rather than
- * allocating them in each paint call substantially reduced the time
- * it took paint to run. Obviously, this method can't be re-entered.
- */
- private Rectangle viewRect = new Rectangle();
-
- public void paint(Graphics g, JComponent c) {
- if (XPStyle.getXP() != null) {
- WindowsButtonUI.paintXPButtonBackground(g, c);
- }
- super.paint(g, c);
- }
-
- static Part getXPButtonType(AbstractButton b) {
- if(b instanceof JCheckBox) {
- return Part.BP_CHECKBOX;
- }
- if(b instanceof JRadioButton) {
- return Part.BP_RADIOBUTTON;
- }
- boolean toolbar = (b.getParent() instanceof JToolBar);
- return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON;
- }
-
- static State getXPButtonState(AbstractButton b) {
- Part part = getXPButtonType(b);
- ButtonModel model = b.getModel();
- State state = State.NORMAL;
- switch (part) {
- case BP_RADIOBUTTON:
- /* falls through */
- case BP_CHECKBOX:
- if (! model.isEnabled()) {
- state = (model.isSelected()) ? State.CHECKEDDISABLED
- : State.UNCHECKEDDISABLED;
- } else if (model.isPressed() && model.isArmed()) {
- state = (model.isSelected()) ? State.CHECKEDPRESSED
- : State.UNCHECKEDPRESSED;
- } else if (model.isRollover()) {
- state = (model.isSelected()) ? State.CHECKEDHOT
- : State.UNCHECKEDHOT;
- } else {
- state = (model.isSelected()) ? State.CHECKEDNORMAL
- : State.UNCHECKEDNORMAL;
- }
- break;
- case BP_PUSHBUTTON:
- /* falls through */
- case TP_BUTTON:
- boolean toolbar = (b.getParent() instanceof JToolBar);
- if (toolbar) {
- if (model.isArmed() && model.isPressed()) {
- state = State.PRESSED;
- } else if (!model.isEnabled()) {
- state = State.DISABLED;
- } else if (model.isSelected() && model.isRollover()) {
- state = State.HOTCHECKED;
- } else if (model.isSelected()) {
- state = State.CHECKED;
- } else if (model.isRollover()) {
- state = State.HOT;
- } else if (b.hasFocus()) {
- state = State.HOT;
- }
- } else {
- if ((model.isArmed() && model.isPressed())
- || model.isSelected()) {
- state = State.PRESSED;
- } else if (!model.isEnabled()) {
- state = State.DISABLED;
- } else if (model.isRollover() || model.isPressed()) {
- state = State.HOT;
- } else if (b instanceof JButton
- && ((JButton)b).isDefaultButton()) {
- state = State.DEFAULTED;
- } else if (b.hasFocus()) {
- state = State.HOT;
- }
- }
- break;
- default :
- state = State.NORMAL;
- }
-
- return state;
- }
-
- static void paintXPButtonBackground(Graphics g, JComponent c) {
- AbstractButton b = (AbstractButton)c;
-
- XPStyle xp = XPStyle.getXP();
-
- Part part = getXPButtonType(b);
-
- if (b.isContentAreaFilled() && b.getBorder() != null
- && b.isBorderPainted() && xp != null) {
-
- Skin skin = xp.getSkin(b, part);
-
- State state = getXPButtonState(b);
- Dimension d = c.getSize();
- int dx = 0;
- int dy = 0;
- int dw = d.width;
- int dh = d.height;
-
- Border border = c.getBorder();
- Insets insets;
- if (border != null) {
- // Note: The border may be compound, containing an outer
- // opaque border (supplied by the application), plus an
- // inner transparent margin border. We want to size the
- // background to fill the transparent part, but stay
- // inside the opaque part.
- insets = WindowsButtonUI.getOpaqueInsets(border, c);
- } else {
- insets = c.getInsets();
- }
- if (insets != null) {
- dx += insets.left;
- dy += insets.top;
- dw -= (insets.left + insets.right);
- dh -= (insets.top + insets.bottom);
- }
- skin.paintSkin(g, dx, dy, dw, dh, state);
- }
- }
-
- /**
- * returns - b.getBorderInsets(c) if border is opaque
- * - null if border is completely non-opaque
- * - somewhere inbetween if border is compound and
- * outside border is opaque and inside isn't
- */
- private static Insets getOpaqueInsets(Border b, Component c) {
- if (b == null) {
- return null;
- }
- if (b.isBorderOpaque()) {
- return b.getBorderInsets(c);
- } else if (b instanceof CompoundBorder) {
- CompoundBorder cb = (CompoundBorder)b;
- Insets iOut = getOpaqueInsets(cb.getOutsideBorder(), c);
- if (iOut != null && iOut.equals(cb.getOutsideBorder().getBorderInsets(c))) {
- // Outside border is opaque, keep looking
- Insets iIn = getOpaqueInsets(cb.getInsideBorder(), c);
- if (iIn == null) {
- // Inside is non-opaque, use outside insets
- return iOut;
- } else {
- // Found non-opaque somewhere in the inside (which is
- // also compound).
- return new Insets(iOut.top + iIn.top, iOut.left + iIn.left,
- iOut.bottom + iIn.bottom, iOut.right + iIn.right);
- }
- } else {
- // Outside is either all non-opaque or has non-opaque
- // border inside another compound border
- return iOut;
- }
- } else {
- return null;
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-
-
-/**
- * Windows check box menu item.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
-
- final WindowsMenuItemUIAccessor accessor =
- new WindowsMenuItemUIAccessor() {
-
- public JMenuItem getMenuItem() {
- return menuItem;
- }
-
- public State getState(JMenuItem menuItem) {
- return WindowsMenuItemUI.getState(this, menuItem);
- }
-
- public Part getPart(JMenuItem menuItem) {
- return WindowsMenuItemUI.getPart(this, menuItem);
- }
- };
- public static ComponentUI createUI(JComponent b) {
- return new WindowsCheckBoxMenuItemUI();
- }
-
- @Override
- protected void paintBackground(Graphics g, JMenuItem menuItem,
- Color bgColor) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
- return;
- }
- super.paintBackground(g, menuItem, bgColor);
- }
- /**
- * Method which renders the text of the current menu item.
- *
- * @param g Graphics context
- * @param menuItem Current menu item to render
- * @param textRect Bounding rectangle to render the text.
- * @param text String to render
- * @since 1.4
- */
- protected void paintText(Graphics g, JMenuItem menuItem,
- Rectangle textRect, String text) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintText(accessor, g, menuItem,
- textRect, text);
- return;
- }
- ButtonModel model = menuItem.getModel();
- Color oldColor = g.getColor();
-
- if(model.isEnabled() && model.isArmed()) {
- g.setColor(selectionForeground); // Uses protected field.
- }
-
- WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
-
- g.setColor(oldColor);
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.awt.AppContext;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-
-import java.awt.*;
-
-/**
- * Windows check box.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Jeff Dinkins
- */
-public class WindowsCheckBoxUI extends WindowsRadioButtonUI
-{
- // NOTE: MetalCheckBoxUI inherts from MetalRadioButtonUI instead
- // of BasicCheckBoxUI because we want to pick up all the
- // painting changes made in MetalRadioButtonUI.
-
- private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object();
-
- private static final String propertyPrefix = "CheckBox" + ".";
-
- private boolean defaults_initialized = false;
-
- // ********************************
- // Create PLAF
- // ********************************
- public static ComponentUI createUI(JComponent c) {
- AppContext appContext = AppContext.getAppContext();
- WindowsCheckBoxUI windowsCheckBoxUI =
- (WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY);
- if (windowsCheckBoxUI == null) {
- windowsCheckBoxUI = new WindowsCheckBoxUI();
- appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI);
- }
- return windowsCheckBoxUI;
- }
-
-
- public String getPropertyPrefix() {
- return propertyPrefix;
- }
-
- // ********************************
- // Defaults
- // ********************************
- public void installDefaults(AbstractButton b) {
- super.installDefaults(b);
- if(!defaults_initialized) {
- icon = UIManager.getIcon(getPropertyPrefix() + "icon");
- defaults_initialized = true;
- }
- }
-
- public void uninstallDefaults(AbstractButton b) {
- super.uninstallDefaults(b);
- defaults_initialized = false;
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-/**
- * Implements the Windows95/98/ME/NT/2000 Look and Feel.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @since 1.5
- */
-@SuppressWarnings("serial") // Superclass is not serializable across versions
-public class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
- public String getName() {
- return "Windows Classic";
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,665 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.*;
-import javax.swing.border.*;
-import javax.swing.*;
-import java.awt.event.*;
-import java.awt.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.Part;
-import static com.sun.java.swing.plaf.windows.TMSchema.State;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-import sun.swing.DefaultLookup;
-import sun.swing.StringUIClientPropertyKey;
-
-import com.sun.java.swing.plaf.windows.WindowsBorders.DashedBorder;
-
-/**
- * Windows combo box.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Tom Santos
- * @author Igor Kushnirskiy
- */
-
-public class WindowsComboBoxUI extends BasicComboBoxUI {
-
- private static final MouseListener rolloverListener =
- new MouseAdapter() {
- private void handleRollover(MouseEvent e, boolean isRollover) {
- JComboBox<?> comboBox = getComboBox(e);
- WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
- if (comboBox == null || comboBoxUI == null) {
- return;
- }
- if (! comboBox.isEditable()) {
- //mouse over editable ComboBox does not switch rollover
- //for the arrow button
- ButtonModel m = null;
- if (comboBoxUI.arrowButton != null) {
- m = comboBoxUI.arrowButton.getModel();
- }
- if (m != null ) {
- m.setRollover(isRollover);
- }
- }
- comboBoxUI.isRollover = isRollover;
- comboBox.repaint();
- }
-
- public void mouseEntered(MouseEvent e) {
- handleRollover(e, true);
- }
-
- public void mouseExited(MouseEvent e) {
- handleRollover(e, false);
- }
-
- private JComboBox<?> getComboBox(MouseEvent event) {
- Object source = event.getSource();
- JComboBox<?> rv = null;
- if (source instanceof JComboBox) {
- rv = (JComboBox) source;
- } else if (source instanceof XPComboBoxButton) {
- rv = ((XPComboBoxButton) source)
- .getWindowsComboBoxUI().comboBox;
- } else if (source instanceof JTextField &&
- ((JTextField) source).getParent() instanceof JComboBox) {
- rv = (JComboBox) ((JTextField) source).getParent();
- }
- return rv;
- }
-
- private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
- JComboBox<?> comboBox = getComboBox(event);
- WindowsComboBoxUI rv = null;
- if (comboBox != null
- && comboBox.getUI() instanceof WindowsComboBoxUI) {
- rv = (WindowsComboBoxUI) comboBox.getUI();
- }
- return rv;
- }
-
- };
- private boolean isRollover = false;
-
- private static final PropertyChangeListener componentOrientationListener =
- new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent e) {
- String propertyName = e.getPropertyName();
- Object source = null;
- if ("componentOrientation" == propertyName
- && (source = e.getSource()) instanceof JComboBox
- && ((JComboBox) source).getUI() instanceof
- WindowsComboBoxUI) {
- JComboBox<?> comboBox = (JComboBox) source;
- WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
- if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
- ((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
- (comboBox.getComponentOrientation() ==
- ComponentOrientation.RIGHT_TO_LEFT)
- ? Part.CP_DROPDOWNBUTTONLEFT
- : Part.CP_DROPDOWNBUTTONRIGHT);
- }
- }
- }
- };
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsComboBoxUI();
- }
-
- public void installUI( JComponent c ) {
- super.installUI( c );
- isRollover = false;
- comboBox.setRequestFocusEnabled( true );
- if (XPStyle.getXP() != null && arrowButton != null) {
- //we can not do it in installListeners because arrowButton
- //is initialized after installListeners is invoked
- comboBox.addMouseListener(rolloverListener);
- arrowButton.addMouseListener(rolloverListener);
- // set empty border as default to see vista animated border
- comboBox.setBorder(new EmptyBorder(0,0,0,0));
- }
- }
-
- public void uninstallUI(JComponent c ) {
- comboBox.removeMouseListener(rolloverListener);
- if(arrowButton != null) {
- arrowButton.removeMouseListener(rolloverListener);
- }
- super.uninstallUI( c );
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- @Override
- protected void installListeners() {
- super.installListeners();
- XPStyle xp = XPStyle.getXP();
- //button glyph for LTR and RTL combobox might differ
- if (xp != null
- && xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) {
- comboBox.addPropertyChangeListener("componentOrientation",
- componentOrientationListener);
- }
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- @Override
- protected void uninstallListeners() {
- super.uninstallListeners();
- comboBox.removePropertyChangeListener("componentOrientation",
- componentOrientationListener);
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected void configureEditor() {
- super.configureEditor();
- if (XPStyle.getXP() != null) {
- editor.addMouseListener(rolloverListener);
- }
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected void unconfigureEditor() {
- super.unconfigureEditor();
- editor.removeMouseListener(rolloverListener);
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- public void paint(Graphics g, JComponent c) {
- if (XPStyle.getXP() != null) {
- paintXPComboBoxBackground(g, c);
- }
- super.paint(g, c);
- }
-
- State getXPComboBoxState(JComponent c) {
- State state = State.NORMAL;
- if (!c.isEnabled()) {
- state = State.DISABLED;
- } else if (isPopupVisible(comboBox)) {
- state = State.PRESSED;
- } else if (comboBox.isEditable()
- && comboBox.getEditor().getEditorComponent().isFocusOwner()) {
- state = State.PRESSED;
- } else if (isRollover) {
- state = State.HOT;
- }
- return state;
- }
-
- private void paintXPComboBoxBackground(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (xp == null) {
- return;
- }
- State state = getXPComboBoxState(c);
- Skin skin = null;
- if (! comboBox.isEditable()
- && xp.isSkinDefined(c, Part.CP_READONLY)) {
- skin = xp.getSkin(c, Part.CP_READONLY);
- }
- if (skin == null) {
- skin = xp.getSkin(c, Part.CP_BORDER);
- }
- skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
- }
-
- /**
- * If necessary paints the currently selected item.
- *
- * @param g Graphics to paint to
- * @param bounds Region to paint current value to
- * @param hasFocus whether or not the JComboBox has focus
- * @throws NullPointerException if any of the arguments are null.
- * @since 1.5
- */
- public void paintCurrentValue(Graphics g, Rectangle bounds,
- boolean hasFocus) {
- XPStyle xp = XPStyle.getXP();
- if ( xp != null) {
- bounds.x += 2;
- bounds.y += 2;
- bounds.width -= 4;
- bounds.height -= 4;
- } else {
- bounds.x += 1;
- bounds.y += 1;
- bounds.width -= 2;
- bounds.height -= 2;
- }
- if (! comboBox.isEditable()
- && xp != null
- && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
- // On vista for READNLY ComboBox
- // color for currentValue is the same as for any other item
-
- // mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
- ListCellRenderer<Object> renderer = comboBox.getRenderer();
- Component c;
- if ( hasFocus && !isPopupVisible(comboBox) ) {
- c = renderer.getListCellRendererComponent(
- listBox,
- comboBox.getSelectedItem(),
- -1,
- true,
- false );
- } else {
- c = renderer.getListCellRendererComponent(
- listBox,
- comboBox.getSelectedItem(),
- -1,
- false,
- false );
- }
- c.setFont(comboBox.getFont());
- if ( comboBox.isEnabled() ) {
- c.setForeground(comboBox.getForeground());
- c.setBackground(comboBox.getBackground());
- } else {
- c.setForeground(DefaultLookup.getColor(
- comboBox, this, "ComboBox.disabledForeground", null));
- c.setBackground(DefaultLookup.getColor(
- comboBox, this, "ComboBox.disabledBackground", null));
- }
- boolean shouldValidate = false;
- if (c instanceof JPanel) {
- shouldValidate = true;
- }
- currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y,
- bounds.width, bounds.height, shouldValidate);
-
- } else {
- super.paintCurrentValue(g, bounds, hasFocus);
- }
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- public void paintCurrentValueBackground(Graphics g, Rectangle bounds,
- boolean hasFocus) {
- if (XPStyle.getXP() == null) {
- super.paintCurrentValueBackground(g, bounds, hasFocus);
- }
- }
-
- public Dimension getMinimumSize( JComponent c ) {
- Dimension d = super.getMinimumSize(c);
- if (XPStyle.getXP() != null) {
- d.width += 7;
- boolean isEditable = false;
- if (c instanceof JComboBox) {
- isEditable = ((JComboBox) c).isEditable();
- }
- d.height += isEditable ? 4 : 6;
- } else {
- d.width += 4;
- d.height += 2;
- }
- return d;
- }
-
- /**
- * Creates a layout manager for managing the components which make up the
- * combo box.
- *
- * @return an instance of a layout manager
- */
- protected LayoutManager createLayoutManager() {
- return new BasicComboBoxUI.ComboBoxLayoutManager() {
- public void layoutContainer(Container parent) {
- super.layoutContainer(parent);
-
- if (XPStyle.getXP() != null && arrowButton != null) {
- Dimension d = parent.getSize();
- Insets insets = getInsets();
- int buttonWidth = arrowButton.getPreferredSize().width;
- arrowButton.setBounds(WindowsGraphicsUtils.isLeftToRight((JComboBox)parent)
- ? (d.width - insets.right - buttonWidth)
- : insets.left,
- insets.top,
- buttonWidth, d.height - insets.top - insets.bottom);
- }
- }
- };
- }
-
- protected void installKeyboardActions() {
- super.installKeyboardActions();
- }
-
- protected ComboPopup createPopup() {
- return new WinComboPopUp(comboBox);
- }
-
- /**
- * Creates the default editor that will be used in editable combo boxes.
- * A default editor will be used only if an editor has not been
- * explicitly set with <code>setEditor</code>.
- *
- * @return a <code>ComboBoxEditor</code> used for the combo box
- * @see javax.swing.JComboBox#setEditor
- */
- protected ComboBoxEditor createEditor() {
- return new WindowsComboBoxEditor();
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- @Override
- protected ListCellRenderer<Object> createRenderer() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
- return new WindowsComboBoxRenderer();
- } else {
- return super.createRenderer();
- }
- }
-
- /**
- * Creates an button which will be used as the control to show or hide
- * the popup portion of the combo box.
- *
- * @return a button which represents the popup control
- */
- protected JButton createArrowButton() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return new XPComboBoxButton(xp);
- } else {
- return super.createArrowButton();
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPComboBoxButton extends XPStyle.GlyphButton {
- private State prevState = null;
-
- public XPComboBoxButton(XPStyle xp) {
- super(comboBox,
- (! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
- ? Part.CP_DROPDOWNBUTTON
- : (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
- ? Part.CP_DROPDOWNBUTTONLEFT
- : Part.CP_DROPDOWNBUTTONRIGHT
- );
- setRequestFocusEnabled(false);
- }
-
- @Override
- protected State getState() {
- State rv;
-
- getModel().setPressed(comboBox.isPopupVisible());
-
- rv = super.getState();
- XPStyle xp = XPStyle.getXP();
- if (rv != State.DISABLED
- && comboBox != null && ! comboBox.isEditable()
- && xp != null && xp.isSkinDefined(comboBox,
- Part.CP_DROPDOWNBUTTONRIGHT)) {
- /*
- * for non editable ComboBoxes Vista seems to have the
- * same glyph for all non DISABLED states
- */
- rv = State.NORMAL;
- }
- if (rv == State.NORMAL && (prevState == State.HOT || prevState == State.PRESSED)) {
- /*
- * State NORMAL of combobox button cannot overpaint states HOT or PRESSED
- * Therefore HOT state must be painted from alpha 1 to 0 and not as usual that
- * NORMAL state is painted from alpha 0 to alpha 1.
- */
- skin.switchStates(true);
- }
- if (rv != prevState) {
- prevState = rv;
- }
-
- return rv;
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(17, 21);
- }
-
- void setPart(Part part) {
- setPart(comboBox, part);
- }
-
- WindowsComboBoxUI getWindowsComboBoxUI() {
- return WindowsComboBoxUI.this;
- }
- }
-
-
- /**
- * Subclassed to add Windows specific Key Bindings.
- * This class is now obsolete and doesn't do anything.
- * Only included for backwards API compatibility.
- * Do not call or override.
- *
- * @deprecated As of Java 2 platform v1.4.
- */
- @Deprecated
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- protected class WindowsComboPopup extends BasicComboPopup {
-
- public WindowsComboPopup( JComboBox<Object> cBox ) {
- super( cBox );
- }
-
- protected KeyListener createKeyListener() {
- return new InvocationKeyHandler();
- }
-
- protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
- protected InvocationKeyHandler() {
- WindowsComboPopup.this.super();
- }
- }
- }
-
- @SuppressWarnings("serial") // Same-version serialization only
- protected class WinComboPopUp extends BasicComboPopup {
- private Skin listBoxBorder = null;
- private XPStyle xp;
-
- public WinComboPopUp(JComboBox<Object> combo) {
- super(combo);
- xp = XPStyle.getXP();
- if (xp != null && xp.isSkinDefined(combo, Part.LBCP_BORDER_NOSCROLL)) {
- this.listBoxBorder = new Skin(combo, Part.LBCP_BORDER_NOSCROLL);
- this.setBorder(new EmptyBorder(1,1,1,1));
- }
- }
-
- protected KeyListener createKeyListener() {
- return new InvocationKeyHandler();
- }
-
- protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
- protected InvocationKeyHandler() {
- WinComboPopUp.this.super();
- }
- }
-
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- if (this.listBoxBorder != null) {
- this.listBoxBorder.paintSkinRaw(g, this.getX(), this.getY(),
- this.getWidth(), this.getHeight(), State.HOT);
- }
- }
- }
-
-
- /**
- * Subclassed to highlight selected item in an editable combo box.
- */
- public static class WindowsComboBoxEditor
- extends BasicComboBoxEditor.UIResource {
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected JTextField createEditorComponent() {
- JTextField editor = super.createEditorComponent();
- Border border = (Border)UIManager.get("ComboBox.editorBorder");
-
- if (border != null) {
- editor.setBorder(border);
- }
- editor.setOpaque(false);
- return editor;
- }
-
- public void setItem(Object item) {
- super.setItem(item);
- Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
- if ((focus == editor) || (focus == editor.getParent())) {
- editor.selectAll();
- }
- }
- }
-
- /**
- * Subclassed to set opacity {@code false} on the renderer
- * and to show border for focused cells.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private static class WindowsComboBoxRenderer
- extends BasicComboBoxRenderer.UIResource {
- private static final Object BORDER_KEY
- = new StringUIClientPropertyKey("BORDER_KEY");
- private static final Border NULL_BORDER = new EmptyBorder(0, 0, 0, 0);
-
- // Create own version of DashedBorder with more space on left side
- private class WindowsComboBoxDashedBorder extends DashedBorder {
-
- public WindowsComboBoxDashedBorder(Color color, int thickness) {
- super(color, thickness);
- }
-
- public WindowsComboBoxDashedBorder(Color color) {
- super(color);
- }
-
- @Override
- public Insets getBorderInsets(Component c, Insets i) {
- return new Insets(0,2,0,0);
- }
- }
-
- public WindowsComboBoxRenderer() {
- super();
-
- // correct space on the left side of text items in the combo popup list
- Insets i = getBorder().getBorderInsets(this);
- setBorder(new EmptyBorder(0, 2, 0, i.right));
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public Component getListCellRendererComponent(
- JList<?> list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
- Component rv =
- super.getListCellRendererComponent(list, value, index,
- isSelected, cellHasFocus);
- if (rv instanceof JComponent) {
- JComponent component = (JComponent) rv;
- if (index == -1 && isSelected) {
- Border border = component.getBorder();
- Border dashedBorder =
- new WindowsComboBoxDashedBorder(list.getForeground());
- component.setBorder(dashedBorder);
- //store current border in client property if needed
- if (component.getClientProperty(BORDER_KEY) == null) {
- component.putClientProperty(BORDER_KEY,
- (border == null) ? NULL_BORDER : border);
- }
- } else {
- if (component.getBorder() instanceof
- WindowsBorders.DashedBorder) {
- Object storedBorder = component.getClientProperty(BORDER_KEY);
- if (storedBorder instanceof Border) {
- component.setBorder(
- (storedBorder == NULL_BORDER) ? null
- : (Border) storedBorder);
- }
- component.putClientProperty(BORDER_KEY, null);
- }
- }
- if (index == -1) {
- component.setOpaque(false);
- component.setForeground(list.getForeground());
- } else {
- component.setOpaque(true);
- }
- }
- return rv;
- }
-
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.border.*;
-
-
-
-/**
- * Windows icon for a minimized window on the desktop.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsDesktopIconUI extends BasicDesktopIconUI {
- private int width;
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsDesktopIconUI();
- }
-
- public void installDefaults() {
- super.installDefaults();
- width = UIManager.getInt("DesktopIcon.width");
- }
-
- public void installUI(JComponent c) {
- super.installUI(c);
-
- c.setOpaque(XPStyle.getXP() == null);
- }
-
- // Uninstall the listeners added by the WindowsInternalFrameTitlePane
- public void uninstallUI(JComponent c) {
- WindowsInternalFrameTitlePane thePane =
- (WindowsInternalFrameTitlePane)iconPane;
- super.uninstallUI(c);
- thePane.uninstallListeners();
- }
-
- protected void installComponents() {
- iconPane = new WindowsInternalFrameTitlePane(frame);
- desktopIcon.setLayout(new BorderLayout());
- desktopIcon.add(iconPane, BorderLayout.CENTER);
-
- if (XPStyle.getXP() != null) {
- desktopIcon.setBorder(null);
- }
- }
-
- public Dimension getPreferredSize(JComponent c) {
- // Windows desktop icons can not be resized. Therefore, we should
- // always return the minimum size of the desktop icon. See
- // getMinimumSize(JComponent c).
- return getMinimumSize(c);
- }
-
- /**
- * Windows desktop icons are restricted to a width of 160 pixels by
- * default. This value is retrieved by the DesktopIcon.width property.
- */
- public Dimension getMinimumSize(JComponent c) {
- Dimension dim = super.getMinimumSize(c);
- dim.width = width;
- return dim;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.DefaultDesktopManager;
-import javax.swing.JInternalFrame;
-import javax.swing.JLayeredPane;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.beans.PropertyVetoException;
-import java.util.Vector;
-import java.lang.ref.WeakReference;
-
-/**
- * This class implements a DesktopManager which more closely follows
- * the MDI model than the DefaultDesktopManager. Unlike the
- * DefaultDesktopManager policy, MDI requires that the selected
- * and activated child frames are the same, and that that frame
- * always be the top-most window.
- * <p>
- * The maximized state is managed by the DesktopManager with MDI,
- * instead of just being a property of the individual child frame.
- * This means that if the currently selected window is maximized
- * and another window is selected, that new window will be maximized.
- *
- * @see javax.swing.DefaultDesktopManager
- * @author Thomas Ball
- */
-@SuppressWarnings("serial") // JDK-implementation class
-public class WindowsDesktopManager extends DefaultDesktopManager
- implements java.io.Serializable, javax.swing.plaf.UIResource {
-
- /* The frame which is currently selected/activated.
- * We store this value to enforce MDI's single-selection model.
- */
- private WeakReference<JInternalFrame> currentFrameRef;
-
- public void activateFrame(JInternalFrame f) {
- JInternalFrame currentFrame = currentFrameRef != null ?
- currentFrameRef.get() : null;
- try {
- super.activateFrame(f);
- if (currentFrame != null && f != currentFrame) {
- // If the current frame is maximized, transfer that
- // attribute to the frame being activated.
- if (!currentFrame.isClosed() && currentFrame.isMaximum() &&
- (f.getClientProperty("JInternalFrame.frameType") !=
- "optionDialog") ) {
- //Special case. If key binding was used to select next
- //frame instead of minimizing the icon via the minimize
- //icon.
- if (!currentFrame.isIcon()) {
- currentFrame.setMaximum(false);
- if (f.isMaximizable()) {
- if (!f.isMaximum()) {
- f.setMaximum(true);
- } else if (f.isMaximum() && f.isIcon()) {
- f.setIcon(false);
- } else {
- f.setMaximum(false);
- }
- }
- }
- }
- if (currentFrame.isSelected()) {
- currentFrame.setSelected(false);
- }
- }
-
- if (!f.isSelected()) {
- f.setSelected(true);
- }
- } catch (PropertyVetoException e) {}
- if (f != currentFrame) {
- currentFrameRef = new WeakReference<JInternalFrame>(f);
- }
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.ComponentUI;
-import java.awt.event.*;
-
-/**
- * Windows desktop pane.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author David Kloba
- */
-public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
-{
- public static ComponentUI createUI(JComponent c) {
- return new WindowsDesktopPaneUI();
- }
-
- protected void installDesktopManager() {
- desktopManager = desktop.getDesktopManager();
- if(desktopManager == null) {
- desktopManager = new WindowsDesktopManager();
- desktop.setDesktopManager(desktopManager);
- }
- }
-
- protected void installDefaults() {
- super.installDefaults();
- }
-
- @SuppressWarnings("deprecation")
- protected void installKeyboardActions() {
- super.installKeyboardActions();
-
- // Request focus if it isn't set.
- if(!desktop.requestDefaultFocus()) {
- desktop.requestFocus();
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopProperty.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.UIManager;
-
-import sun.swing.plaf.DesktopProperty;
-
-/**
- * Wrapper for a value from the desktop. The value is lazily looked up, and
- * can be accessed using the <code>UIManager.ActiveValue</code> method
- * <code>createValue</code>. If the underlying desktop property changes this
- * will force the UIs to update all known Frames. You can invoke
- * <code>invalidate</code> to force the value to be fetched again.
- */
-public class WindowsDesktopProperty extends DesktopProperty {
-
- /**
- * Updates the UIs of all the known Frames.
- */
- @Override
- protected final void updateAllUIs() {
- // Check if the current UI is WindowsLookAndfeel and flush the XP style map.
- // Note: Change the package test if this class is moved to a different package.
- Class<?> uiClass = UIManager.getLookAndFeel().getClass();
- if (uiClass.getPackage().equals(WindowsDesktopProperty.class.getPackage())) {
- XPStyle.invalidateStyle();
- }
- super.updateAllUIs();
- }
-
- /**
- * Creates a WindowsDesktopProperty.
- *
- * @param key Key used in looking up desktop value.
- * @param fallback Value used if desktop property is null.
- */
- public WindowsDesktopProperty(String key, Object fallback) {
- super(key,fallback);
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.text.Caret;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsEditorPaneUI extends BasicEditorPaneUI
-{
-
- /**
- * Creates a UI for a JEditorPane.
- *
- * @param c the configurable text component
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsEditorPaneUI();
- }
-
- /**
- * Creates the object to use for a caret. By default an
- * instance of WindowsCaret is created. This method
- * can be redefined to provide something else that implements
- * the InputPosition interface or a subclass of DefaultCaret.
- *
- * @return the caret object
- */
- protected Caret createCaret() {
- return new WindowsTextUI.WindowsCaret();
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1325 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.filechooser.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.BufferedImage;
-import java.beans.*;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import sun.awt.shell.ShellFolder;
-import sun.swing.*;
-
-import javax.accessibility.*;
-
-/**
- * Windows {@literal L&F} implementation of a FileChooser.
- *
- * @author Jeff Dinkins
- */
-public class WindowsFileChooserUI extends BasicFileChooserUI {
-
- // The following are private because the implementation of the
- // Windows FileChooser L&F is not complete yet.
-
- private JPanel centerPanel;
-
- private JLabel lookInLabel;
- private JComboBox<File> directoryComboBox;
- private DirectoryComboBoxModel directoryComboBoxModel;
- private ActionListener directoryComboBoxAction = new DirectoryComboBoxAction();
-
- private FilterComboBoxModel filterComboBoxModel;
-
- private JTextField filenameTextField;
- private FilePane filePane;
- private WindowsPlacesBar placesBar;
-
- private JButton approveButton;
- private JButton cancelButton;
-
- private JPanel buttonPanel;
- private JPanel bottomPanel;
-
- private JComboBox<FileFilter> filterComboBox;
-
- private static final Dimension hstrut10 = new Dimension(10, 1);
-
- private static final Dimension vstrut4 = new Dimension(1, 4);
- private static final Dimension vstrut6 = new Dimension(1, 6);
- private static final Dimension vstrut8 = new Dimension(1, 8);
-
- private static final Insets shrinkwrap = new Insets(0,0,0,0);
-
- // Preferred and Minimum sizes for the dialog box
- private static int PREF_WIDTH = 425;
- private static int PREF_HEIGHT = 245;
- private static Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT);
-
- private static int MIN_WIDTH = 425;
- private static int MIN_HEIGHT = 245;
-
- private static int LIST_PREF_WIDTH = 444;
- private static int LIST_PREF_HEIGHT = 138;
- private static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
-
- // Labels, mnemonics, and tooltips (oh my!)
- private int lookInLabelMnemonic = 0;
- private String lookInLabelText = null;
- private String saveInLabelText = null;
-
- private int fileNameLabelMnemonic = 0;
- private String fileNameLabelText = null;
- private int folderNameLabelMnemonic = 0;
- private String folderNameLabelText = null;
-
- private int filesOfTypeLabelMnemonic = 0;
- private String filesOfTypeLabelText = null;
-
- private String upFolderToolTipText = null;
- private String upFolderAccessibleName = null;
-
- private String newFolderToolTipText = null;
- private String newFolderAccessibleName = null;
-
- private String viewMenuButtonToolTipText = null;
- private String viewMenuButtonAccessibleName = null;
-
- private BasicFileView fileView = new WindowsFileView();
-
- private JLabel fileNameLabel;
-
- private void populateFileNameLabel() {
- if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
- fileNameLabel.setText(folderNameLabelText);
- fileNameLabel.setDisplayedMnemonic(folderNameLabelMnemonic);
- } else {
- fileNameLabel.setText(fileNameLabelText);
- fileNameLabel.setDisplayedMnemonic(fileNameLabelMnemonic);
- }
- }
-
- //
- // ComponentUI Interface Implementation methods
- //
- public static ComponentUI createUI(JComponent c) {
- return new WindowsFileChooserUI((JFileChooser) c);
- }
-
- public WindowsFileChooserUI(JFileChooser filechooser) {
- super(filechooser);
- }
-
- public void installUI(JComponent c) {
- super.installUI(c);
- }
-
- public void uninstallComponents(JFileChooser fc) {
- fc.removeAll();
- }
-
- private class WindowsFileChooserUIAccessor implements FilePane.FileChooserUIAccessor {
- public JFileChooser getFileChooser() {
- return WindowsFileChooserUI.this.getFileChooser();
- }
-
- public BasicDirectoryModel getModel() {
- return WindowsFileChooserUI.this.getModel();
- }
-
- public JPanel createList() {
- return WindowsFileChooserUI.this.createList(getFileChooser());
- }
-
- public JPanel createDetailsView() {
- return WindowsFileChooserUI.this.createDetailsView(getFileChooser());
- }
-
- public boolean isDirectorySelected() {
- return WindowsFileChooserUI.this.isDirectorySelected();
- }
-
- public File getDirectory() {
- return WindowsFileChooserUI.this.getDirectory();
- }
-
- public Action getChangeToParentDirectoryAction() {
- return WindowsFileChooserUI.this.getChangeToParentDirectoryAction();
- }
-
- public Action getApproveSelectionAction() {
- return WindowsFileChooserUI.this.getApproveSelectionAction();
- }
-
- public Action getNewFolderAction() {
- return WindowsFileChooserUI.this.getNewFolderAction();
- }
-
- public MouseListener createDoubleClickListener(JList<?> list) {
- return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(),
- list);
- }
-
- public ListSelectionListener createListSelectionListener() {
- return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
- }
- }
-
- public void installComponents(JFileChooser fc) {
- filePane = new FilePane(new WindowsFileChooserUIAccessor());
- fc.addPropertyChangeListener(filePane);
-
- FileSystemView fsv = fc.getFileSystemView();
-
- fc.setBorder(new EmptyBorder(4, 10, 10, 10));
- fc.setLayout(new BorderLayout(8, 8));
-
- updateUseShellFolder();
-
- // ********************************* //
- // **** Construct the top panel **** //
- // ********************************* //
-
- // Directory manipulation buttons
- JToolBar topPanel = new JToolBar();
- topPanel.setFloatable(false);
- topPanel.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
-
- // Add the top panel to the fileChooser
- fc.add(topPanel, BorderLayout.NORTH);
-
- // ComboBox Label
- @SuppressWarnings("serial") // anonymous class
- JLabel tmp1 = new JLabel(lookInLabelText, JLabel.TRAILING) {
- public Dimension getPreferredSize() {
- return getMinimumSize();
- }
-
- public Dimension getMinimumSize() {
- Dimension d = super.getPreferredSize();
- if (placesBar != null) {
- d.width = Math.max(d.width, placesBar.getWidth());
- }
- return d;
- }
- };
- lookInLabel = tmp1;
- lookInLabel.setDisplayedMnemonic(lookInLabelMnemonic);
- lookInLabel.setAlignmentX(JComponent.LEFT_ALIGNMENT);
- lookInLabel.setAlignmentY(JComponent.CENTER_ALIGNMENT);
- topPanel.add(lookInLabel);
- topPanel.add(Box.createRigidArea(new Dimension(8,0)));
-
- // CurrentDir ComboBox
- @SuppressWarnings("serial") // anonymous class
- JComboBox<File> tmp2 = new JComboBox<File>() {
- public Dimension getMinimumSize() {
- Dimension d = super.getMinimumSize();
- d.width = 60;
- return d;
- }
-
- public Dimension getPreferredSize() {
- Dimension d = super.getPreferredSize();
- // Must be small enough to not affect total width.
- d.width = 150;
- return d;
- }
- };
- directoryComboBox = tmp2;
- directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
- lookInLabel.setLabelFor(directoryComboBox);
- directoryComboBoxModel = createDirectoryComboBoxModel(fc);
- directoryComboBox.setModel(directoryComboBoxModel);
- directoryComboBox.addActionListener(directoryComboBoxAction);
- directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
- directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
- directoryComboBox.setAlignmentY(JComponent.CENTER_ALIGNMENT);
- directoryComboBox.setMaximumRowCount(8);
-
- topPanel.add(directoryComboBox);
- topPanel.add(Box.createRigidArea(hstrut10));
-
- // Up Button
- JButton upFolderButton = createToolButton(getChangeToParentDirectoryAction(), upFolderIcon,
- upFolderToolTipText, upFolderAccessibleName);
- topPanel.add(upFolderButton);
-
- // New Directory Button
- if (!UIManager.getBoolean("FileChooser.readOnly")) {
- JButton newFolderButton = createToolButton(filePane.getNewFolderAction(), newFolderIcon,
- newFolderToolTipText, newFolderAccessibleName);
- topPanel.add(newFolderButton);
- }
-
- // View button group
- ButtonGroup viewButtonGroup = new ButtonGroup();
-
- // Popup Menu
- final JPopupMenu viewTypePopupMenu = new JPopupMenu();
-
- final JRadioButtonMenuItem listViewMenuItem = new JRadioButtonMenuItem(
- filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
- listViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_LIST);
- viewTypePopupMenu.add(listViewMenuItem);
- viewButtonGroup.add(listViewMenuItem);
-
- final JRadioButtonMenuItem detailsViewMenuItem = new JRadioButtonMenuItem(
- filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
- detailsViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_DETAILS);
- viewTypePopupMenu.add(detailsViewMenuItem);
- viewButtonGroup.add(detailsViewMenuItem);
-
- // Create icon for viewMenuButton
- BufferedImage image = new BufferedImage(viewMenuIcon.getIconWidth() + 7, viewMenuIcon.getIconHeight(),
- BufferedImage.TYPE_INT_ARGB);
- Graphics graphics = image.getGraphics();
- viewMenuIcon.paintIcon(filePane, graphics, 0, 0);
- int x = image.getWidth() - 5;
- int y = image.getHeight() / 2 - 1;
- graphics.setColor(Color.BLACK);
- graphics.fillPolygon(new int[]{x, x + 5, x + 2}, new int[]{y, y, y + 3}, 3);
-
- // Details Button
- final JButton viewMenuButton = createToolButton(null, new ImageIcon(image), viewMenuButtonToolTipText,
- viewMenuButtonAccessibleName);
-
- viewMenuButton.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- if (SwingUtilities.isLeftMouseButton(e) && !viewMenuButton.isSelected()) {
- viewMenuButton.setSelected(true);
-
- viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
- }
- }
- });
- viewMenuButton.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- // Forbid keyboard actions if the button is not in rollover state
- if (e.getKeyCode() == KeyEvent.VK_SPACE && viewMenuButton.getModel().isRollover()) {
- viewMenuButton.setSelected(true);
-
- viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
- }
- }
- });
- viewTypePopupMenu.addPopupMenuListener(new PopupMenuListener() {
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- }
-
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- viewMenuButton.setSelected(false);
- }
- });
- }
-
- public void popupMenuCanceled(PopupMenuEvent e) {
- }
- });
-
- topPanel.add(viewMenuButton);
-
- topPanel.add(Box.createRigidArea(new Dimension(80, 0)));
-
- filePane.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent e) {
- if ("viewType".equals(e.getPropertyName())) {
- switch (filePane.getViewType()) {
- case FilePane.VIEWTYPE_LIST:
- listViewMenuItem.setSelected(true);
- break;
-
- case FilePane.VIEWTYPE_DETAILS:
- detailsViewMenuItem.setSelected(true);
- break;
- }
- }
- }
- });
-
- // ************************************** //
- // ******* Add the directory pane ******* //
- // ************************************** //
- centerPanel = new JPanel(new BorderLayout());
- centerPanel.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);
- JComponent accessory = fc.getAccessory();
- if(accessory != null) {
- getAccessoryPanel().add(accessory);
- }
- filePane.setPreferredSize(LIST_PREF_SIZE);
- centerPanel.add(filePane, BorderLayout.CENTER);
- fc.add(centerPanel, BorderLayout.CENTER);
-
- // ********************************** //
- // **** Construct the bottom panel ** //
- // ********************************** //
- getBottomPanel().setLayout(new BoxLayout(getBottomPanel(), BoxLayout.LINE_AXIS));
-
- // Add the bottom panel to file chooser
- centerPanel.add(getBottomPanel(), BorderLayout.SOUTH);
-
- // labels
- JPanel labelPanel = new JPanel();
- labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
- labelPanel.add(Box.createRigidArea(vstrut4));
-
- fileNameLabel = new JLabel();
- populateFileNameLabel();
- fileNameLabel.setAlignmentY(0);
- labelPanel.add(fileNameLabel);
-
- labelPanel.add(Box.createRigidArea(new Dimension(1,12)));
-
- JLabel ftl = new JLabel(filesOfTypeLabelText);
- ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
- labelPanel.add(ftl);
-
- getBottomPanel().add(labelPanel);
- getBottomPanel().add(Box.createRigidArea(new Dimension(15, 0)));
-
- // file entry and filters
- JPanel fileAndFilterPanel = new JPanel();
- fileAndFilterPanel.add(Box.createRigidArea(vstrut8));
- fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));
-
- @SuppressWarnings("serial") // anonymous class
- JTextField tmp3 = new JTextField(35) {
- public Dimension getMaximumSize() {
- return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
- }
- };
- filenameTextField = tmp3;
-
- fileNameLabel.setLabelFor(filenameTextField);
- filenameTextField.addFocusListener(
- new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- if (!getFileChooser().isMultiSelectionEnabled()) {
- filePane.clearSelection();
- }
- }
- }
- );
-
- if (fc.isMultiSelectionEnabled()) {
- setFileName(fileNameString(fc.getSelectedFiles()));
- } else {
- setFileName(fileNameString(fc.getSelectedFile()));
- }
-
- fileAndFilterPanel.add(filenameTextField);
- fileAndFilterPanel.add(Box.createRigidArea(vstrut8));
-
- filterComboBoxModel = createFilterComboBoxModel();
- fc.addPropertyChangeListener(filterComboBoxModel);
- filterComboBox = new JComboBox<FileFilter>(filterComboBoxModel);
- ftl.setLabelFor(filterComboBox);
- filterComboBox.setRenderer(createFilterComboBoxRenderer());
- fileAndFilterPanel.add(filterComboBox);
-
- getBottomPanel().add(fileAndFilterPanel);
- getBottomPanel().add(Box.createRigidArea(new Dimension(30, 0)));
-
- // buttons
- getButtonPanel().setLayout(new BoxLayout(getButtonPanel(), BoxLayout.Y_AXIS));
-
- @SuppressWarnings("serial") // anonymous class
- JButton tmp4 = new JButton(getApproveButtonText(fc)) {
- public Dimension getMaximumSize() {
- return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
- approveButton.getPreferredSize() : cancelButton.getPreferredSize();
- }
- };
- approveButton = tmp4;
- Insets buttonMargin = approveButton.getMargin();
- buttonMargin = new InsetsUIResource(buttonMargin.top, buttonMargin.left + 5,
- buttonMargin.bottom, buttonMargin.right + 5);
- approveButton.setMargin(buttonMargin);
- approveButton.setMnemonic(getApproveButtonMnemonic(fc));
- approveButton.addActionListener(getApproveSelectionAction());
- approveButton.setToolTipText(getApproveButtonToolTipText(fc));
- getButtonPanel().add(Box.createRigidArea(vstrut6));
- getButtonPanel().add(approveButton);
- getButtonPanel().add(Box.createRigidArea(vstrut4));
-
- @SuppressWarnings("serial") // anonymous class
- JButton tmp5 = new JButton(cancelButtonText) {
- public Dimension getMaximumSize() {
- return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
- approveButton.getPreferredSize() : cancelButton.getPreferredSize();
- }
- };
- cancelButton = tmp5;
- cancelButton.setMargin(buttonMargin);
- cancelButton.setToolTipText(cancelButtonToolTipText);
- cancelButton.addActionListener(getCancelSelectionAction());
- getButtonPanel().add(cancelButton);
-
- if(fc.getControlButtonsAreShown()) {
- addControlButtons();
- }
- }
-
- private void updateUseShellFolder() {
- // Decide whether to use the ShellFolder class to populate shortcut
- // panel and combobox.
- JFileChooser fc = getFileChooser();
-
- if (FilePane.usesShellFolder(fc)) {
- if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
- placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
- fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
- fc.addPropertyChangeListener(placesBar);
- }
- } else {
- if (placesBar != null) {
- fc.remove(placesBar);
- fc.removePropertyChangeListener(placesBar);
- placesBar = null;
- }
- }
- }
-
- protected JPanel getButtonPanel() {
- if(buttonPanel == null) {
- buttonPanel = new JPanel();
- }
- return buttonPanel;
- }
-
- protected JPanel getBottomPanel() {
- if(bottomPanel == null) {
- bottomPanel = new JPanel();
- }
- return bottomPanel;
- }
-
- protected void installStrings(JFileChooser fc) {
- super.installStrings(fc);
-
- Locale l = fc.getLocale();
-
- lookInLabelMnemonic = getMnemonic("FileChooser.lookInLabelMnemonic", l);
- lookInLabelText = UIManager.getString("FileChooser.lookInLabelText",l);
- saveInLabelText = UIManager.getString("FileChooser.saveInLabelText",l);
-
- fileNameLabelMnemonic = getMnemonic("FileChooser.fileNameLabelMnemonic", l);
- fileNameLabelText = UIManager.getString("FileChooser.fileNameLabelText",l);
- folderNameLabelMnemonic = getMnemonic("FileChooser.folderNameLabelMnemonic", l);
- folderNameLabelText = UIManager.getString("FileChooser.folderNameLabelText",l);
-
- filesOfTypeLabelMnemonic = getMnemonic("FileChooser.filesOfTypeLabelMnemonic", l);
- filesOfTypeLabelText = UIManager.getString("FileChooser.filesOfTypeLabelText",l);
-
- upFolderToolTipText = UIManager.getString("FileChooser.upFolderToolTipText",l);
- upFolderAccessibleName = UIManager.getString("FileChooser.upFolderAccessibleName",l);
-
- newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText",l);
- newFolderAccessibleName = UIManager.getString("FileChooser.newFolderAccessibleName",l);
-
- viewMenuButtonToolTipText = UIManager.getString("FileChooser.viewMenuButtonToolTipText",l);
- viewMenuButtonAccessibleName = UIManager.getString("FileChooser.viewMenuButtonAccessibleName",l);
- }
-
- private Integer getMnemonic(String key, Locale l) {
- return SwingUtilities2.getUIDefaultsInt(key, l);
- }
-
- protected void installListeners(JFileChooser fc) {
- super.installListeners(fc);
- ActionMap actionMap = getActionMap();
- SwingUtilities.replaceUIActionMap(fc, actionMap);
- }
-
- protected ActionMap getActionMap() {
- return createActionMap();
- }
-
- protected ActionMap createActionMap() {
- ActionMap map = new ActionMapUIResource();
- FilePane.addActionsToMap(map, filePane.getActions());
- return map;
- }
-
- protected JPanel createList(JFileChooser fc) {
- return filePane.createList();
- }
-
- protected JPanel createDetailsView(JFileChooser fc) {
- return filePane.createDetailsView();
- }
-
- /**
- * Creates a selection listener for the list of files and directories.
- *
- * @param fc a <code>JFileChooser</code>
- * @return a <code>ListSelectionListener</code>
- */
- public ListSelectionListener createListSelectionListener(JFileChooser fc) {
- return super.createListSelectionListener(fc);
- }
-
- // Obsolete class, not used in this version.
- @SuppressWarnings("serial")
- protected class WindowsNewFolderAction extends NewFolderAction {
- }
-
- // Obsolete class, not used in this version.
- protected class SingleClickListener extends MouseAdapter {
- }
-
- // Obsolete class, not used in this version.
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- protected class FileRenderer extends DefaultListCellRenderer {
- }
-
- public void uninstallUI(JComponent c) {
- // Remove listeners
- c.removePropertyChangeListener(filterComboBoxModel);
- c.removePropertyChangeListener(filePane);
- if (placesBar != null) {
- c.removePropertyChangeListener(placesBar);
- }
- cancelButton.removeActionListener(getCancelSelectionAction());
- approveButton.removeActionListener(getApproveSelectionAction());
- filenameTextField.removeActionListener(getApproveSelectionAction());
-
- if (filePane != null) {
- filePane.uninstallUI();
- filePane = null;
- }
-
- super.uninstallUI(c);
- }
-
- /**
- * Returns the preferred size of the specified
- * <code>JFileChooser</code>.
- * The preferred size is at least as large,
- * in both height and width,
- * as the preferred size recommended
- * by the file chooser's layout manager.
- *
- * @param c a <code>JFileChooser</code>
- * @return a <code>Dimension</code> specifying the preferred
- * width and height of the file chooser
- */
- @Override
- public Dimension getPreferredSize(JComponent c) {
- int prefWidth = PREF_SIZE.width;
- Dimension d = c.getLayout().preferredLayoutSize(c);
- if (d != null) {
- return new Dimension(d.width < prefWidth ? prefWidth : d.width,
- d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height);
- } else {
- return new Dimension(prefWidth, PREF_SIZE.height);
- }
- }
-
- /**
- * Returns the minimum size of the <code>JFileChooser</code>.
- *
- * @param c a <code>JFileChooser</code>
- * @return a <code>Dimension</code> specifying the minimum
- * width and height of the file chooser
- */
- @Override
- public Dimension getMinimumSize(JComponent c) {
- return new Dimension(MIN_WIDTH, MIN_HEIGHT);
- }
-
- /**
- * Returns the maximum size of the <code>JFileChooser</code>.
- *
- * @param c a <code>JFileChooser</code>
- * @return a <code>Dimension</code> specifying the maximum
- * width and height of the file chooser
- */
- @Override
- public Dimension getMaximumSize(JComponent c) {
- return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
- }
-
- private String fileNameString(File file) {
- if (file == null) {
- return null;
- } else {
- JFileChooser fc = getFileChooser();
- if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
- (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){
- return file.getPath();
- } else {
- return file.getName();
- }
- }
- }
-
- private String fileNameString(File[] files) {
- StringBuilder buf = new StringBuilder();
- for (int i = 0; files != null && i < files.length; i++) {
- if (i > 0) {
- buf.append(" ");
- }
- if (files.length > 1) {
- buf.append("\"");
- }
- buf.append(fileNameString(files[i]));
- if (files.length > 1) {
- buf.append("\"");
- }
- }
- return buf.toString();
- }
-
- /* The following methods are used by the PropertyChange Listener */
-
- private void doSelectedFileChanged(PropertyChangeEvent e) {
- File f = (File) e.getNewValue();
- JFileChooser fc = getFileChooser();
- if (f != null
- && ((fc.isFileSelectionEnabled() && !f.isDirectory())
- || (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {
-
- setFileName(fileNameString(f));
- }
- }
-
- private void doSelectedFilesChanged(PropertyChangeEvent e) {
- File[] files = (File[]) e.getNewValue();
- JFileChooser fc = getFileChooser();
- if (files != null
- && files.length > 0
- && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
- setFileName(fileNameString(files));
- }
- }
-
- private void doDirectoryChanged(PropertyChangeEvent e) {
- JFileChooser fc = getFileChooser();
- FileSystemView fsv = fc.getFileSystemView();
-
- clearIconCache();
- File currentDirectory = fc.getCurrentDirectory();
- if(currentDirectory != null) {
- directoryComboBoxModel.addItem(currentDirectory);
-
- if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
- if (fsv.isFileSystem(currentDirectory)) {
- setFileName(currentDirectory.getPath());
- } else {
- setFileName(null);
- }
- }
- }
- }
-
- private void doFilterChanged(PropertyChangeEvent e) {
- clearIconCache();
- }
-
- private void doFileSelectionModeChanged(PropertyChangeEvent e) {
- if (fileNameLabel != null) {
- populateFileNameLabel();
- }
- clearIconCache();
-
- JFileChooser fc = getFileChooser();
- File currentDirectory = fc.getCurrentDirectory();
- if (currentDirectory != null
- && fc.isDirectorySelectionEnabled()
- && !fc.isFileSelectionEnabled()
- && fc.getFileSystemView().isFileSystem(currentDirectory)) {
-
- setFileName(currentDirectory.getPath());
- } else {
- setFileName(null);
- }
- }
-
- private void doAccessoryChanged(PropertyChangeEvent e) {
- if(getAccessoryPanel() != null) {
- if(e.getOldValue() != null) {
- getAccessoryPanel().remove((JComponent) e.getOldValue());
- }
- JComponent accessory = (JComponent) e.getNewValue();
- if(accessory != null) {
- getAccessoryPanel().add(accessory, BorderLayout.CENTER);
- }
- }
- }
-
- private void doApproveButtonTextChanged(PropertyChangeEvent e) {
- JFileChooser chooser = getFileChooser();
- approveButton.setText(getApproveButtonText(chooser));
- approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
- approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
- }
-
- private void doDialogTypeChanged(PropertyChangeEvent e) {
- JFileChooser chooser = getFileChooser();
- approveButton.setText(getApproveButtonText(chooser));
- approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
- approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
- if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
- lookInLabel.setText(saveInLabelText);
- } else {
- lookInLabel.setText(lookInLabelText);
- }
- }
-
- private void doApproveButtonMnemonicChanged(PropertyChangeEvent e) {
- approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
- }
-
- private void doControlButtonsChanged(PropertyChangeEvent e) {
- if(getFileChooser().getControlButtonsAreShown()) {
- addControlButtons();
- } else {
- removeControlButtons();
- }
- }
-
- /*
- * Listen for filechooser property changes, such as
- * the selected file changing, or the type of the dialog changing.
- */
- public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
- return new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent e) {
- String s = e.getPropertyName();
- if(s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
- doSelectedFileChanged(e);
- } else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
- doSelectedFilesChanged(e);
- } else if(s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
- doDirectoryChanged(e);
- } else if(s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
- doFilterChanged(e);
- } else if(s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
- doFileSelectionModeChanged(e);
- } else if(s.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
- doAccessoryChanged(e);
- } else if (s.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
- s.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {
- doApproveButtonTextChanged(e);
- } else if(s.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
- doDialogTypeChanged(e);
- } else if(s.equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
- doApproveButtonMnemonicChanged(e);
- } else if(s.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
- doControlButtonsChanged(e);
- } else if (s == "FileChooser.useShellFolder") {
- updateUseShellFolder();
- doDirectoryChanged(e);
- } else if (s.equals("componentOrientation")) {
- ComponentOrientation o = (ComponentOrientation)e.getNewValue();
- JFileChooser cc = (JFileChooser)e.getSource();
- if (o != e.getOldValue()) {
- cc.applyComponentOrientation(o);
- }
- } else if (s.equals("ancestor")) {
- if (e.getOldValue() == null && e.getNewValue() != null) {
- // Ancestor was added, set initial focus
- filenameTextField.selectAll();
- filenameTextField.requestFocus();
- }
- }
- }
- };
- }
-
-
- protected void removeControlButtons() {
- getBottomPanel().remove(getButtonPanel());
- }
-
- protected void addControlButtons() {
- getBottomPanel().add(getButtonPanel());
- }
-
- public void ensureFileIsVisible(JFileChooser fc, File f) {
- filePane.ensureFileIsVisible(fc, f);
- }
-
- public void rescanCurrentDirectory(JFileChooser fc) {
- filePane.rescanCurrentDirectory();
- }
-
- public String getFileName() {
- if(filenameTextField != null) {
- return filenameTextField.getText();
- } else {
- return null;
- }
- }
-
- public void setFileName(String filename) {
- if(filenameTextField != null) {
- filenameTextField.setText(filename);
- }
- }
-
- /**
- * Property to remember whether a directory is currently selected in the UI.
- * This is normally called by the UI on a selection event.
- *
- * @param directorySelected if a directory is currently selected.
- * @since 1.4
- */
- protected void setDirectorySelected(boolean directorySelected) {
- super.setDirectorySelected(directorySelected);
- JFileChooser chooser = getFileChooser();
- if(directorySelected) {
- approveButton.setText(directoryOpenButtonText);
- approveButton.setToolTipText(directoryOpenButtonToolTipText);
- approveButton.setMnemonic(directoryOpenButtonMnemonic);
- } else {
- approveButton.setText(getApproveButtonText(chooser));
- approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
- approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
- }
- }
-
- public String getDirectoryName() {
- // PENDING(jeff) - get the name from the directory combobox
- return null;
- }
-
- public void setDirectoryName(String dirname) {
- // PENDING(jeff) - set the name in the directory combobox
- }
-
- protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
- return new DirectoryComboBoxRenderer();
- }
-
- @SuppressWarnings("serial") // anonymous class
- private static JButton createToolButton(Action a, Icon defaultIcon, String toolTipText, String accessibleName) {
- final JButton result = new JButton(a);
-
- result.setText(null);
- result.setIcon(defaultIcon);
- result.setToolTipText(toolTipText);
- result.setRequestFocusEnabled(false);
- result.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
- result.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY, Boolean.TRUE);
- result.setAlignmentX(JComponent.LEFT_ALIGNMENT);
- result.setAlignmentY(JComponent.CENTER_ALIGNMENT);
- result.setMargin(shrinkwrap);
- result.setFocusPainted(false);
-
- result.setModel(new DefaultButtonModel() {
- public void setPressed(boolean b) {
- // Forbid keyboard actions if the button is not in rollover state
- if (!b || isRollover()) {
- super.setPressed(b);
- }
- }
-
- public void setRollover(boolean b) {
- if (b && !isRollover()) {
- // Reset other buttons
- for (Component component : result.getParent().getComponents()) {
- if (component instanceof JButton && component != result) {
- ((JButton) component).getModel().setRollover(false);
- }
- }
- }
-
- super.setRollover(b);
- }
-
- public void setSelected(boolean b) {
- super.setSelected(b);
-
- if (b) {
- stateMask |= PRESSED | ARMED;
- } else {
- stateMask &= ~(PRESSED | ARMED);
- }
- }
- });
-
- result.addFocusListener(new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- result.getModel().setRollover(true);
- }
-
- public void focusLost(FocusEvent e) {
- result.getModel().setRollover(false);
- }
- });
-
- return result;
- }
-
- //
- // Renderer for DirectoryComboBox
- //
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- class DirectoryComboBoxRenderer extends DefaultListCellRenderer {
- IndentIcon ii = new IndentIcon();
- public Component getListCellRendererComponent(JList<?> list, Object value,
- int index, boolean isSelected,
- boolean cellHasFocus) {
-
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-
- if (value == null) {
- setText("");
- return this;
- }
- File directory = (File)value;
- setText(getFileChooser().getName(directory));
- Icon icon = getFileChooser().getIcon(directory);
- ii.icon = icon;
- ii.depth = directoryComboBoxModel.getDepth(index);
- setIcon(ii);
-
- return this;
- }
- }
-
- static final int space = 10;
- class IndentIcon implements Icon {
-
- Icon icon = null;
- int depth = 0;
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- if (c.getComponentOrientation().isLeftToRight()) {
- icon.paintIcon(c, g, x+depth*space, y);
- } else {
- icon.paintIcon(c, g, x, y);
- }
- }
-
- public int getIconWidth() {
- return icon.getIconWidth() + depth*space;
- }
-
- public int getIconHeight() {
- return icon.getIconHeight();
- }
-
- }
-
- //
- // DataModel for DirectoryComboxbox
- //
- protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) {
- return new DirectoryComboBoxModel();
- }
-
- /**
- * Data model for a type-face selection combo-box.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
- Vector<File> directories = new Vector<File>();
- int[] depths = null;
- File selectedDirectory = null;
- JFileChooser chooser = getFileChooser();
- FileSystemView fsv = chooser.getFileSystemView();
-
- public DirectoryComboBoxModel() {
- // Add the current directory to the model, and make it the
- // selectedDirectory
- File dir = getFileChooser().getCurrentDirectory();
- if(dir != null) {
- addItem(dir);
- }
- }
-
- /**
- * Adds the directory to the model and sets it to be selected,
- * additionally clears out the previous selected directory and
- * the paths leading up to it, if any.
- */
- private void addItem(File directory) {
-
- if(directory == null) {
- return;
- }
-
- boolean useShellFolder = FilePane.usesShellFolder(chooser);
-
- directories.clear();
-
- File[] baseFolders = (useShellFolder)
- ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
- : fsv.getRoots();
- directories.addAll(Arrays.asList(baseFolders));
-
- // Get the canonical (full) path. This has the side
- // benefit of removing extraneous chars from the path,
- // for example /foo/bar/ becomes /foo/bar
- File canonical;
- try {
- canonical = directory.getCanonicalFile();
- } catch (IOException e) {
- // Maybe drive is not ready. Can't abort here.
- canonical = directory;
- }
-
- // create File instances of each directory leading up to the top
- try {
- File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
- : canonical;
- File f = sf;
- Vector<File> path = new Vector<File>(10);
- do {
- path.addElement(f);
- } while ((f = f.getParentFile()) != null);
-
- int pathCount = path.size();
- // Insert chain at appropriate place in vector
- for (int i = 0; i < pathCount; i++) {
- f = path.get(i);
- if (directories.contains(f)) {
- int topIndex = directories.indexOf(f);
- for (int j = i-1; j >= 0; j--) {
- directories.insertElementAt(path.get(j), topIndex+i-j);
- }
- break;
- }
- }
- calculateDepths();
- setSelectedItem(sf);
- } catch (FileNotFoundException ex) {
- calculateDepths();
- }
- }
-
- private void calculateDepths() {
- depths = new int[directories.size()];
- for (int i = 0; i < depths.length; i++) {
- File dir = directories.get(i);
- File parent = dir.getParentFile();
- depths[i] = 0;
- if (parent != null) {
- for (int j = i-1; j >= 0; j--) {
- if (parent.equals(directories.get(j))) {
- depths[i] = depths[j] + 1;
- break;
- }
- }
- }
- }
- }
-
- public int getDepth(int i) {
- return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0;
- }
-
- public void setSelectedItem(Object selectedDirectory) {
- this.selectedDirectory = (File)selectedDirectory;
- fireContentsChanged(this, -1, -1);
- }
-
- public Object getSelectedItem() {
- return selectedDirectory;
- }
-
- public int getSize() {
- return directories.size();
- }
-
- public File getElementAt(int index) {
- return directories.elementAt(index);
- }
- }
-
- //
- // Renderer for Types ComboBox
- //
- protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
- return new FilterComboBoxRenderer();
- }
-
- /**
- * Render different type sizes and styles.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public class FilterComboBoxRenderer extends DefaultListCellRenderer {
- public Component getListCellRendererComponent(JList<?> list,
- Object value, int index, boolean isSelected,
- boolean cellHasFocus) {
-
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-
- if (value != null && value instanceof FileFilter) {
- setText(((FileFilter)value).getDescription());
- }
-
- return this;
- }
- }
-
- //
- // DataModel for Types Comboxbox
- //
- protected FilterComboBoxModel createFilterComboBoxModel() {
- return new FilterComboBoxModel();
- }
-
- /**
- * Data model for a type-face selection combo-box.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
- PropertyChangeListener {
- protected FileFilter[] filters;
- protected FilterComboBoxModel() {
- super();
- filters = getFileChooser().getChoosableFileFilters();
- }
-
- public void propertyChange(PropertyChangeEvent e) {
- String prop = e.getPropertyName();
- if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
- filters = (FileFilter[]) e.getNewValue();
- fireContentsChanged(this, -1, -1);
- } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
- fireContentsChanged(this, -1, -1);
- }
- }
-
- public void setSelectedItem(Object filter) {
- if(filter != null) {
- getFileChooser().setFileFilter((FileFilter) filter);
- fireContentsChanged(this, -1, -1);
- }
- }
-
- public Object getSelectedItem() {
- // Ensure that the current filter is in the list.
- // NOTE: we shouldnt' have to do this, since JFileChooser adds
- // the filter to the choosable filters list when the filter
- // is set. Lets be paranoid just in case someone overrides
- // setFileFilter in JFileChooser.
- FileFilter currentFilter = getFileChooser().getFileFilter();
- boolean found = false;
- if(currentFilter != null) {
- for (FileFilter filter : filters) {
- if (filter == currentFilter) {
- found = true;
- }
- }
- if(found == false) {
- getFileChooser().addChoosableFileFilter(currentFilter);
- }
- }
- return getFileChooser().getFileFilter();
- }
-
- public int getSize() {
- if(filters != null) {
- return filters.length;
- } else {
- return 0;
- }
- }
-
- public FileFilter getElementAt(int index) {
- if(index > getSize() - 1) {
- // This shouldn't happen. Try to recover gracefully.
- return getFileChooser().getFileFilter();
- }
- if(filters != null) {
- return filters[index];
- } else {
- return null;
- }
- }
- }
-
- public void valueChanged(ListSelectionEvent e) {
- JFileChooser fc = getFileChooser();
- File f = fc.getSelectedFile();
- if (!e.getValueIsAdjusting() && f != null && !getFileChooser().isTraversable(f)) {
- setFileName(fileNameString(f));
- }
- }
-
- /**
- * Acts when DirectoryComboBox has changed the selected item.
- */
- protected class DirectoryComboBoxAction implements ActionListener {
-
-
-
-
- public void actionPerformed(ActionEvent e) {
- File f = (File)directoryComboBox.getSelectedItem();
- getFileChooser().setCurrentDirectory(f);
- }
- }
-
- protected JButton getApproveButton(JFileChooser fc) {
- return approveButton;
- }
-
- public FileView getFileView(JFileChooser fc) {
- return fileView;
- }
-
- // ***********************
- // * FileView operations *
- // ***********************
- protected class WindowsFileView extends BasicFileView {
- /* FileView type descriptions */
-
- public Icon getIcon(File f) {
- Icon icon = getCachedIcon(f);
- if (icon != null) {
- return icon;
- }
- if (f != null) {
- icon = getFileChooser().getFileSystemView().getSystemIcon(f);
- }
- if (icon == null) {
- icon = super.getIcon(f);
- }
- cacheIcon(f, icon);
- return icon;
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.swing.SwingUtilities2;
-
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.plaf.UIResource;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-
-/**
- * A collection of static utility methods used for rendering the Windows look
- * and feel.
- *
- * @author Mark Davidson
- * @since 1.4
- */
-public class WindowsGraphicsUtils {
-
- /**
- * Renders a text String in Windows without the mnemonic.
- * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
- * the overriden paintText methods of the ButtonUI delegates will call this static method.
- *
- * @param g Graphics context
- * @param b Current button to render
- * @param textRect Bounding rectangle to render the text.
- * @param text String to render
- */
- public static void paintText(Graphics g, AbstractButton b,
- Rectangle textRect, String text,
- int textShiftOffset) {
- FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
-
- int mnemIndex = b.getDisplayedMnemonicIndex();
- // W2K Feature: Check to see if the Underscore should be rendered.
- if (WindowsLookAndFeel.isMnemonicHidden() == true) {
- mnemIndex = -1;
- }
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null && !(b instanceof JMenuItem)) {
- paintXPText(b, g, textRect.x + textShiftOffset,
- textRect.y + fm.getAscent() + textShiftOffset,
- text, mnemIndex);
- } else {
- paintClassicText(b, g, textRect.x + textShiftOffset,
- textRect.y + fm.getAscent() + textShiftOffset,
- text, mnemIndex);
- }
- }
-
- static void paintClassicText(AbstractButton b, Graphics g, int x, int y,
- String text, int mnemIndex) {
- ButtonModel model = b.getModel();
-
- /* Draw the Text */
- Color color = b.getForeground();
- if(model.isEnabled()) {
- /*** paint the text normally */
- if(!(b instanceof JMenuItem && model.isArmed())
- && !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) {
- /* We shall not set foreground color for selected menu or
- * armed menuitem. Foreground must be set in appropriate
- * Windows* class because these colors passes from
- * BasicMenuItemUI as protected fields and we can't
- * reach them from this class */
- g.setColor(b.getForeground());
- }
- SwingUtilities2.drawStringUnderlineCharAt(b, g,text, mnemIndex, x, y);
- } else { /*** paint the text disabled ***/
- color = getDisabledTextColor(b);
- if (color == null) {
- color = UIManager.getColor("Button.shadow");
- }
- Color shadow = UIManager.getColor("Button.disabledShadow");
- if(model.isArmed()) {
- color = UIManager.getColor("Button.disabledForeground");
- } else {
- if (shadow == null) {
- shadow = b.getBackground().darker();
- }
- g.setColor(shadow);
- SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
- x + 1, y + 1);
- }
- if (color == null) {
- color = b.getBackground().brighter();
- }
- g.setColor(color);
- SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
- }
- }
-
- private static Color getDisabledTextColor(AbstractButton b) {
- if (b instanceof JCheckBox) {
- return UIManager.getColor("CheckBox.disabledText");
- } else if (b instanceof JRadioButton) {
- return UIManager.getColor("RadioButton.disabledText");
- } else if (b instanceof JToggleButton) {
- return UIManager.getColor("ToggleButton.disabledText");
- } else if (b instanceof JButton) {
- return UIManager.getColor("Button.disabledText");
- }
- return null;
- }
-
- static void paintXPText(AbstractButton b, Graphics g, int x, int y,
- String text, int mnemIndex) {
- Part part = WindowsButtonUI.getXPButtonType(b);
- State state = WindowsButtonUI.getXPButtonState(b);
- paintXPText(b, part, state, g, x, y, text, mnemIndex);
- }
-
- static void paintXPText(AbstractButton b, Part part, State state,
- Graphics g, int x, int y, String text, int mnemIndex) {
- XPStyle xp = XPStyle.getXP();
- if (xp == null) {
- return;
- }
- Color textColor;
- if (b.isEnabled()) {
- textColor = b.getForeground();
- }
- else {
- textColor = getDisabledTextColor(b);
- }
-
- if (textColor == null || textColor instanceof UIResource) {
- textColor = xp.getColor(b, part, state, Prop.TEXTCOLOR, b.getForeground());
- // to work around an apparent bug in Windows, use the pushbutton
- // color for disabled toolbar buttons if the disabled color is the
- // same as the enabled color
- if (part == Part.TP_BUTTON && state == State.DISABLED) {
- Color enabledColor = xp.getColor(b, part, State.NORMAL,
- Prop.TEXTCOLOR, b.getForeground());
- if(textColor.equals(enabledColor)) {
- textColor = xp.getColor(b, Part.BP_PUSHBUTTON, state,
- Prop.TEXTCOLOR, textColor);
- }
- }
- // only draw shadow if developer hasn't changed the foreground color
- // and if the current style has text shadows.
- TypeEnum shadowType = xp.getTypeEnum(b, part,
- state, Prop.TEXTSHADOWTYPE);
- if (shadowType == TypeEnum.TST_SINGLE ||
- shadowType == TypeEnum.TST_CONTINUOUS) {
- Color shadowColor = xp.getColor(b, part, state,
- Prop.TEXTSHADOWCOLOR, Color.black);
- Point offset = xp.getPoint(b, part, state, Prop.TEXTSHADOWOFFSET);
- if (offset != null) {
- g.setColor(shadowColor);
- SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
- x + offset.x,
- y + offset.y);
- }
- }
- }
-
- g.setColor(textColor);
- SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
- }
-
- static boolean isLeftToRight(Component c) {
- return c.getComponentOrientation().isLeftToRight();
- }
-
- /*
- * Repaints all the components with the mnemonics in the given window and
- * all its owned windows.
- */
- static void repaintMnemonicsInWindow(Window w) {
- if(w == null || !w.isShowing()) {
- return;
- }
-
- Window[] ownedWindows = w.getOwnedWindows();
- for(int i=0;i<ownedWindows.length;i++) {
- repaintMnemonicsInWindow(ownedWindows[i]);
- }
-
- repaintMnemonicsInContainer(w);
- }
-
- /*
- * Repaints all the components with the mnemonics in container.
- * Recursively searches for all the subcomponents.
- */
- static void repaintMnemonicsInContainer(Container cont) {
- Component c;
- for(int i=0; i<cont.getComponentCount(); i++) {
- c = cont.getComponent(i);
- if(c == null || !c.isVisible()) {
- continue;
- }
- if(c instanceof AbstractButton
- && ((AbstractButton)c).getMnemonic() != '\0') {
- c.repaint();
- continue;
- } else if(c instanceof JLabel
- && ((JLabel)c).getDisplayedMnemonic() != '\0') {
- c.repaint();
- continue;
- }
- if(c instanceof Container) {
- repaintMnemonicsInContainer((Container)c);
- }
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,974 +0,0 @@
-/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.*;
-import javax.swing.plaf.ButtonUI;
-import javax.swing.plaf.UIResource;
-
-import java.awt.*;
-import java.io.Serializable;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-import sun.swing.MenuItemCheckIconFactory;
-import sun.swing.SwingUtilities2;
-
-/**
- * Factory object that can vend Icons appropriate for the Windows {@literal L & F}.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author David Kloba
- * @author Georges Saab
- * @author Rich Schiavi
- */
-@SuppressWarnings("serial") // Same-version serialization only
-public class WindowsIconFactory implements Serializable
-{
- private static Icon frame_closeIcon;
- private static Icon frame_iconifyIcon;
- private static Icon frame_maxIcon;
- private static Icon frame_minIcon;
- private static Icon frame_resizeIcon;
- private static Icon checkBoxIcon;
- private static Icon radioButtonIcon;
- private static Icon checkBoxMenuItemIcon;
- private static Icon radioButtonMenuItemIcon;
- private static Icon menuItemCheckIcon;
- private static Icon menuItemArrowIcon;
- private static Icon menuArrowIcon;
- private static VistaMenuItemCheckIconFactory menuItemCheckIconFactory;
-
- public static Icon getMenuItemCheckIcon() {
- if (menuItemCheckIcon == null) {
- menuItemCheckIcon = new MenuItemCheckIcon();
- }
- return menuItemCheckIcon;
- }
-
- public static Icon getMenuItemArrowIcon() {
- if (menuItemArrowIcon == null) {
- menuItemArrowIcon = new MenuItemArrowIcon();
- }
- return menuItemArrowIcon;
- }
-
- public static Icon getMenuArrowIcon() {
- if (menuArrowIcon == null) {
- menuArrowIcon = new MenuArrowIcon();
- }
- return menuArrowIcon;
- }
-
- public static Icon getCheckBoxIcon() {
- if (checkBoxIcon == null) {
- checkBoxIcon = new CheckBoxIcon();
- }
- return checkBoxIcon;
- }
-
- public static Icon getRadioButtonIcon() {
- if (radioButtonIcon == null) {
- radioButtonIcon = new RadioButtonIcon();
- }
- return radioButtonIcon;
- }
-
- public static Icon getCheckBoxMenuItemIcon() {
- if (checkBoxMenuItemIcon == null) {
- checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
- }
- return checkBoxMenuItemIcon;
- }
-
- public static Icon getRadioButtonMenuItemIcon() {
- if (radioButtonMenuItemIcon == null) {
- radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
- }
- return radioButtonMenuItemIcon;
- }
-
- static
- synchronized VistaMenuItemCheckIconFactory getMenuItemCheckIconFactory() {
- if (menuItemCheckIconFactory == null) {
- menuItemCheckIconFactory =
- new VistaMenuItemCheckIconFactory();
- }
- return menuItemCheckIconFactory;
- }
-
- public static Icon createFrameCloseIcon() {
- if (frame_closeIcon == null) {
- frame_closeIcon = new FrameButtonIcon(Part.WP_CLOSEBUTTON);
- }
- return frame_closeIcon;
- }
-
- public static Icon createFrameIconifyIcon() {
- if (frame_iconifyIcon == null) {
- frame_iconifyIcon = new FrameButtonIcon(Part.WP_MINBUTTON);
- }
- return frame_iconifyIcon;
- }
-
- public static Icon createFrameMaximizeIcon() {
- if (frame_maxIcon == null) {
- frame_maxIcon = new FrameButtonIcon(Part.WP_MAXBUTTON);
- }
- return frame_maxIcon;
- }
-
- public static Icon createFrameMinimizeIcon() {
- if (frame_minIcon == null) {
- frame_minIcon = new FrameButtonIcon(Part.WP_RESTOREBUTTON);
- }
- return frame_minIcon;
- }
-
- public static Icon createFrameResizeIcon() {
- if(frame_resizeIcon == null)
- frame_resizeIcon = new ResizeIcon();
- return frame_resizeIcon;
- }
-
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class FrameButtonIcon implements Icon, Serializable {
- private Part part;
-
- private FrameButtonIcon(Part part) {
- this.part = part;
- }
-
- public void paintIcon(Component c, Graphics g, int x0, int y0) {
- int width = getIconWidth();
- int height = getIconHeight();
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(c, part);
- AbstractButton b = (AbstractButton)c;
- ButtonModel model = b.getModel();
-
- // Find out if frame is inactive
- JInternalFrame jif = (JInternalFrame)SwingUtilities.
- getAncestorOfClass(JInternalFrame.class, b);
- boolean jifSelected = (jif != null && jif.isSelected());
-
- State state;
- if (jifSelected) {
- if (!model.isEnabled()) {
- state = State.DISABLED;
- } else if (model.isArmed() && model.isPressed()) {
- state = State.PUSHED;
- } else if (model.isRollover()) {
- state = State.HOT;
- } else {
- state = State.NORMAL;
- }
- } else {
- if (!model.isEnabled()) {
- state = State.INACTIVEDISABLED;
- } else if (model.isArmed() && model.isPressed()) {
- state = State.INACTIVEPUSHED;
- } else if (model.isRollover()) {
- state = State.INACTIVEHOT;
- } else {
- state = State.INACTIVENORMAL;
- }
- }
- skin.paintSkin(g, 0, 0, width, height, state);
- } else {
- g.setColor(Color.black);
- int x = width / 12 + 2;
- int y = height / 5;
- int h = height - y * 2 - 1;
- int w = width * 3/4 -3;
- int thickness2 = Math.max(height / 8, 2);
- int thickness = Math.max(width / 15, 1);
- if (part == Part.WP_CLOSEBUTTON) {
- int lineWidth;
- if (width > 47) lineWidth = 6;
- else if (width > 37) lineWidth = 5;
- else if (width > 26) lineWidth = 4;
- else if (width > 16) lineWidth = 3;
- else if (width > 12) lineWidth = 2;
- else lineWidth = 1;
- y = height / 12 + 2;
- if (lineWidth == 1) {
- if (w % 2 == 1) { x++; w++; }
- g.drawLine(x, y, x+w-2, y+w-2);
- g.drawLine(x+w-2, y, x, y+w-2);
- } else if (lineWidth == 2) {
- if (w > 6) { x++; w--; }
- g.drawLine(x, y, x+w-2, y+w-2);
- g.drawLine(x+w-2, y, x, y+w-2);
- g.drawLine(x+1, y, x+w-1, y+w-2);
- g.drawLine(x+w-1, y, x+1, y+w-2);
- } else {
- x += 2; y++; w -= 2;
- g.drawLine(x, y, x+w-1, y+w-1);
- g.drawLine(x+w-1, y, x, y+w-1);
- g.drawLine(x+1, y, x+w-1, y+w-2);
- g.drawLine(x+w-2, y, x, y+w-2);
- g.drawLine(x, y+1, x+w-2, y+w-1);
- g.drawLine(x+w-1, y+1, x+1, y+w-1);
- for (int i = 4; i <= lineWidth; i++) {
- g.drawLine(x+i-2, y, x+w-1, y+w-i+1);
- g.drawLine(x, y+i-2, x+w-i+1, y+w-1);
- g.drawLine(x+w-i+1, y, x, y+w-i+1);
- g.drawLine(x+w-1, y+i-2, x+i-2, y+w-1);
- }
- }
- } else if (part == Part.WP_MINBUTTON) {
- g.fillRect(x, y+h-thickness2, w-w/3, thickness2);
- } else if (part == Part.WP_MAXBUTTON) {
- g.fillRect(x, y, w, thickness2);
- g.fillRect(x, y, thickness, h);
- g.fillRect(x+w-thickness, y, thickness, h);
- g.fillRect(x, y+h-thickness, w, thickness);
- } else if (part == Part.WP_RESTOREBUTTON) {
- g.fillRect(x+w/3, y, w-w/3, thickness2);
- g.fillRect(x+w/3, y, thickness, h/3);
- g.fillRect(x+w-thickness, y, thickness, h-h/3);
- g.fillRect(x+w-w/3, y+h-h/3-thickness, w/3, thickness);
-
- g.fillRect(x, y+h/3, w-w/3, thickness2);
- g.fillRect(x, y+h/3, thickness, h-h/3);
- g.fillRect(x+w-w/3-thickness, y+h/3, thickness, h-h/3);
- g.fillRect(x, y+h-thickness, w-w/3, thickness);
- }
- }
- }
-
- public int getIconWidth() {
- int width;
- if (XPStyle.getXP() != null) {
- // Fix for XP bug where sometimes these sizes aren't updated properly
- // Assume for now that height is correct and derive width using the
- // ratio from the uxtheme part
- width = UIManager.getInt("InternalFrame.titleButtonHeight") -2;
- Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
- if (d != null && d.width != 0 && d.height != 0) {
- width = (int) ((float) width * d.width / d.height);
- }
- } else {
- width = UIManager.getInt("InternalFrame.titleButtonWidth") -2;
- }
- if (XPStyle.getXP() != null) {
- width -= 2;
- }
- return width;
- }
-
- public int getIconHeight() {
- int height = UIManager.getInt("InternalFrame.titleButtonHeight")-4;
- return height;
- }
- }
-
-
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class ResizeIcon implements Icon, Serializable {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- g.setColor(UIManager.getColor("InternalFrame.resizeIconHighlight"));
- g.drawLine(0, 11, 11, 0);
- g.drawLine(4, 11, 11, 4);
- g.drawLine(8, 11, 11, 8);
-
- g.setColor(UIManager.getColor("InternalFrame.resizeIconShadow"));
- g.drawLine(1, 11, 11, 1);
- g.drawLine(2, 11, 11, 2);
- g.drawLine(5, 11, 11, 5);
- g.drawLine(6, 11, 11, 6);
- g.drawLine(9, 11, 11, 9);
- g.drawLine(10, 11, 11, 10);
- }
- public int getIconWidth() { return 13; }
- public int getIconHeight() { return 13; }
- };
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class CheckBoxIcon implements Icon, Serializable
- {
- static final int csize = 13;
- public void paintIcon(Component c, Graphics g, int x, int y) {
- JCheckBox cb = (JCheckBox) c;
- ButtonModel model = cb.getModel();
- XPStyle xp = XPStyle.getXP();
-
- if (xp != null) {
- State state;
- if (model.isSelected()) {
- state = State.CHECKEDNORMAL;
- if (!model.isEnabled()) {
- state = State.CHECKEDDISABLED;
- } else if (model.isPressed() && model.isArmed()) {
- state = State.CHECKEDPRESSED;
- } else if (model.isRollover()) {
- state = State.CHECKEDHOT;
- }
- } else {
- state = State.UNCHECKEDNORMAL;
- if (!model.isEnabled()) {
- state = State.UNCHECKEDDISABLED;
- } else if (model.isPressed() && model.isArmed()) {
- state = State.UNCHECKEDPRESSED;
- } else if (model.isRollover()) {
- state = State.UNCHECKEDHOT;
- }
- }
- Part part = Part.BP_CHECKBOX;
- xp.getSkin(c, part).paintSkin(g, x, y, state);
- } else {
- // outer bevel
- if(!cb.isBorderPaintedFlat()) {
- // Outer top/left
- g.setColor(UIManager.getColor("CheckBox.shadow"));
- g.drawLine(x, y, x+11, y);
- g.drawLine(x, y+1, x, y+11);
-
- // Outer bottom/right
- g.setColor(UIManager.getColor("CheckBox.highlight"));
- g.drawLine(x+12, y, x+12, y+12);
- g.drawLine(x, y+12, x+11, y+12);
-
- // Inner top.left
- g.setColor(UIManager.getColor("CheckBox.darkShadow"));
- g.drawLine(x+1, y+1, x+10, y+1);
- g.drawLine(x+1, y+2, x+1, y+10);
-
- // Inner bottom/right
- g.setColor(UIManager.getColor("CheckBox.light"));
- g.drawLine(x+1, y+11, x+11, y+11);
- g.drawLine(x+11, y+1, x+11, y+10);
-
- // inside box
- if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
- g.setColor(UIManager.getColor("CheckBox.background"));
- } else {
- g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
- }
- g.fillRect(x+2, y+2, csize-4, csize-4);
- } else {
- g.setColor(UIManager.getColor("CheckBox.shadow"));
- g.drawRect(x+1, y+1, csize-3, csize-3);
-
- if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
- g.setColor(UIManager.getColor("CheckBox.background"));
- } else {
- g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
- }
- g.fillRect(x+2, y+2, csize-4, csize-4);
- }
-
- if(model.isEnabled()) {
- g.setColor(UIManager.getColor("CheckBox.foreground"));
- } else {
- g.setColor(UIManager.getColor("CheckBox.shadow"));
- }
-
- // paint check
- if (model.isSelected()) {
- if (SwingUtilities2.isScaledGraphics(g)) {
- int[] xPoints = {3, 5, 9, 9, 5, 3};
- int[] yPoints = {5, 7, 3, 5, 9, 7};
- g.translate(x, y);
- g.fillPolygon(xPoints, yPoints, 6);
- g.drawPolygon(xPoints, yPoints, 6);
- g.translate(-x, -y);
- } else {
- g.drawLine(x + 9, y + 3, x + 9, y + 3);
- g.drawLine(x + 8, y + 4, x + 9, y + 4);
- g.drawLine(x + 7, y + 5, x + 9, y + 5);
- g.drawLine(x + 6, y + 6, x + 8, y + 6);
- g.drawLine(x + 3, y + 7, x + 7, y + 7);
- g.drawLine(x + 4, y + 8, x + 6, y + 8);
- g.drawLine(x + 5, y + 9, x + 5, y + 9);
- g.drawLine(x + 3, y + 5, x + 3, y + 5);
- g.drawLine(x + 3, y + 6, x + 4, y + 6);
- }
- }
- }
- }
-
- public int getIconWidth() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return xp.getSkin(null, Part.BP_CHECKBOX).getWidth();
- } else {
- return csize;
- }
- }
-
- public int getIconHeight() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return xp.getSkin(null, Part.BP_CHECKBOX).getHeight();
- } else {
- return csize;
- }
- }
- }
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class RadioButtonIcon implements Icon, UIResource, Serializable
- {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- AbstractButton b = (AbstractButton) c;
- ButtonModel model = b.getModel();
- XPStyle xp = XPStyle.getXP();
-
- if (xp != null) {
- Part part = Part.BP_RADIOBUTTON;
- Skin skin = xp.getSkin(b, part);
- State state;
- int index = 0;
- if (model.isSelected()) {
- state = State.CHECKEDNORMAL;
- if (!model.isEnabled()) {
- state = State.CHECKEDDISABLED;
- } else if (model.isPressed() && model.isArmed()) {
- state = State.CHECKEDPRESSED;
- } else if (model.isRollover()) {
- state = State.CHECKEDHOT;
- }
- } else {
- state = State.UNCHECKEDNORMAL;
- if (!model.isEnabled()) {
- state = State.UNCHECKEDDISABLED;
- } else if (model.isPressed() && model.isArmed()) {
- state = State.UNCHECKEDPRESSED;
- } else if (model.isRollover()) {
- state = State.UNCHECKEDHOT;
- }
- }
- skin.paintSkin(g, x, y, state);
- } else {
- // fill interior
- if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
- g.setColor(UIManager.getColor("RadioButton.background"));
- } else {
- g.setColor(UIManager.getColor("RadioButton.interiorBackground"));
- }
- g.fillRect(x+2, y+2, 8, 8);
-
-
- boolean isScaledGraphics = SwingUtilities2.isScaledGraphics(g);
-
- if (isScaledGraphics) {
-
- Graphics2D g2d = (Graphics2D) g;
- Stroke oldStroke = g2d.getStroke();
- g2d.setStroke(new BasicStroke(1.03f, BasicStroke.CAP_ROUND,
- BasicStroke.JOIN_ROUND));
- Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- // outter left arc
- g.setColor(UIManager.getColor("RadioButton.shadow"));
- g.drawArc(x, y, 11, 11, 45, 180);
- // outter right arc
- g.setColor(UIManager.getColor("RadioButton.highlight"));
- g.drawArc(x, y, 11, 11, 45, -180);
- // inner left arc
- g.setColor(UIManager.getColor("RadioButton.darkShadow"));
- g.drawArc(x + 1, y + 1, 9, 9, 45, 180);
- // inner right arc
- g.setColor(UIManager.getColor("RadioButton.light"));
- g.drawArc(x + 1, y + 1, 9, 9, 45, -180);
-
- g2d.setStroke(oldStroke);
-
- if (model.isSelected()) {
- if (model.isEnabled()) {
- g.setColor(UIManager.getColor("RadioButton.foreground"));
- } else {
- g.setColor(UIManager.getColor("RadioButton.shadow"));
- }
- g.fillOval(x + 3, y + 3, 5, 5);
- }
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
-
- } else {
-
- // outter left arc
- g.setColor(UIManager.getColor("RadioButton.shadow"));
- g.drawLine(x+4, y+0, x+7, y+0);
- g.drawLine(x+2, y+1, x+3, y+1);
- g.drawLine(x+8, y+1, x+9, y+1);
- g.drawLine(x+1, y+2, x+1, y+3);
- g.drawLine(x+0, y+4, x+0, y+7);
- g.drawLine(x+1, y+8, x+1, y+9);
-
- // outter right arc
- g.setColor(UIManager.getColor("RadioButton.highlight"));
- g.drawLine(x+2, y+10, x+3, y+10);
- g.drawLine(x+4, y+11, x+7, y+11);
- g.drawLine(x+8, y+10, x+9, y+10);
- g.drawLine(x+10, y+9, x+10, y+8);
- g.drawLine(x+11, y+7, x+11, y+4);
- g.drawLine(x+10, y+3, x+10, y+2);
-
-
- // inner left arc
- g.setColor(UIManager.getColor("RadioButton.darkShadow"));
- g.drawLine(x+4, y+1, x+7, y+1);
- g.drawLine(x+2, y+2, x+3, y+2);
- g.drawLine(x+8, y+2, x+9, y+2);
- g.drawLine(x+2, y+3, x+2, y+3);
- g.drawLine(x+1, y+4, x+1, y+7);
- g.drawLine(x+2, y+8, x+2, y+8);
-
-
- // inner right arc
- g.setColor(UIManager.getColor("RadioButton.light"));
- g.drawLine(x+2, y+9, x+3, y+9);
- g.drawLine(x+4, y+10, x+7, y+10);
- g.drawLine(x+8, y+9, x+9, y+9);
- g.drawLine(x+9, y+8, x+9, y+8);
- g.drawLine(x+10, y+7, x+10, y+4);
- g.drawLine(x+9, y+3, x+9, y+3);
-
-
- // indicate whether selected or not
- if (model.isSelected()) {
- if (model.isEnabled()) {
- g.setColor(UIManager.getColor("RadioButton.foreground"));
- } else {
- g.setColor(UIManager.getColor("RadioButton.shadow"));
- }
- g.fillRect(x+4, y+5, 4, 2);
- g.fillRect(x+5, y+4, 2, 4);
- }
- }
- }
- }
-
- public int getIconWidth() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return xp.getSkin(null, Part.BP_RADIOBUTTON).getWidth();
- } else {
- return 13;
- }
- }
-
- public int getIconHeight() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return xp.getSkin(null, Part.BP_RADIOBUTTON).getHeight();
- } else {
- return 13;
- }
- }
- } // end class RadioButtonIcon
-
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
- {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- AbstractButton b = (AbstractButton) c;
- ButtonModel model = b.getModel();
- boolean isSelected = model.isSelected();
- if (isSelected) {
- y = y - getIconHeight() / 2;
- g.drawLine(x+9, y+3, x+9, y+3);
- g.drawLine(x+8, y+4, x+9, y+4);
- g.drawLine(x+7, y+5, x+9, y+5);
- g.drawLine(x+6, y+6, x+8, y+6);
- g.drawLine(x+3, y+7, x+7, y+7);
- g.drawLine(x+4, y+8, x+6, y+8);
- g.drawLine(x+5, y+9, x+5, y+9);
- g.drawLine(x+3, y+5, x+3, y+5);
- g.drawLine(x+3, y+6, x+4, y+6);
- }
- }
- public int getIconWidth() { return 9; }
- public int getIconHeight() { return 9; }
-
- } // End class CheckBoxMenuItemIcon
-
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
- {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- AbstractButton b = (AbstractButton) c;
- ButtonModel model = b.getModel();
- if (b.isSelected() == true) {
- g.fillRoundRect(x+3,y+3, getIconWidth()-6, getIconHeight()-6,
- 4, 4);
- }
- }
- public int getIconWidth() { return 12; }
- public int getIconHeight() { return 12; }
-
- } // End class RadioButtonMenuItemIcon
-
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class MenuItemCheckIcon implements Icon, UIResource, Serializable{
- public void paintIcon(Component c, Graphics g, int x, int y) {
- /* For debugging:
- Color oldColor = g.getColor();
- g.setColor(Color.orange);
- g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
- g.setColor(oldColor);
- */
- }
- public int getIconWidth() { return 9; }
- public int getIconHeight() { return 9; }
-
- } // End class MenuItemCheckIcon
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class MenuItemArrowIcon implements Icon, UIResource, Serializable {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- /* For debugging:
- Color oldColor = g.getColor();
- g.setColor(Color.green);
- g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
- g.setColor(oldColor);
- */
- }
- public int getIconWidth() { return 4; }
- public int getIconHeight() { return 8; }
-
- } // End class MenuItemArrowIcon
-
- @SuppressWarnings("serial") // Same-version serialization only
- private static class MenuArrowIcon implements Icon, UIResource, Serializable {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- State state = State.NORMAL;
- if (c instanceof JMenuItem) {
- state = ((JMenuItem) c).getModel().isEnabled()
- ? State.NORMAL : State.DISABLED;
- }
- Skin skin = xp.getSkin(c, Part.MP_POPUPSUBMENU);
- if (WindowsGraphicsUtils.isLeftToRight(c)) {
- skin.paintSkin(g, x, y, state);
- } else {
- Graphics2D g2d = (Graphics2D)g.create();
- g2d.translate(x + skin.getWidth(), y);
- g2d.scale(-1, 1);
- skin.paintSkin(g2d, 0, 0, state);
- g2d.dispose();
- }
- } else {
- g.translate(x,y);
- if( WindowsGraphicsUtils.isLeftToRight(c) ) {
- g.drawLine( 0, 0, 0, 7 );
- g.drawLine( 1, 1, 1, 6 );
- g.drawLine( 2, 2, 2, 5 );
- g.drawLine( 3, 3, 3, 4 );
- } else {
- g.drawLine( 4, 0, 4, 7 );
- g.drawLine( 3, 1, 3, 6 );
- g.drawLine( 2, 2, 2, 5 );
- g.drawLine( 1, 3, 1, 4 );
- }
- g.translate(-x,-y);
- }
- }
- public int getIconWidth() {
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
- return skin.getWidth();
- } else {
- return 4;
- }
- }
- public int getIconHeight() {
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
- return skin.getHeight();
- } else {
- return 8;
- }
- }
- } // End class MenuArrowIcon
-
- static class VistaMenuItemCheckIconFactory
- implements MenuItemCheckIconFactory {
- private static final int OFFSET = 3;
-
- public Icon getIcon(JMenuItem component) {
- return new VistaMenuItemCheckIcon(component);
- }
-
- public boolean isCompatible(Object icon, String prefix) {
- return icon instanceof VistaMenuItemCheckIcon
- && ((VistaMenuItemCheckIcon) icon).type == getType(prefix);
- }
-
- public Icon getIcon(String type) {
- return new VistaMenuItemCheckIcon(type);
- }
-
- static int getIconWidth() {
- XPStyle xp = XPStyle.getXP();
- return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16)
- + 2 * OFFSET;
- }
-
- private static Class<? extends JMenuItem> getType(Component c) {
- Class<? extends JMenuItem> rv = null;
- if (c instanceof JCheckBoxMenuItem) {
- rv = JCheckBoxMenuItem.class;
- } else if (c instanceof JRadioButtonMenuItem) {
- rv = JRadioButtonMenuItem.class;
- } else if (c instanceof JMenu) {
- rv = JMenu.class;
- } else if (c instanceof JMenuItem) {
- rv = JMenuItem.class;
- }
- return rv;
- }
-
- private static Class<? extends JMenuItem> getType(String type) {
- Class<? extends JMenuItem> rv = null;
- if (type == "CheckBoxMenuItem") {
- rv = JCheckBoxMenuItem.class;
- } else if (type == "RadioButtonMenuItem") {
- rv = JRadioButtonMenuItem.class;
- } else if (type == "Menu") {
- rv = JMenu.class;
- } else if (type == "MenuItem") {
- rv = JMenuItem.class;
- } else {
- // this should never happen
- rv = JMenuItem.class;
- }
- return rv;
- }
-
- /**
- * CheckIcon for JMenuItem, JMenu, JCheckBoxMenuItem and
- * JRadioButtonMenuItem.
- * Note: to be used on Vista only.
- */
- @SuppressWarnings("serial") // Same-version serialization only
- private static class VistaMenuItemCheckIcon
- implements Icon, UIResource, Serializable {
-
- private final JMenuItem menuItem;
- private final Class<? extends JMenuItem> type;
-
- VistaMenuItemCheckIcon(JMenuItem menuItem) {
- this.type = getType(menuItem);
- this.menuItem = menuItem;
- }
- VistaMenuItemCheckIcon(String type) {
- this.type = getType(type);
- this.menuItem = null;
- }
-
- public int getIconHeight() {
- Icon lafIcon = getLaFIcon();
- if (lafIcon != null) {
- return lafIcon.getIconHeight();
- }
- Icon icon = getIcon();
- int height = 0;
- if (icon != null) {
- height = icon.getIconHeight();
- } else {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK);
- height = skin.getHeight();
- } else {
- height = 16;
- }
- }
- height += 2 * OFFSET;
- return height;
- }
-
- public int getIconWidth() {
- Icon lafIcon = getLaFIcon();
- if (lafIcon != null) {
- return lafIcon.getIconWidth();
- }
- Icon icon = getIcon();
- int width = 0;
- if (icon != null) {
- width = icon.getIconWidth() + 2 * OFFSET;
- } else {
- width = VistaMenuItemCheckIconFactory.getIconWidth();
- }
- return width;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- Icon lafIcon = getLaFIcon();
- if (lafIcon != null) {
- lafIcon.paintIcon(c, g, x, y);
- return;
- }
- assert menuItem == null || c == menuItem;
- Icon icon = getIcon();
- if (type == JCheckBoxMenuItem.class
- || type == JRadioButtonMenuItem.class) {
- AbstractButton b = (AbstractButton) c;
- if (b.isSelected()) {
- Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
- Part part = Part.MP_POPUPCHECK;
- State backgroundState;
- State state;
- if (isEnabled(c, null)) {
- backgroundState =
- (icon != null) ? State.BITMAP : State.NORMAL;
- state = (type == JRadioButtonMenuItem.class)
- ? State.BULLETNORMAL
- : State.CHECKMARKNORMAL;
- } else {
- backgroundState = State.DISABLEDPUSHED;
- state =
- (type == JRadioButtonMenuItem.class)
- ? State.BULLETDISABLED
- : State.CHECKMARKDISABLED;
- }
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin;
- skin = xp.getSkin(c, backgroundPart);
- skin.paintSkin(g, x, y,
- getIconWidth(), getIconHeight(), backgroundState);
- if (icon == null) {
- skin = xp.getSkin(c, part);
- skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
- }
- }
- }
- }
- if (icon != null) {
- icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
- }
- }
- private static WindowsMenuItemUIAccessor getAccessor(
- JMenuItem menuItem) {
- WindowsMenuItemUIAccessor rv = null;
- ButtonUI uiObject = (menuItem != null) ? menuItem.getUI()
- : null;
- if (uiObject instanceof WindowsMenuItemUI) {
- rv = ((WindowsMenuItemUI) uiObject).accessor;
- } else if (uiObject instanceof WindowsMenuUI) {
- rv = ((WindowsMenuUI) uiObject).accessor;
- } else if (uiObject instanceof WindowsCheckBoxMenuItemUI) {
- rv = ((WindowsCheckBoxMenuItemUI) uiObject).accessor;
- } else if (uiObject instanceof WindowsRadioButtonMenuItemUI) {
- rv = ((WindowsRadioButtonMenuItemUI) uiObject).accessor;
- }
- return rv;
- }
-
- private static boolean isEnabled(Component c, State state) {
- if (state == null && c instanceof JMenuItem) {
- WindowsMenuItemUIAccessor accessor =
- getAccessor((JMenuItem) c);
- if (accessor != null) {
- state = accessor.getState((JMenuItem) c);
- }
- }
- if (state == null) {
- if (c != null) {
- return c.isEnabled();
- } else {
- return true;
- }
- } else {
- return (state != State.DISABLED)
- && (state != State.DISABLEDHOT)
- && (state != State.DISABLEDPUSHED);
- }
- }
- private Icon getIcon() {
- Icon rv = null;
- if (menuItem == null) {
- return rv;
- }
- WindowsMenuItemUIAccessor accessor =
- getAccessor(menuItem);
- State state = (accessor != null) ? accessor.getState(menuItem)
- : null;
- if (isEnabled(menuItem, null)) {
- if (state == State.PUSHED) {
- rv = menuItem.getPressedIcon();
- } else {
- rv = menuItem.getIcon();
- }
- } else {
- rv = menuItem.getDisabledIcon();
- }
- return rv;
- }
- /**
- * Check if developer changed icon in the UI table.
- *
- * @return the icon to use or {@code null} if the current one is to
- * be used
- */
- private Icon getLaFIcon() {
- // use icon from the UI table if it does not match this one.
- Icon rv = (Icon) UIManager.getDefaults().get(typeToString(type));
- if (rv instanceof VistaMenuItemCheckIcon
- && ((VistaMenuItemCheckIcon) rv).type == type) {
- rv = null;
- }
- return rv;
- }
-
- private static String typeToString(
- Class<? extends JMenuItem> type) {
- assert type == JMenuItem.class
- || type == JMenu.class
- || type == JCheckBoxMenuItem.class
- || type == JRadioButtonMenuItem.class;
- StringBuilder sb = new StringBuilder(type.getName());
- // remove package name, dot and the first character
- sb.delete(0, sb.lastIndexOf("J") + 1);
- sb.append(".checkIcon");
- return sb.toString();
- }
- }
- } // End class VistaMenuItemCheckIconFactory
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,572 +0,0 @@
-/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.swing.SwingUtilities2;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.UIManager;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
-import java.awt.*;
-import java.awt.event.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-@SuppressWarnings("serial") // Superclass is not serializable across versions
-public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
- private Color selectedTitleGradientColor;
- private Color notSelectedTitleGradientColor;
- private JPopupMenu systemPopupMenu;
- private JLabel systemLabel;
-
- private Font titleFont;
- private int titlePaneHeight;
- private int buttonWidth, buttonHeight;
- private boolean hotTrackingOn;
-
- public WindowsInternalFrameTitlePane(JInternalFrame f) {
- super(f);
- }
-
- protected void addSubComponents() {
- add(systemLabel);
- add(iconButton);
- add(maxButton);
- add(closeButton);
- }
-
- protected void installDefaults() {
- super.installDefaults();
-
- titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
- buttonWidth = UIManager.getInt("InternalFrame.titleButtonWidth") - 4;
- buttonHeight = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
-
- Object obj = UIManager.get("InternalFrame.titleButtonToolTipsOn");
- hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
-
-
- if (XPStyle.getXP() != null) {
- // Fix for XP bug where sometimes these sizes aren't updated properly
- // Assume for now that height is correct and derive width using the
- // ratio from the uxtheme part
- buttonWidth = buttonHeight;
- Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
- if (d != null && d.width != 0 && d.height != 0) {
- buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
- }
- } else {
- buttonWidth += 2;
- Color activeBorderColor =
- UIManager.getColor("InternalFrame.activeBorderColor");
- setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
- }
- // JDK-8039383: initialize these colors because getXP() may return null when theme is changed
- selectedTitleGradientColor =
- UIManager.getColor("InternalFrame.activeTitleGradient");
- notSelectedTitleGradientColor =
- UIManager.getColor("InternalFrame.inactiveTitleGradient");
- }
-
- protected void uninstallListeners() {
- // Get around protected method in superclass
- super.uninstallListeners();
- }
-
- protected void createButtons() {
- super.createButtons();
- if (XPStyle.getXP() != null) {
- iconButton.setContentAreaFilled(false);
- maxButton.setContentAreaFilled(false);
- closeButton.setContentAreaFilled(false);
- }
- }
-
- protected void setButtonIcons() {
- super.setButtonIcons();
-
- if (!hotTrackingOn) {
- iconButton.setToolTipText(null);
- maxButton.setToolTipText(null);
- closeButton.setToolTipText(null);
- }
- }
-
-
- public void paintComponent(Graphics g) {
- XPStyle xp = XPStyle.getXP();
-
- paintTitleBackground(g);
-
- String title = frame.getTitle();
- if (title != null) {
- boolean isSelected = frame.isSelected();
- Font oldFont = g.getFont();
- Font newFont = (titleFont != null) ? titleFont : getFont();
- g.setFont(newFont);
-
- // Center text vertically.
- FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, newFont);
- int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
- fm.getDescent()) / 2;
-
- Rectangle lastIconBounds = new Rectangle(0, 0, 0, 0);
- if (frame.isIconifiable()) {
- lastIconBounds = iconButton.getBounds();
- } else if (frame.isMaximizable()) {
- lastIconBounds = maxButton.getBounds();
- } else if (frame.isClosable()) {
- lastIconBounds = closeButton.getBounds();
- }
-
- int titleX;
- int titleW;
- int gap = 2;
- if (WindowsGraphicsUtils.isLeftToRight(frame)) {
- if (lastIconBounds.x == 0) { // There are no icons
- lastIconBounds.x = frame.getWidth() - frame.getInsets().right;
- }
- titleX = systemLabel.getX() + systemLabel.getWidth() + gap;
- if (xp != null) {
- titleX += 2;
- }
- titleW = lastIconBounds.x - titleX - gap;
- } else {
- if (lastIconBounds.x == 0) { // There are no icons
- lastIconBounds.x = frame.getInsets().left;
- }
- titleW = SwingUtilities2.stringWidth(frame, fm, title);
- int minTitleX = lastIconBounds.x + lastIconBounds.width + gap;
- if (xp != null) {
- minTitleX += 2;
- }
- int availableWidth = systemLabel.getX() - gap - minTitleX;
- if (availableWidth > titleW) {
- titleX = systemLabel.getX() - gap - titleW;
- } else {
- titleX = minTitleX;
- titleW = availableWidth;
- }
- }
- title = getTitle(frame.getTitle(), fm, titleW);
-
- if (xp != null) {
- String shadowType = null;
- if (isSelected) {
- shadowType = xp.getString(this, Part.WP_CAPTION,
- State.ACTIVE, Prop.TEXTSHADOWTYPE);
- }
- if ("single".equalsIgnoreCase(shadowType)) {
- Point shadowOffset = xp.getPoint(this, Part.WP_WINDOW, State.ACTIVE,
- Prop.TEXTSHADOWOFFSET);
- Color shadowColor = xp.getColor(this, Part.WP_WINDOW, State.ACTIVE,
- Prop.TEXTSHADOWCOLOR, null);
- if (shadowOffset != null && shadowColor != null) {
- g.setColor(shadowColor);
- SwingUtilities2.drawString(frame, g, title,
- titleX + shadowOffset.x,
- baseline + shadowOffset.y);
- }
- }
- }
- g.setColor(isSelected ? selectedTextColor : notSelectedTextColor);
- SwingUtilities2.drawString(frame, g, title, titleX, baseline);
- g.setFont(oldFont);
- }
- }
-
- public Dimension getPreferredSize() {
- return getMinimumSize();
- }
-
- public Dimension getMinimumSize() {
- Dimension d = new Dimension(super.getMinimumSize());
- d.height = titlePaneHeight + 2;
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- // Note: Don't know how to calculate height on XP,
- // the captionbarheight is 25 but native caption is 30 (maximized 26)
- if (frame.isMaximum()) {
- d.height -= 1;
- } else {
- d.height += 3;
- }
- }
- return d;
- }
-
- protected void paintTitleBackground(Graphics g) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Part part = frame.isIcon() ? Part.WP_MINCAPTION
- : (frame.isMaximum() ? Part.WP_MAXCAPTION
- : Part.WP_CAPTION);
- State state = frame.isSelected() ? State.ACTIVE : State.INACTIVE;
- Skin skin = xp.getSkin(this, part);
- skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
- } else {
- Boolean gradientsOn = (Boolean)LookAndFeel.getDesktopPropertyValue(
- "win.frame.captionGradientsOn", Boolean.valueOf(false));
- if (gradientsOn.booleanValue() && g instanceof Graphics2D) {
- Graphics2D g2 = (Graphics2D)g;
- Paint savePaint = g2.getPaint();
-
- boolean isSelected = frame.isSelected();
- int w = getWidth();
-
- if (isSelected) {
- GradientPaint titleGradient = new GradientPaint(0,0,
- selectedTitleColor,
- (int)(w*.75),0,
- selectedTitleGradientColor);
- g2.setPaint(titleGradient);
- } else {
- GradientPaint titleGradient = new GradientPaint(0,0,
- notSelectedTitleColor,
- (int)(w*.75),0,
- notSelectedTitleGradientColor);
- g2.setPaint(titleGradient);
- }
- g2.fillRect(0, 0, getWidth(), getHeight());
- g2.setPaint(savePaint);
- } else {
- super.paintTitleBackground(g);
- }
- }
- }
-
- protected void assembleSystemMenu() {
- systemPopupMenu = new JPopupMenu();
- addSystemMenuItems(systemPopupMenu);
- enableActions();
- @SuppressWarnings("serial") // anonymous class
- JLabel tmp = new JLabel(frame.getFrameIcon()) {
- protected void paintComponent(Graphics g) {
- int x = 0;
- int y = 0;
- int w = getWidth();
- int h = getHeight();
- g = g.create(); // Create scratch graphics
- if (isOpaque()) {
- g.setColor(getBackground());
- g.fillRect(0, 0, w, h);
- }
- Icon icon = getIcon();
- int iconWidth;
- int iconHeight;
- if (icon != null &&
- (iconWidth = icon.getIconWidth()) > 0 &&
- (iconHeight = icon.getIconHeight()) > 0) {
-
- // Set drawing scale to make icon scale to our desired size
- double drawScale;
- if (iconWidth > iconHeight) {
- // Center icon vertically
- y = (h - w*iconHeight/iconWidth) / 2;
- drawScale = w / (double)iconWidth;
- } else {
- // Center icon horizontally
- x = (w - h*iconWidth/iconHeight) / 2;
- drawScale = h / (double)iconHeight;
- }
- ((Graphics2D)g).translate(x, y);
- ((Graphics2D)g).scale(drawScale, drawScale);
- icon.paintIcon(this, g, 0, 0);
- }
- g.dispose();
- }
- };
- systemLabel = tmp;
- systemLabel.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2 && frame.isClosable() &&
- !frame.isIcon()) {
- systemPopupMenu.setVisible(false);
- frame.doDefaultCloseAction();
- }
- else {
- super.mouseClicked(e);
- }
- }
- public void mousePressed(MouseEvent e) {
- try {
- frame.setSelected(true);
- } catch(PropertyVetoException pve) {
- }
- showSystemPopupMenu(e.getComponent());
- }
- });
- }
-
- protected void addSystemMenuItems(JPopupMenu menu) {
- JMenuItem mi = menu.add(restoreAction);
- mi.setMnemonic(getButtonMnemonic("restore"));
- mi = menu.add(moveAction);
- mi.setMnemonic(getButtonMnemonic("move"));
- mi = menu.add(sizeAction);
- mi.setMnemonic(getButtonMnemonic("size"));
- mi = menu.add(iconifyAction);
- mi.setMnemonic(getButtonMnemonic("minimize"));
- mi = menu.add(maximizeAction);
- mi.setMnemonic(getButtonMnemonic("maximize"));
- menu.add(new JSeparator());
- mi = menu.add(closeAction);
- mi.setMnemonic(getButtonMnemonic("close"));
- }
-
- private static int getButtonMnemonic(String button) {
- try {
- return Integer.parseInt(UIManager.getString(
- "InternalFrameTitlePane." + button + "Button.mnemonic"));
- } catch (NumberFormatException e) {
- return -1;
- }
- }
-
- protected void showSystemMenu(){
- showSystemPopupMenu(systemLabel);
- }
-
- private void showSystemPopupMenu(Component invoker){
- Dimension dim = new Dimension();
- Border border = frame.getBorder();
- if (border != null) {
- dim.width += border.getBorderInsets(frame).left +
- border.getBorderInsets(frame).right;
- dim.height += border.getBorderInsets(frame).bottom +
- border.getBorderInsets(frame).top;
- }
- if (!frame.isIcon()) {
- systemPopupMenu.show(invoker,
- getX() - dim.width,
- getY() + getHeight() - dim.height);
- } else {
- systemPopupMenu.show(invoker,
- getX() - dim.width,
- getY() - systemPopupMenu.getPreferredSize().height -
- dim.height);
- }
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return new WindowsPropertyChangeHandler();
- }
-
- protected LayoutManager createLayout() {
- return new WindowsTitlePaneLayout();
- }
-
- public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
- private Insets captionMargin = null;
- private Insets contentMargin = null;
- private XPStyle xp = XPStyle.getXP();
-
- WindowsTitlePaneLayout() {
- if (xp != null) {
- Component c = WindowsInternalFrameTitlePane.this;
- captionMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CAPTIONMARGINS);
- contentMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CONTENTMARGINS);
- }
- if (captionMargin == null) {
- captionMargin = new Insets(0, 2, 0, 2);
- }
- if (contentMargin == null) {
- contentMargin = new Insets(0, 0, 0, 0);
- }
- }
-
- private int layoutButton(JComponent button, Part part,
- int x, int y, int w, int h, int gap,
- boolean leftToRight) {
- if (!leftToRight) {
- x -= w;
- }
- button.setBounds(x, y, w, h);
- if (leftToRight) {
- x += w + 2;
- } else {
- x -= 2;
- }
- return x;
- }
-
- public void layoutContainer(Container c) {
- boolean leftToRight = WindowsGraphicsUtils.isLeftToRight(frame);
- int x, y;
- int w = getWidth();
- int h = getHeight();
-
- // System button
- // Note: this icon is square, but the buttons aren't always.
- int iconSize = (xp != null) ? (h-2)*6/10 : h-4;
- if (xp != null) {
- x = (leftToRight) ? captionMargin.left + 2 : w - captionMargin.right - 2;
- } else {
- x = (leftToRight) ? captionMargin.left : w - captionMargin.right;
- }
- y = (h - iconSize) / 2;
- layoutButton(systemLabel, Part.WP_SYSBUTTON,
- x, y, iconSize, iconSize, 0,
- leftToRight);
-
- // Right hand buttons
- if (xp != null) {
- x = (leftToRight) ? w - captionMargin.right - 2 : captionMargin.left + 2;
- y = 1; // XP seems to ignore margins and offset here
- if (frame.isMaximum()) {
- y += 1;
- } else {
- y += 5;
- }
- } else {
- x = (leftToRight) ? w - captionMargin.right : captionMargin.left;
- y = (h - buttonHeight) / 2;
- }
-
- if(frame.isClosable()) {
- x = layoutButton(closeButton, Part.WP_CLOSEBUTTON,
- x, y, buttonWidth, buttonHeight, 2,
- !leftToRight);
- }
-
- if(frame.isMaximizable()) {
- x = layoutButton(maxButton, Part.WP_MAXBUTTON,
- x, y, buttonWidth, buttonHeight, (xp != null) ? 2 : 0,
- !leftToRight);
- }
-
- if(frame.isIconifiable()) {
- layoutButton(iconButton, Part.WP_MINBUTTON,
- x, y, buttonWidth, buttonHeight, 0,
- !leftToRight);
- }
- }
- } // end WindowsTitlePaneLayout
-
- public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
- public void propertyChange(PropertyChangeEvent evt) {
- String prop = evt.getPropertyName();
-
- // Update the internal frame icon for the system menu.
- if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
- systemLabel != null) {
- systemLabel.setIcon(frame.getFrameIcon());
- }
-
- super.propertyChange(evt);
- }
- }
-
- /**
- * A versatile Icon implementation which can take an array of Icon
- * instances (typically <code>ImageIcon</code>s) and choose one that gives the best
- * quality for a given Graphics2D scale factor when painting.
- * <p>
- * The class is public so it can be instantiated by UIDefaults.ProxyLazyValue.
- * <p>
- * Note: We assume here that icons are square.
- */
- public static class ScalableIconUIResource implements Icon, UIResource {
- // We can use an arbitrary size here because we scale to it in paintIcon()
- private static final int SIZE = 16;
-
- private Icon[] icons;
-
- /**
- * @param objects an array of Icon or UIDefaults.LazyValue
- * <p>
- * The constructor is public so it can be called by UIDefaults.ProxyLazyValue.
- */
- public ScalableIconUIResource(Object[] objects) {
- this.icons = new Icon[objects.length];
-
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof UIDefaults.LazyValue) {
- icons[i] = (Icon)((UIDefaults.LazyValue)objects[i]).createValue(null);
- } else {
- icons[i] = (Icon)objects[i];
- }
- }
- }
-
- /**
- * @return the <code>Icon</code> closest to the requested size
- */
- protected Icon getBestIcon(int size) {
- if (icons != null && icons.length > 0) {
- int bestIndex = 0;
- int minDiff = Integer.MAX_VALUE;
- for (int i=0; i < icons.length; i++) {
- Icon icon = icons[i];
- int iconSize;
- if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
- int diff = Math.abs(iconSize - size);
- if (diff < minDiff) {
- minDiff = diff;
- bestIndex = i;
- }
- }
- }
- return icons[bestIndex];
- } else {
- return null;
- }
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- Graphics2D g2d = (Graphics2D)g.create();
- // Calculate how big our drawing area is in pixels
- // Assume we are square
- int size = getIconWidth();
- double scale = g2d.getTransform().getScaleX();
- Icon icon = getBestIcon((int)(size * scale));
- int iconSize;
- if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
- // Set drawing scale to make icon act true to our reported size
- double drawScale = size / (double)iconSize;
- g2d.translate(x, y);
- g2d.scale(drawScale, drawScale);
- icon.paintIcon(c, g2d, 0, 0);
- }
- g2d.dispose();
- }
-
- public int getIconWidth() {
- return SIZE;
- }
-
- public int getIconHeight() {
- return SIZE;
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.beans.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.ComponentUI;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsInternalFrameUI extends BasicInternalFrameUI
-{
- XPStyle xp = XPStyle.getXP();
-
- public void installDefaults() {
- super.installDefaults();
-
- if (xp != null) {
- frame.setBorder(new XPBorder());
- } else {
- frame.setBorder(UIManager.getBorder("InternalFrame.border"));
- }
- }
-
- public void installUI(JComponent c) {
- super.installUI(c);
-
- LookAndFeel.installProperty(c, "opaque",
- xp == null? Boolean.TRUE : Boolean.FALSE);
- }
-
- public void uninstallDefaults() {
- frame.setBorder(null);
- super.uninstallDefaults();
- }
-
- public static ComponentUI createUI(JComponent b) {
- return new WindowsInternalFrameUI((JInternalFrame)b);
- }
-
- public WindowsInternalFrameUI(JInternalFrame w){
- super(w);
- }
-
- protected DesktopManager createDesktopManager(){
- return new WindowsDesktopManager();
- }
-
- protected JComponent createNorthPane(JInternalFrame w) {
- titlePane = new WindowsInternalFrameTitlePane(w);
- return titlePane;
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPBorder extends AbstractBorder {
- private Skin leftSkin = xp.getSkin(frame, Part.WP_FRAMELEFT);
- private Skin rightSkin = xp.getSkin(frame, Part.WP_FRAMERIGHT);
- private Skin bottomSkin = xp.getSkin(frame, Part.WP_FRAMEBOTTOM);
-
- /**
- * @param x the x position of the painted border
- * @param y the y position of the painted border
- * @param width the width of the painted border
- * @param height the height of the painted border
- */
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- State state = ((JInternalFrame)c).isSelected() ? State.ACTIVE : State.INACTIVE;
- int topBorderHeight = (titlePane != null) ? titlePane.getSize().height : 0;
-
- bottomSkin.paintSkin(g, 0, height-bottomSkin.getHeight(),
- width, bottomSkin.getHeight(),
- state);
-
- leftSkin.paintSkin(g, 0, topBorderHeight-1,
- leftSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
- state);
-
- rightSkin.paintSkin(g, width-rightSkin.getWidth(), topBorderHeight-1,
- rightSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
- state);
-
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- insets.top = 4;
- insets.left = leftSkin.getWidth();
- insets.right = rightSkin.getWidth();
- insets.bottom = bottomSkin.getHeight();
-
- return insets;
- }
-
- public boolean isBorderOpaque() {
- return true;
- }
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.swing.SwingUtilities2;
-import sun.awt.AppContext;
-
-import java.awt.Color;
-import java.awt.Graphics;
-
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.UIManager;
-
-import javax.swing.plaf.ComponentUI;
-
-import javax.swing.plaf.basic.BasicLabelUI;
-
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsLabelUI extends BasicLabelUI {
-
- private static final Object WINDOWS_LABEL_UI_KEY = new Object();
-
- // ********************************
- // Create PLAF
- // ********************************
- public static ComponentUI createUI(JComponent c) {
- AppContext appContext = AppContext.getAppContext();
- WindowsLabelUI windowsLabelUI =
- (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
- if (windowsLabelUI == null) {
- windowsLabelUI = new WindowsLabelUI();
- appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
- }
- return windowsLabelUI;
- }
-
- protected void paintEnabledText(JLabel l, Graphics g, String s,
- int textX, int textY) {
- int mnemonicIndex = l.getDisplayedMnemonicIndex();
- // W2K Feature: Check to see if the Underscore should be rendered.
- if (WindowsLookAndFeel.isMnemonicHidden() == true) {
- mnemonicIndex = -1;
- }
-
- g.setColor(l.getForeground());
- SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
- textX, textY);
- }
-
- protected void paintDisabledText(JLabel l, Graphics g, String s,
- int textX, int textY) {
- int mnemonicIndex = l.getDisplayedMnemonicIndex();
- // W2K Feature: Check to see if the Underscore should be rendered.
- if (WindowsLookAndFeel.isMnemonicHidden() == true) {
- mnemonicIndex = -1;
- }
- if ( UIManager.getColor("Label.disabledForeground") instanceof Color &&
- UIManager.getColor("Label.disabledShadow") instanceof Color) {
- g.setColor( UIManager.getColor("Label.disabledShadow") );
- SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
- mnemonicIndex,
- textX + 1, textY + 1);
- g.setColor( UIManager.getColor("Label.disabledForeground") );
- SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
- mnemonicIndex,
- textX, textY);
- } else {
- Color background = l.getBackground();
- g.setColor(background.brighter());
- SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
- textX + 1, textY + 1);
- g.setColor(background.darker());
- SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
- textX, textY);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2588 +0,0 @@
-/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * <p>These classes are designed to be used while the
- * corresponding <code>LookAndFeel</code> class has been installed
- * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
- * Using them while a different <code>LookAndFeel</code> is installed
- * may produce unexpected results, including exceptions.
- * Additionally, changing the <code>LookAndFeel</code>
- * maintained by the <code>UIManager</code> without updating the
- * corresponding <code>ComponentUI</code> of any
- * <code>JComponent</code>s may also produce unexpected results,
- * such as the wrong colors showing up, and is generally not
- * encouraged.
- *
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.image.ImageFilter;
-import java.awt.image.ImageProducer;
-import java.awt.image.FilteredImageSource;
-import java.awt.image.RGBImageFilter;
-
-import javax.swing.plaf.*;
-import javax.swing.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.border.*;
-import javax.swing.text.DefaultEditorKit;
-import static javax.swing.UIDefaults.LazyValue;
-
-import java.awt.Font;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-
-import java.security.AccessController;
-
-import sun.awt.SunToolkit;
-import sun.awt.OSInfo;
-import sun.awt.shell.ShellFolder;
-import sun.font.FontUtilities;
-import sun.security.action.GetPropertyAction;
-
-import sun.swing.DefaultLayoutStyle;
-import sun.swing.ImageIconUIResource;
-import sun.swing.SwingAccessor;
-import sun.swing.icon.SortArrowIcon;
-import sun.swing.SwingUtilities2;
-import sun.swing.StringUIClientPropertyKey;
-import sun.swing.plaf.windows.ClassicSortArrowIcon;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-import com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory;
-
-/**
- * Implements the Windows95/98/NT/2000 Look and Feel.
- * UI classes not implemented specifically for Windows will
- * default to those implemented in Basic.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author unattributed
- */
-@SuppressWarnings("serial") // Superclass is not serializable across versions
-public class WindowsLookAndFeel extends BasicLookAndFeel
-{
- /**
- * A client property that can be used with any JComponent that will end up
- * calling the LookAndFeel.getDisabledIcon method. This client property,
- * when set to Boolean.TRUE, will cause getDisabledIcon to use an
- * alternate algorithm for creating disabled icons to produce icons
- * that appear similar to the native Windows file chooser
- */
- static final Object HI_RES_DISABLED_ICON_CLIENT_KEY =
- new StringUIClientPropertyKey(
- "WindowsLookAndFeel.generateHiResDisabledIcon");
-
- private boolean updatePending = false;
-
- private boolean useSystemFontSettings = true;
- private boolean useSystemFontSizeSettings;
-
- // These properties are not used directly, but are kept as
- // private members to avoid being GC'd.
- private WindowsDesktopProperty themeActive, dllName, colorName, sizeName;
- private WindowsDesktopProperty aaSettings;
-
- private transient LayoutStyle style;
-
- /**
- * Base dialog units along the horizontal axis.
- */
- private int baseUnitX;
-
- /**
- * Base dialog units along the vertical axis.
- */
- private int baseUnitY;
-
- public String getName() {
- return "Windows";
- }
-
- public String getDescription() {
- return "The Microsoft Windows Look and Feel";
- }
-
- public String getID() {
- return "Windows";
- }
-
- public boolean isNativeLookAndFeel() {
- return OSInfo.getOSType() == OSInfo.OSType.WINDOWS;
- }
-
- public boolean isSupportedLookAndFeel() {
- return isNativeLookAndFeel();
- }
-
- public void initialize() {
- super.initialize();
-
- // Set the flag which determines which version of Windows should
- // be rendered. This flag only need to be set once.
- // if version <= 4.0 then the classic LAF should be loaded.
- if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
- isClassicWindows = true;
- } else {
- isClassicWindows = false;
- XPStyle.invalidateStyle();
- }
-
- // Using the fonts set by the user can potentially cause
- // performance and compatibility issues, so allow this feature
- // to be switched off either at runtime or programmatically
- //
- String systemFonts = java.security.AccessController.doPrivileged(
- new GetPropertyAction("swing.useSystemFontSettings"));
- useSystemFontSettings = (systemFonts == null ||
- Boolean.valueOf(systemFonts).booleanValue());
-
- if (useSystemFontSettings) {
- Object value = UIManager.get("Application.useSystemFontSettings");
-
- useSystemFontSettings = (value == null ||
- Boolean.TRUE.equals(value));
- }
- KeyboardFocusManager.getCurrentKeyboardFocusManager().
- addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
-
- }
-
- /**
- * Initialize the uiClassID to BasicComponentUI mapping.
- * The JComponent classes define their own uiClassID constants
- * (see AbstractComponent.getUIClassID). This table must
- * map those constants to a BasicComponentUI class of the
- * appropriate type.
- *
- * @see BasicLookAndFeel#getDefaults
- */
- protected void initClassDefaults(UIDefaults table)
- {
- super.initClassDefaults(table);
-
- final String windowsPackageName = "com.sun.java.swing.plaf.windows.";
-
- Object[] uiDefaults = {
- "ButtonUI", windowsPackageName + "WindowsButtonUI",
- "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI",
- "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI",
- "LabelUI", windowsPackageName + "WindowsLabelUI",
- "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI",
- "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI",
- "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI",
- "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI",
- "SliderUI", windowsPackageName + "WindowsSliderUI",
- "SeparatorUI", windowsPackageName + "WindowsSeparatorUI",
- "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI",
- "SpinnerUI", windowsPackageName + "WindowsSpinnerUI",
- "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI",
- "TextAreaUI", windowsPackageName + "WindowsTextAreaUI",
- "TextFieldUI", windowsPackageName + "WindowsTextFieldUI",
- "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI",
- "TextPaneUI", windowsPackageName + "WindowsTextPaneUI",
- "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI",
- "TreeUI", windowsPackageName + "WindowsTreeUI",
- "ToolBarUI", windowsPackageName + "WindowsToolBarUI",
- "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI",
- "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI",
- "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI",
- "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI",
- "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI",
- "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI",
- "FileChooserUI", windowsPackageName + "WindowsFileChooserUI",
- "MenuUI", windowsPackageName + "WindowsMenuUI",
- "MenuItemUI", windowsPackageName + "WindowsMenuItemUI",
- "MenuBarUI", windowsPackageName + "WindowsMenuBarUI",
- "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI",
- "PopupMenuSeparatorUI", windowsPackageName + "WindowsPopupMenuSeparatorUI",
- "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI",
- "RootPaneUI", windowsPackageName + "WindowsRootPaneUI"
- };
-
- table.putDefaults(uiDefaults);
- }
-
- /**
- * Load the SystemColors into the defaults table. The keys
- * for SystemColor defaults are the same as the names of
- * the public fields in SystemColor. If the table is being
- * created on a native Windows platform we use the SystemColor
- * values, otherwise we create color objects whose values match
- * the defaults Windows95 colors.
- */
- protected void initSystemColorDefaults(UIDefaults table)
- {
- String[] defaultSystemColors = {
- "desktop", "#005C5C", /* Color of the desktop background */
- "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
- "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
- "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
- "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
- "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
- "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
- "window", "#FFFFFF", /* Default color for the interior of windows */
- "windowBorder", "#000000", /* ??? */
- "windowText", "#000000", /* ??? */
- "menu", "#C0C0C0", /* Background color for menus */
- "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */
- "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */
- "menuText", "#000000", /* Text color for menus */
- "text", "#C0C0C0", /* Text background color */
- "textText", "#000000", /* Text foreground color */
- "textHighlight", "#000080", /* Text background color when selected */
- "textHighlightText", "#FFFFFF", /* Text color when selected */
- "textInactiveText", "#808080", /* Text color when disabled */
- "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
- "controlText", "#000000", /* Default color for text in controls */
- "controlHighlight", "#C0C0C0",
-
- /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */
- "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
- "controlShadow", "#808080", /* Shadow color for controls */
- "controlDkShadow", "#000000", /* Dark shadow color for controls */
- "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
- "info", "#FFFFE1", /* ??? */
- "infoText", "#000000" /* ??? */
- };
-
- loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
- }
-
- /**
- * Initialize the defaults table with the name of the ResourceBundle
- * used for getting localized defaults.
- */
- private void initResourceBundle(UIDefaults table) {
- SwingAccessor.getUIDefaultsAccessor()
- .addInternalBundle(table,
- "com.sun.java.swing.plaf.windows.resources.windows");
- }
-
- // XXX - there are probably a lot of redundant values that could be removed.
- // ie. Take a look at RadioButtonBorder, etc...
- protected void initComponentDefaults(UIDefaults table)
- {
- super.initComponentDefaults( table );
-
- initResourceBundle(table);
-
- // *** Shared Fonts
- LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
-
- LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
- LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
- LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
-
- // *** Colors
- // XXX - some of these doens't seem to be used
- ColorUIResource red = new ColorUIResource(Color.red);
- ColorUIResource black = new ColorUIResource(Color.black);
- ColorUIResource white = new ColorUIResource(Color.white);
- ColorUIResource gray = new ColorUIResource(Color.gray);
- ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
- ColorUIResource scrollBarTrackHighlight = darkGray;
-
- // Set the flag which determines which version of Windows should
- // be rendered. This flag only need to be set once.
- // if version <= 4.0 then the classic LAF should be loaded.
- isClassicWindows = OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0;
-
- // *** Tree
- Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon();
-
- Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon();
-
-
- // *** Text
- Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
- "control C", DefaultEditorKit.copyAction,
- "control V", DefaultEditorKit.pasteAction,
- "control X", DefaultEditorKit.cutAction,
- "COPY", DefaultEditorKit.copyAction,
- "PASTE", DefaultEditorKit.pasteAction,
- "CUT", DefaultEditorKit.cutAction,
- "control INSERT", DefaultEditorKit.copyAction,
- "shift INSERT", DefaultEditorKit.pasteAction,
- "shift DELETE", DefaultEditorKit.cutAction,
- "control A", DefaultEditorKit.selectAllAction,
- "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
- "shift LEFT", DefaultEditorKit.selectionBackwardAction,
- "shift RIGHT", DefaultEditorKit.selectionForwardAction,
- "control LEFT", DefaultEditorKit.previousWordAction,
- "control RIGHT", DefaultEditorKit.nextWordAction,
- "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
- "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
- "HOME", DefaultEditorKit.beginLineAction,
- "END", DefaultEditorKit.endLineAction,
- "shift HOME", DefaultEditorKit.selectionBeginLineAction,
- "shift END", DefaultEditorKit.selectionEndLineAction,
- "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "ctrl H", DefaultEditorKit.deletePrevCharAction,
- "DELETE", DefaultEditorKit.deleteNextCharAction,
- "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
- "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
- "RIGHT", DefaultEditorKit.forwardAction,
- "LEFT", DefaultEditorKit.backwardAction,
- "KP_RIGHT", DefaultEditorKit.forwardAction,
- "KP_LEFT", DefaultEditorKit.backwardAction,
- "ENTER", JTextField.notifyAction,
- "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
- });
-
- Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
- "control C", DefaultEditorKit.copyAction,
- "control V", DefaultEditorKit.pasteAction,
- "control X", DefaultEditorKit.cutAction,
- "COPY", DefaultEditorKit.copyAction,
- "PASTE", DefaultEditorKit.pasteAction,
- "CUT", DefaultEditorKit.cutAction,
- "control INSERT", DefaultEditorKit.copyAction,
- "shift INSERT", DefaultEditorKit.pasteAction,
- "shift DELETE", DefaultEditorKit.cutAction,
- "control A", DefaultEditorKit.selectAllAction,
- "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
- "shift LEFT", DefaultEditorKit.selectionBackwardAction,
- "shift RIGHT", DefaultEditorKit.selectionForwardAction,
- "control LEFT", DefaultEditorKit.beginLineAction,
- "control RIGHT", DefaultEditorKit.endLineAction,
- "control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
- "control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
- "HOME", DefaultEditorKit.beginLineAction,
- "END", DefaultEditorKit.endLineAction,
- "shift HOME", DefaultEditorKit.selectionBeginLineAction,
- "shift END", DefaultEditorKit.selectionEndLineAction,
- "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "ctrl H", DefaultEditorKit.deletePrevCharAction,
- "DELETE", DefaultEditorKit.deleteNextCharAction,
- "RIGHT", DefaultEditorKit.forwardAction,
- "LEFT", DefaultEditorKit.backwardAction,
- "KP_RIGHT", DefaultEditorKit.forwardAction,
- "KP_LEFT", DefaultEditorKit.backwardAction,
- "ENTER", JTextField.notifyAction,
- "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
- });
-
- Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
- "control C", DefaultEditorKit.copyAction,
- "control V", DefaultEditorKit.pasteAction,
- "control X", DefaultEditorKit.cutAction,
- "COPY", DefaultEditorKit.copyAction,
- "PASTE", DefaultEditorKit.pasteAction,
- "CUT", DefaultEditorKit.cutAction,
- "control INSERT", DefaultEditorKit.copyAction,
- "shift INSERT", DefaultEditorKit.pasteAction,
- "shift DELETE", DefaultEditorKit.cutAction,
- "shift LEFT", DefaultEditorKit.selectionBackwardAction,
- "shift RIGHT", DefaultEditorKit.selectionForwardAction,
- "control LEFT", DefaultEditorKit.previousWordAction,
- "control RIGHT", DefaultEditorKit.nextWordAction,
- "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
- "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
- "control A", DefaultEditorKit.selectAllAction,
- "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
- "HOME", DefaultEditorKit.beginLineAction,
- "END", DefaultEditorKit.endLineAction,
- "shift HOME", DefaultEditorKit.selectionBeginLineAction,
- "shift END", DefaultEditorKit.selectionEndLineAction,
- "control HOME", DefaultEditorKit.beginAction,
- "control END", DefaultEditorKit.endAction,
- "control shift HOME", DefaultEditorKit.selectionBeginAction,
- "control shift END", DefaultEditorKit.selectionEndAction,
- "UP", DefaultEditorKit.upAction,
- "DOWN", DefaultEditorKit.downAction,
- "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "ctrl H", DefaultEditorKit.deletePrevCharAction,
- "DELETE", DefaultEditorKit.deleteNextCharAction,
- "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
- "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
- "RIGHT", DefaultEditorKit.forwardAction,
- "LEFT", DefaultEditorKit.backwardAction,
- "KP_RIGHT", DefaultEditorKit.forwardAction,
- "KP_LEFT", DefaultEditorKit.backwardAction,
- "PAGE_UP", DefaultEditorKit.pageUpAction,
- "PAGE_DOWN", DefaultEditorKit.pageDownAction,
- "shift PAGE_UP", "selection-page-up",
- "shift PAGE_DOWN", "selection-page-down",
- "ctrl shift PAGE_UP", "selection-page-left",
- "ctrl shift PAGE_DOWN", "selection-page-right",
- "shift UP", DefaultEditorKit.selectionUpAction,
- "shift DOWN", DefaultEditorKit.selectionDownAction,
- "ENTER", DefaultEditorKit.insertBreakAction,
- "TAB", DefaultEditorKit.insertTabAction,
- "control T", "next-link-action",
- "control shift T", "previous-link-action",
- "control SPACE", "activate-link-action",
- "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
- });
-
- Object menuItemAcceleratorDelimiter = "+";
-
- Object ControlBackgroundColor = new WindowsDesktopProperty(
- "win.3d.backgroundColor",
- table.get("control"));
- Object ControlLightColor = new WindowsDesktopProperty(
- "win.3d.lightColor",
- table.get("controlHighlight"));
- Object ControlHighlightColor = new WindowsDesktopProperty(
- "win.3d.highlightColor",
- table.get("controlLtHighlight"));
- Object ControlShadowColor = new WindowsDesktopProperty(
- "win.3d.shadowColor",
- table.get("controlShadow"));
- Object ControlDarkShadowColor = new WindowsDesktopProperty(
- "win.3d.darkShadowColor",
- table.get("controlDkShadow"));
- Object ControlTextColor = new WindowsDesktopProperty(
- "win.button.textColor",
- table.get("controlText"));
- Object MenuBackgroundColor = new WindowsDesktopProperty(
- "win.menu.backgroundColor",
- table.get("menu"));
- Object MenuBarBackgroundColor = new WindowsDesktopProperty(
- "win.menubar.backgroundColor",
- table.get("menu"));
- Object MenuTextColor = new WindowsDesktopProperty(
- "win.menu.textColor",
- table.get("menuText"));
- Object SelectionBackgroundColor = new WindowsDesktopProperty(
- "win.item.highlightColor",
- table.get("textHighlight"));
- Object SelectionTextColor = new WindowsDesktopProperty(
- "win.item.highlightTextColor",
- table.get("textHighlightText"));
- Object WindowBackgroundColor = new WindowsDesktopProperty(
- "win.frame.backgroundColor",
- table.get("window"));
- Object WindowTextColor = new WindowsDesktopProperty(
- "win.frame.textColor",
- table.get("windowText"));
- Object WindowBorderWidth = new WindowsDesktopProperty(
- "win.frame.sizingBorderWidth",
- Integer.valueOf(1));
- Object TitlePaneHeight = new WindowsDesktopProperty(
- "win.frame.captionHeight",
- Integer.valueOf(18));
- Object TitleButtonWidth = new WindowsDesktopProperty(
- "win.frame.captionButtonWidth",
- Integer.valueOf(16));
- Object TitleButtonHeight = new WindowsDesktopProperty(
- "win.frame.captionButtonHeight",
- Integer.valueOf(16));
- Object InactiveTextColor = new WindowsDesktopProperty(
- "win.text.grayedTextColor",
- table.get("textInactiveText"));
- Object ScrollbarBackgroundColor = new WindowsDesktopProperty(
- "win.scrollbar.backgroundColor",
- table.get("scrollbar"));
- Object buttonFocusColor = new FocusColorProperty();
-
- Object TextBackground = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
- WindowBackgroundColor);
- //The following four lines were commented out as part of bug 4991597
- //This code *is* correct, however it differs from WindowsXP and is, apparently
- //a Windows XP bug. Until Windows fixes this bug, we shall also exhibit the same
- //behavior
- //Object ReadOnlyTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.READONLY, Prop.FILLCOLOR,
- // ControlBackgroundColor);
- //Object DisabledTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.DISABLED, Prop.FILLCOLOR,
- // ControlBackgroundColor);
- Object ReadOnlyTextBackground = ControlBackgroundColor;
- Object DisabledTextBackground = ControlBackgroundColor;
-
- Object MenuFont = dialogPlain12;
- Object FixedControlFont = monospacedPlain12;
- Object ControlFont = dialogPlain12;
- Object MessageFont = dialogPlain12;
- Object WindowFont = dialogBold12;
- Object ToolTipFont = sansSerifPlain12;
- Object IconFont = ControlFont;
-
- Object scrollBarWidth = new WindowsDesktopProperty("win.scrollbar.width", Integer.valueOf(16));
-
- Object menuBarHeight = new WindowsDesktopProperty("win.menu.height", null);
-
- Object hotTrackingOn = new WindowsDesktopProperty("win.item.hotTrackingOn", true);
-
- Object showMnemonics = new WindowsDesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE);
-
- if (useSystemFontSettings) {
- MenuFont = getDesktopFontValue("win.menu.font", MenuFont);
- FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont);
- ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont);
- MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont);
- WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont);
- IconFont = getDesktopFontValue("win.icon.font", IconFont);
- ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont);
-
- /* Put the desktop AA settings in the defaults.
- * JComponent.setUI() retrieves this and makes it available
- * as a client property on the JComponent. Use the same key name
- * for both client property and UIDefaults.
- * Also need to set up listeners for changes in these settings.
- */
- SwingUtilities2.putAATextInfo(true, table);
- this.aaSettings =
- new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
- }
- if (useSystemFontSizeSettings) {
- MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12);
- FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED,
- Font.PLAIN, 12);
- ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12);
- MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12);
- WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12);
- ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12);
- IconFont = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12);
- }
-
-
- if (!(this instanceof WindowsClassicLookAndFeel) &&
- (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
- OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0) &&
- AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) {
-
- // These desktop properties are not used directly, but are needed to
- // trigger realoading of UI's.
- this.themeActive = new TriggerDesktopProperty("win.xpstyle.themeActive");
- this.dllName = new TriggerDesktopProperty("win.xpstyle.dllName");
- this.colorName = new TriggerDesktopProperty("win.xpstyle.colorName");
- this.sizeName = new TriggerDesktopProperty("win.xpstyle.sizeName");
- }
-
-
- Object[] defaults = {
- // *** Auditory Feedback
- // this key defines which of the various cues to render
- // Overridden from BasicL&F. This L&F should play all sounds
- // all the time. The infrastructure decides what to play.
- // This is disabled until sound bugs can be resolved.
- "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"),
-
- "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings),
-
- "TextField.focusInputMap", fieldInputMap,
- "PasswordField.focusInputMap", passwordInputMap,
- "TextArea.focusInputMap", multilineInputMap,
- "TextPane.focusInputMap", multilineInputMap,
- "EditorPane.focusInputMap", multilineInputMap,
-
- // Buttons
- "Button.font", ControlFont,
- "Button.background", ControlBackgroundColor,
- // Button.foreground, Button.shadow, Button.darkShadow,
- // Button.disabledForground, and Button.disabledShadow are only
- // used for Windows Classic. Windows XP will use colors
- // from the current visual style.
- "Button.foreground", ControlTextColor,
- "Button.shadow", ControlShadowColor,
- "Button.darkShadow", ControlDarkShadowColor,
- "Button.light", ControlLightColor,
- "Button.highlight", ControlHighlightColor,
- "Button.disabledForeground", InactiveTextColor,
- "Button.disabledShadow", ControlHighlightColor,
- "Button.focus", buttonFocusColor,
- "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
- "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
- "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
- "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)),
- "Button.textShiftOffset", new XPValue(Integer.valueOf(0),
- Integer.valueOf(1)),
- // W2K keyboard navigation hidding.
- "Button.showMnemonics", showMnemonics,
- "Button.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "SPACE", "pressed",
- "released SPACE", "released"
- }),
-
- "Caret.width",
- new WindowsDesktopProperty("win.caret.width", null),
-
- "CheckBox.font", ControlFont,
- "CheckBox.interiorBackground", WindowBackgroundColor,
- "CheckBox.background", ControlBackgroundColor,
- "CheckBox.foreground", WindowTextColor,
- "CheckBox.shadow", ControlShadowColor,
- "CheckBox.darkShadow", ControlDarkShadowColor,
- "CheckBox.light", ControlLightColor,
- "CheckBox.highlight", ControlHighlightColor,
- "CheckBox.focus", buttonFocusColor,
- "CheckBox.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "SPACE", "pressed",
- "released SPACE", "released"
- }),
- // margin is 2 all the way around, BasicBorders.RadioButtonBorder
- // (checkbox uses RadioButtonBorder) is 2 all the way around too.
- "CheckBox.totalInsets", new Insets(4, 4, 4, 4),
-
- "CheckBoxMenuItem.font", MenuFont,
- "CheckBoxMenuItem.background", MenuBackgroundColor,
- "CheckBoxMenuItem.foreground", MenuTextColor,
- "CheckBoxMenuItem.selectionForeground", SelectionTextColor,
- "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor,
- "CheckBoxMenuItem.acceleratorForeground", MenuTextColor,
- "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor,
- "CheckBoxMenuItem.commandSound", "win.sound.menuCommand",
-
- "ComboBox.font", ControlFont,
- "ComboBox.background", WindowBackgroundColor,
- "ComboBox.foreground", WindowTextColor,
- "ComboBox.buttonBackground", ControlBackgroundColor,
- "ComboBox.buttonShadow", ControlShadowColor,
- "ComboBox.buttonDarkShadow", ControlDarkShadowColor,
- "ComboBox.buttonHighlight", ControlHighlightColor,
- "ComboBox.selectionBackground", SelectionBackgroundColor,
- "ComboBox.selectionForeground", SelectionTextColor,
- "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,4,1,1),
- new EmptyBorder(1,4,1,4)),
- "ComboBox.disabledBackground",
- new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
- Prop.FILLCOLOR, DisabledTextBackground),
- "ComboBox.disabledForeground",
- new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
- Prop.TEXTCOLOR, InactiveTextColor),
- "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
- "ESCAPE", "hidePopup",
- "PAGE_UP", "pageUpPassThrough",
- "PAGE_DOWN", "pageDownPassThrough",
- "HOME", "homePassThrough",
- "END", "endPassThrough",
- "DOWN", "selectNext2",
- "KP_DOWN", "selectNext2",
- "UP", "selectPrevious2",
- "KP_UP", "selectPrevious2",
- "ENTER", "enterPressed",
- "F4", "togglePopup",
- "alt DOWN", "togglePopup",
- "alt KP_DOWN", "togglePopup",
- "alt UP", "togglePopup",
- "alt KP_UP", "togglePopup"
- }),
-
- // DeskTop.
- "Desktop.background", new WindowsDesktopProperty(
- "win.mdi.backgroundColor",
- table.get("desktop")),
- "Desktop.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ctrl F5", "restore",
- "ctrl F4", "close",
- "ctrl F7", "move",
- "ctrl F8", "resize",
- "RIGHT", "right",
- "KP_RIGHT", "right",
- "LEFT", "left",
- "KP_LEFT", "left",
- "UP", "up",
- "KP_UP", "up",
- "DOWN", "down",
- "KP_DOWN", "down",
- "ESCAPE", "escape",
- "ctrl F9", "minimize",
- "ctrl F10", "maximize",
- "ctrl F6", "selectNextFrame",
- "ctrl TAB", "selectNextFrame",
- "ctrl alt F6", "selectNextFrame",
- "shift ctrl alt F6", "selectPreviousFrame",
- "ctrl F12", "navigateNext",
- "shift ctrl F12", "navigatePrevious"
- }),
-
- // DesktopIcon
- "DesktopIcon.width", Integer.valueOf(160),
-
- "EditorPane.font", ControlFont,
- "EditorPane.background", WindowBackgroundColor,
- "EditorPane.foreground", WindowTextColor,
- "EditorPane.selectionBackground", SelectionBackgroundColor,
- "EditorPane.selectionForeground", SelectionTextColor,
- "EditorPane.caretForeground", WindowTextColor,
- "EditorPane.inactiveForeground", InactiveTextColor,
- "EditorPane.inactiveBackground", WindowBackgroundColor,
- "EditorPane.disabledBackground", DisabledTextBackground,
-
- "FileChooser.homeFolderIcon", new LazyWindowsIcon(null,
- "icons/HomeFolder.gif"),
- "FileChooser.listFont", IconFont,
- "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR,
- WindowBackgroundColor),
- "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
- (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
- "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
- "icons/ListView.gif"),
- "FileChooser.listViewWindowsStyle", Boolean.TRUE,
- "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView",
- "icons/DetailsView.gif"),
- "FileChooser.viewMenuIcon", new LazyWindowsIcon("fileChooserIcon ViewMenu",
- "icons/ListView.gif"),
- "FileChooser.upFolderIcon", new LazyWindowsIcon("fileChooserIcon UpFolder",
- "icons/UpFolder.gif"),
- "FileChooser.newFolderIcon", new LazyWindowsIcon("fileChooserIcon NewFolder",
- "icons/NewFolder.gif"),
- "FileChooser.useSystemExtensionHiding", Boolean.TRUE,
-
- "FileChooser.usesSingleFilePane", Boolean.TRUE,
- "FileChooser.noPlacesBar", new WindowsDesktopProperty("win.comdlg.noPlacesBar",
- Boolean.FALSE),
- "FileChooser.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ESCAPE", "cancelSelection",
- "F2", "editFileName",
- "F5", "refresh",
- "BACK_SPACE", "Go Up"
- }),
-
- "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- "icons/Directory.gif"),
- "FileView.fileIcon", SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- "icons/File.gif"),
- "FileView.computerIcon", SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- "icons/Computer.gif"),
- "FileView.hardDriveIcon", SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- "icons/HardDrive.gif"),
- "FileView.floppyDriveIcon", SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- "icons/FloppyDrive.gif"),
-
- "FormattedTextField.font", ControlFont,
- "InternalFrame.titleFont", WindowFont,
- "InternalFrame.titlePaneHeight", TitlePaneHeight,
- "InternalFrame.titleButtonWidth", TitleButtonWidth,
- "InternalFrame.titleButtonHeight", TitleButtonHeight,
- "InternalFrame.titleButtonToolTipsOn", hotTrackingOn,
- "InternalFrame.borderColor", ControlBackgroundColor,
- "InternalFrame.borderShadow", ControlShadowColor,
- "InternalFrame.borderDarkShadow", ControlDarkShadowColor,
- "InternalFrame.borderHighlight", ControlHighlightColor,
- "InternalFrame.borderLight", ControlLightColor,
- "InternalFrame.borderWidth", WindowBorderWidth,
- "InternalFrame.minimizeIconBackground", ControlBackgroundColor,
- "InternalFrame.resizeIconHighlight", ControlLightColor,
- "InternalFrame.resizeIconShadow", ControlShadowColor,
- "InternalFrame.activeBorderColor", new WindowsDesktopProperty(
- "win.frame.activeBorderColor",
- table.get("windowBorder")),
- "InternalFrame.inactiveBorderColor", new WindowsDesktopProperty(
- "win.frame.inactiveBorderColor",
- table.get("windowBorder")),
- "InternalFrame.activeTitleBackground", new WindowsDesktopProperty(
- "win.frame.activeCaptionColor",
- table.get("activeCaption")),
- "InternalFrame.activeTitleGradient", new WindowsDesktopProperty(
- "win.frame.activeCaptionGradientColor",
- table.get("activeCaption")),
- "InternalFrame.activeTitleForeground", new WindowsDesktopProperty(
- "win.frame.captionTextColor",
- table.get("activeCaptionText")),
- "InternalFrame.inactiveTitleBackground", new WindowsDesktopProperty(
- "win.frame.inactiveCaptionColor",
- table.get("inactiveCaption")),
- "InternalFrame.inactiveTitleGradient", new WindowsDesktopProperty(
- "win.frame.inactiveCaptionGradientColor",
- table.get("inactiveCaption")),
- "InternalFrame.inactiveTitleForeground", new WindowsDesktopProperty(
- "win.frame.inactiveCaptionTextColor",
- table.get("inactiveCaptionText")),
-
- "InternalFrame.maximizeIcon",
- WindowsIconFactory.createFrameMaximizeIcon(),
- "InternalFrame.minimizeIcon",
- WindowsIconFactory.createFrameMinimizeIcon(),
- "InternalFrame.iconifyIcon",
- WindowsIconFactory.createFrameIconifyIcon(),
- "InternalFrame.closeIcon",
- WindowsIconFactory.createFrameCloseIcon(),
- "InternalFrame.icon",
- (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{
- // The constructor takes one arg: an array of UIDefaults.LazyValue
- // representing the icons
- SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
- SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
- }),
- // Internal Frame Auditory Cue Mappings
- "InternalFrame.closeSound", "win.sound.close",
- "InternalFrame.maximizeSound", "win.sound.maximize",
- "InternalFrame.minimizeSound", "win.sound.minimize",
- "InternalFrame.restoreDownSound", "win.sound.restoreDown",
- "InternalFrame.restoreUpSound", "win.sound.restoreUp",
-
- "InternalFrame.windowBindings", new Object[] {
- "shift ESCAPE", "showSystemMenu",
- "ctrl SPACE", "showSystemMenu",
- "ESCAPE", "hideSystemMenu"},
-
- // Label
- "Label.font", ControlFont,
- "Label.background", ControlBackgroundColor,
- "Label.foreground", WindowTextColor,
- "Label.disabledForeground", InactiveTextColor,
- "Label.disabledShadow", ControlHighlightColor,
-
- // List.
- "List.font", ControlFont,
- "List.background", WindowBackgroundColor,
- "List.foreground", WindowTextColor,
- "List.selectionBackground", SelectionBackgroundColor,
- "List.selectionForeground", SelectionTextColor,
- "List.lockToPositionOnScroll", Boolean.TRUE,
- "List.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ctrl C", "copy",
- "ctrl V", "paste",
- "ctrl X", "cut",
- "COPY", "copy",
- "PASTE", "paste",
- "CUT", "cut",
- "control INSERT", "copy",
- "shift INSERT", "paste",
- "shift DELETE", "cut",
- "UP", "selectPreviousRow",
- "KP_UP", "selectPreviousRow",
- "shift UP", "selectPreviousRowExtendSelection",
- "shift KP_UP", "selectPreviousRowExtendSelection",
- "ctrl shift UP", "selectPreviousRowExtendSelection",
- "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
- "ctrl UP", "selectPreviousRowChangeLead",
- "ctrl KP_UP", "selectPreviousRowChangeLead",
- "DOWN", "selectNextRow",
- "KP_DOWN", "selectNextRow",
- "shift DOWN", "selectNextRowExtendSelection",
- "shift KP_DOWN", "selectNextRowExtendSelection",
- "ctrl shift DOWN", "selectNextRowExtendSelection",
- "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
- "ctrl DOWN", "selectNextRowChangeLead",
- "ctrl KP_DOWN", "selectNextRowChangeLead",
- "LEFT", "selectPreviousColumn",
- "KP_LEFT", "selectPreviousColumn",
- "shift LEFT", "selectPreviousColumnExtendSelection",
- "shift KP_LEFT", "selectPreviousColumnExtendSelection",
- "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
- "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
- "ctrl LEFT", "selectPreviousColumnChangeLead",
- "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
- "RIGHT", "selectNextColumn",
- "KP_RIGHT", "selectNextColumn",
- "shift RIGHT", "selectNextColumnExtendSelection",
- "shift KP_RIGHT", "selectNextColumnExtendSelection",
- "ctrl shift RIGHT", "selectNextColumnExtendSelection",
- "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
- "ctrl RIGHT", "selectNextColumnChangeLead",
- "ctrl KP_RIGHT", "selectNextColumnChangeLead",
- "HOME", "selectFirstRow",
- "shift HOME", "selectFirstRowExtendSelection",
- "ctrl shift HOME", "selectFirstRowExtendSelection",
- "ctrl HOME", "selectFirstRowChangeLead",
- "END", "selectLastRow",
- "shift END", "selectLastRowExtendSelection",
- "ctrl shift END", "selectLastRowExtendSelection",
- "ctrl END", "selectLastRowChangeLead",
- "PAGE_UP", "scrollUp",
- "shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl PAGE_UP", "scrollUpChangeLead",
- "PAGE_DOWN", "scrollDown",
- "shift PAGE_DOWN", "scrollDownExtendSelection",
- "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
- "ctrl PAGE_DOWN", "scrollDownChangeLead",
- "ctrl A", "selectAll",
- "ctrl SLASH", "selectAll",
- "ctrl BACK_SLASH", "clearSelection",
- "SPACE", "addToSelection",
- "ctrl SPACE", "toggleAndAnchor",
- "shift SPACE", "extendTo",
- "ctrl shift SPACE", "moveSelectionTo"
- }),
-
- // PopupMenu
- "PopupMenu.font", MenuFont,
- "PopupMenu.background", MenuBackgroundColor,
- "PopupMenu.foreground", MenuTextColor,
- "PopupMenu.popupSound", "win.sound.menuPopup",
- "PopupMenu.consumeEventOnClose", Boolean.TRUE,
-
- // Menus
- "Menu.font", MenuFont,
- "Menu.foreground", MenuTextColor,
- "Menu.background", MenuBackgroundColor,
- "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE,
- "Menu.selectionForeground", SelectionTextColor,
- "Menu.selectionBackground", SelectionBackgroundColor,
- "Menu.acceleratorForeground", MenuTextColor,
- "Menu.acceleratorSelectionForeground", SelectionTextColor,
- "Menu.menuPopupOffsetX", Integer.valueOf(0),
- "Menu.menuPopupOffsetY", Integer.valueOf(0),
- "Menu.submenuPopupOffsetX", Integer.valueOf(-4),
- "Menu.submenuPopupOffsetY", Integer.valueOf(-3),
- "Menu.crossMenuMnemonic", Boolean.FALSE,
- "Menu.preserveTopLevelSelection", Boolean.TRUE,
-
- // MenuBar.
- "MenuBar.font", MenuFont,
- "MenuBar.background", new XPValue(MenuBarBackgroundColor,
- MenuBackgroundColor),
- "MenuBar.foreground", MenuTextColor,
- "MenuBar.shadow", ControlShadowColor,
- "MenuBar.highlight", ControlHighlightColor,
- "MenuBar.height", menuBarHeight,
- "MenuBar.rolloverEnabled", hotTrackingOn,
- "MenuBar.windowBindings", new Object[] {
- "F10", "takeFocus" },
-
- "MenuItem.font", MenuFont,
- "MenuItem.acceleratorFont", MenuFont,
- "MenuItem.foreground", MenuTextColor,
- "MenuItem.background", MenuBackgroundColor,
- "MenuItem.selectionForeground", SelectionTextColor,
- "MenuItem.selectionBackground", SelectionBackgroundColor,
- "MenuItem.disabledForeground", InactiveTextColor,
- "MenuItem.acceleratorForeground", MenuTextColor,
- "MenuItem.acceleratorSelectionForeground", SelectionTextColor,
- "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
- // Menu Item Auditory Cue Mapping
- "MenuItem.commandSound", "win.sound.menuCommand",
- // indicates that keyboard navigation won't skip disabled menu items
- "MenuItem.disabledAreNavigable", Boolean.TRUE,
-
- "RadioButton.font", ControlFont,
- "RadioButton.interiorBackground", WindowBackgroundColor,
- "RadioButton.background", ControlBackgroundColor,
- "RadioButton.foreground", WindowTextColor,
- "RadioButton.shadow", ControlShadowColor,
- "RadioButton.darkShadow", ControlDarkShadowColor,
- "RadioButton.light", ControlLightColor,
- "RadioButton.highlight", ControlHighlightColor,
- "RadioButton.focus", buttonFocusColor,
- "RadioButton.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "SPACE", "pressed",
- "released SPACE", "released"
- }),
- // margin is 2 all the way around, BasicBorders.RadioButtonBorder
- // is 2 all the way around too.
- "RadioButton.totalInsets", new Insets(4, 4, 4, 4),
-
-
- "RadioButtonMenuItem.font", MenuFont,
- "RadioButtonMenuItem.foreground", MenuTextColor,
- "RadioButtonMenuItem.background", MenuBackgroundColor,
- "RadioButtonMenuItem.selectionForeground", SelectionTextColor,
- "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor,
- "RadioButtonMenuItem.disabledForeground", InactiveTextColor,
- "RadioButtonMenuItem.acceleratorForeground", MenuTextColor,
- "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor,
- "RadioButtonMenuItem.commandSound", "win.sound.menuCommand",
-
- // OptionPane.
- "OptionPane.font", MessageFont,
- "OptionPane.messageFont", MessageFont,
- "OptionPane.buttonFont", MessageFont,
- "OptionPane.background", ControlBackgroundColor,
- "OptionPane.foreground", WindowTextColor,
- "OptionPane.buttonMinimumWidth", new XPDLUValue(50, 50, SwingConstants.EAST),
- "OptionPane.messageForeground", ControlTextColor,
- "OptionPane.errorIcon", new LazyWindowsIcon("optionPaneIcon Error",
- "icons/Error.gif"),
- "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information",
- "icons/Inform.gif"),
- "OptionPane.questionIcon", new LazyWindowsIcon("optionPaneIcon Question",
- "icons/Question.gif"),
- "OptionPane.warningIcon", new LazyWindowsIcon("optionPaneIcon Warning",
- "icons/Warn.gif"),
- "OptionPane.windowBindings", new Object[] {
- "ESCAPE", "close" },
- // Option Pane Auditory Cue Mappings
- "OptionPane.errorSound", "win.sound.hand", // Error
- "OptionPane.informationSound", "win.sound.asterisk", // Info Plain
- "OptionPane.questionSound", "win.sound.question", // Question
- "OptionPane.warningSound", "win.sound.exclamation", // Warning
-
- "FormattedTextField.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ctrl C", DefaultEditorKit.copyAction,
- "ctrl V", DefaultEditorKit.pasteAction,
- "ctrl X", DefaultEditorKit.cutAction,
- "COPY", DefaultEditorKit.copyAction,
- "PASTE", DefaultEditorKit.pasteAction,
- "CUT", DefaultEditorKit.cutAction,
- "control INSERT", DefaultEditorKit.copyAction,
- "shift INSERT", DefaultEditorKit.pasteAction,
- "shift DELETE", DefaultEditorKit.cutAction,
- "shift LEFT", DefaultEditorKit.selectionBackwardAction,
- "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
- "shift RIGHT", DefaultEditorKit.selectionForwardAction,
- "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
- "ctrl LEFT", DefaultEditorKit.previousWordAction,
- "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
- "ctrl RIGHT", DefaultEditorKit.nextWordAction,
- "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
- "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
- "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
- "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
- "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
- "ctrl A", DefaultEditorKit.selectAllAction,
- "HOME", DefaultEditorKit.beginLineAction,
- "END", DefaultEditorKit.endLineAction,
- "shift HOME", DefaultEditorKit.selectionBeginLineAction,
- "shift END", DefaultEditorKit.selectionEndLineAction,
- "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
- "ctrl H", DefaultEditorKit.deletePrevCharAction,
- "DELETE", DefaultEditorKit.deleteNextCharAction,
- "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
- "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
- "RIGHT", DefaultEditorKit.forwardAction,
- "LEFT", DefaultEditorKit.backwardAction,
- "KP_RIGHT", DefaultEditorKit.forwardAction,
- "KP_LEFT", DefaultEditorKit.backwardAction,
- "ENTER", JTextField.notifyAction,
- "ctrl BACK_SLASH", "unselect",
- "control shift O", "toggle-componentOrientation",
- "ESCAPE", "reset-field-edit",
- "UP", "increment",
- "KP_UP", "increment",
- "DOWN", "decrement",
- "KP_DOWN", "decrement",
- }),
- "FormattedTextField.inactiveBackground", ReadOnlyTextBackground,
- "FormattedTextField.disabledBackground", DisabledTextBackground,
- "FormattedTextField.background", TextBackground,
- "FormattedTextField.foreground", WindowTextColor,
-
- // *** Panel
- "Panel.font", ControlFont,
- "Panel.background", ControlBackgroundColor,
- "Panel.foreground", WindowTextColor,
-
- // *** PasswordField
- "PasswordField.font", ControlFont,
- "PasswordField.background", TextBackground,
- "PasswordField.foreground", WindowTextColor,
- "PasswordField.inactiveForeground", InactiveTextColor, // for disabled
- "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly
- "PasswordField.disabledBackground", DisabledTextBackground, // for disabled
- "PasswordField.selectionBackground", SelectionBackgroundColor,
- "PasswordField.selectionForeground", SelectionTextColor,
- "PasswordField.caretForeground",WindowTextColor,
- "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
-
- // *** ProgressBar
- "ProgressBar.font", ControlFont,
- "ProgressBar.foreground", SelectionBackgroundColor,
- "ProgressBar.background", ControlBackgroundColor,
- "ProgressBar.shadow", ControlShadowColor,
- "ProgressBar.highlight", ControlHighlightColor,
- "ProgressBar.selectionForeground", ControlBackgroundColor,
- "ProgressBar.selectionBackground", SelectionBackgroundColor,
- "ProgressBar.cellLength", Integer.valueOf(7),
- "ProgressBar.cellSpacing", Integer.valueOf(2),
- "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3),
-
- // *** RootPane.
- // These bindings are only enabled when there is a default
- // button set on the rootpane.
- "RootPane.defaultButtonWindowKeyBindings", new Object[] {
- "ENTER", "press",
- "released ENTER", "release",
- "ctrl ENTER", "press",
- "ctrl released ENTER", "release"
- },
-
- // *** ScrollBar.
- "ScrollBar.background", ScrollbarBackgroundColor,
- "ScrollBar.foreground", ControlBackgroundColor,
- "ScrollBar.track", white,
- "ScrollBar.trackForeground", ScrollbarBackgroundColor,
- "ScrollBar.trackHighlight", black,
- "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight,
- "ScrollBar.thumb", ControlBackgroundColor,
- "ScrollBar.thumbHighlight", ControlHighlightColor,
- "ScrollBar.thumbDarkShadow", ControlDarkShadowColor,
- "ScrollBar.thumbShadow", ControlShadowColor,
- "ScrollBar.width", scrollBarWidth,
- "ScrollBar.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "RIGHT", "positiveUnitIncrement",
- "KP_RIGHT", "positiveUnitIncrement",
- "DOWN", "positiveUnitIncrement",
- "KP_DOWN", "positiveUnitIncrement",
- "PAGE_DOWN", "positiveBlockIncrement",
- "ctrl PAGE_DOWN", "positiveBlockIncrement",
- "LEFT", "negativeUnitIncrement",
- "KP_LEFT", "negativeUnitIncrement",
- "UP", "negativeUnitIncrement",
- "KP_UP", "negativeUnitIncrement",
- "PAGE_UP", "negativeBlockIncrement",
- "ctrl PAGE_UP", "negativeBlockIncrement",
- "HOME", "minScroll",
- "END", "maxScroll"
- }),
-
- // *** ScrollPane.
- "ScrollPane.font", ControlFont,
- "ScrollPane.background", ControlBackgroundColor,
- "ScrollPane.foreground", ControlTextColor,
- "ScrollPane.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "RIGHT", "unitScrollRight",
- "KP_RIGHT", "unitScrollRight",
- "DOWN", "unitScrollDown",
- "KP_DOWN", "unitScrollDown",
- "LEFT", "unitScrollLeft",
- "KP_LEFT", "unitScrollLeft",
- "UP", "unitScrollUp",
- "KP_UP", "unitScrollUp",
- "PAGE_UP", "scrollUp",
- "PAGE_DOWN", "scrollDown",
- "ctrl PAGE_UP", "scrollLeft",
- "ctrl PAGE_DOWN", "scrollRight",
- "ctrl HOME", "scrollHome",
- "ctrl END", "scrollEnd"
- }),
-
- // *** Separator
- "Separator.background", ControlHighlightColor,
- "Separator.foreground", ControlShadowColor,
-
- // *** Slider.
- "Slider.font", ControlFont,
- "Slider.foreground", ControlBackgroundColor,
- "Slider.background", ControlBackgroundColor,
- "Slider.highlight", ControlHighlightColor,
- "Slider.shadow", ControlShadowColor,
- "Slider.focus", ControlDarkShadowColor,
- "Slider.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "RIGHT", "positiveUnitIncrement",
- "KP_RIGHT", "positiveUnitIncrement",
- "DOWN", "negativeUnitIncrement",
- "KP_DOWN", "negativeUnitIncrement",
- "PAGE_DOWN", "negativeBlockIncrement",
- "LEFT", "negativeUnitIncrement",
- "KP_LEFT", "negativeUnitIncrement",
- "UP", "positiveUnitIncrement",
- "KP_UP", "positiveUnitIncrement",
- "PAGE_UP", "positiveBlockIncrement",
- "HOME", "minScroll",
- "END", "maxScroll"
- }),
-
- // Spinner
- "Spinner.font", ControlFont,
- "Spinner.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "UP", "increment",
- "KP_UP", "increment",
- "DOWN", "decrement",
- "KP_DOWN", "decrement",
- }),
-
- // *** SplitPane
- "SplitPane.background", ControlBackgroundColor,
- "SplitPane.highlight", ControlHighlightColor,
- "SplitPane.shadow", ControlShadowColor,
- "SplitPane.darkShadow", ControlDarkShadowColor,
- "SplitPane.dividerSize", Integer.valueOf(5),
- "SplitPane.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "UP", "negativeIncrement",
- "DOWN", "positiveIncrement",
- "LEFT", "negativeIncrement",
- "RIGHT", "positiveIncrement",
- "KP_UP", "negativeIncrement",
- "KP_DOWN", "positiveIncrement",
- "KP_LEFT", "negativeIncrement",
- "KP_RIGHT", "positiveIncrement",
- "HOME", "selectMin",
- "END", "selectMax",
- "F8", "startResize",
- "F6", "toggleFocus",
- "ctrl TAB", "focusOutForward",
- "ctrl shift TAB", "focusOutBackward"
- }),
-
- // *** TabbedPane
- "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE),
- "TabbedPane.tabInsets", new XPValue(new InsetsUIResource(1, 4, 1, 4),
- new InsetsUIResource(0, 4, 1, 4)),
- "TabbedPane.tabAreaInsets", new XPValue(new InsetsUIResource(3, 2, 2, 2),
- new InsetsUIResource(3, 2, 0, 2)),
- "TabbedPane.font", ControlFont,
- "TabbedPane.background", ControlBackgroundColor,
- "TabbedPane.foreground", ControlTextColor,
- "TabbedPane.highlight", ControlHighlightColor,
- "TabbedPane.light", ControlLightColor,
- "TabbedPane.shadow", ControlShadowColor,
- "TabbedPane.darkShadow", ControlDarkShadowColor,
- "TabbedPane.focus", ControlTextColor,
- "TabbedPane.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "RIGHT", "navigateRight",
- "KP_RIGHT", "navigateRight",
- "LEFT", "navigateLeft",
- "KP_LEFT", "navigateLeft",
- "UP", "navigateUp",
- "KP_UP", "navigateUp",
- "DOWN", "navigateDown",
- "KP_DOWN", "navigateDown",
- "ctrl DOWN", "requestFocusForVisibleComponent",
- "ctrl KP_DOWN", "requestFocusForVisibleComponent",
- }),
- "TabbedPane.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ctrl TAB", "navigateNext",
- "ctrl shift TAB", "navigatePrevious",
- "ctrl PAGE_DOWN", "navigatePageDown",
- "ctrl PAGE_UP", "navigatePageUp",
- "ctrl UP", "requestFocus",
- "ctrl KP_UP", "requestFocus",
- }),
-
- // *** Table
- "Table.font", ControlFont,
- "Table.foreground", ControlTextColor, // cell text color
- "Table.background", WindowBackgroundColor, // cell background color
- "Table.highlight", ControlHighlightColor,
- "Table.light", ControlLightColor,
- "Table.shadow", ControlShadowColor,
- "Table.darkShadow", ControlDarkShadowColor,
- "Table.selectionForeground", SelectionTextColor,
- "Table.selectionBackground", SelectionBackgroundColor,
- "Table.gridColor", gray, // grid line color
- "Table.focusCellBackground", WindowBackgroundColor,
- "Table.focusCellForeground", ControlTextColor,
- "Table.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ctrl C", "copy",
- "ctrl V", "paste",
- "ctrl X", "cut",
- "COPY", "copy",
- "PASTE", "paste",
- "CUT", "cut",
- "control INSERT", "copy",
- "shift INSERT", "paste",
- "shift DELETE", "cut",
- "RIGHT", "selectNextColumn",
- "KP_RIGHT", "selectNextColumn",
- "shift RIGHT", "selectNextColumnExtendSelection",
- "shift KP_RIGHT", "selectNextColumnExtendSelection",
- "ctrl shift RIGHT", "selectNextColumnExtendSelection",
- "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
- "ctrl RIGHT", "selectNextColumnChangeLead",
- "ctrl KP_RIGHT", "selectNextColumnChangeLead",
- "LEFT", "selectPreviousColumn",
- "KP_LEFT", "selectPreviousColumn",
- "shift LEFT", "selectPreviousColumnExtendSelection",
- "shift KP_LEFT", "selectPreviousColumnExtendSelection",
- "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
- "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
- "ctrl LEFT", "selectPreviousColumnChangeLead",
- "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
- "DOWN", "selectNextRow",
- "KP_DOWN", "selectNextRow",
- "shift DOWN", "selectNextRowExtendSelection",
- "shift KP_DOWN", "selectNextRowExtendSelection",
- "ctrl shift DOWN", "selectNextRowExtendSelection",
- "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
- "ctrl DOWN", "selectNextRowChangeLead",
- "ctrl KP_DOWN", "selectNextRowChangeLead",
- "UP", "selectPreviousRow",
- "KP_UP", "selectPreviousRow",
- "shift UP", "selectPreviousRowExtendSelection",
- "shift KP_UP", "selectPreviousRowExtendSelection",
- "ctrl shift UP", "selectPreviousRowExtendSelection",
- "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
- "ctrl UP", "selectPreviousRowChangeLead",
- "ctrl KP_UP", "selectPreviousRowChangeLead",
- "HOME", "selectFirstColumn",
- "shift HOME", "selectFirstColumnExtendSelection",
- "ctrl shift HOME", "selectFirstRowExtendSelection",
- "ctrl HOME", "selectFirstRow",
- "END", "selectLastColumn",
- "shift END", "selectLastColumnExtendSelection",
- "ctrl shift END", "selectLastRowExtendSelection",
- "ctrl END", "selectLastRow",
- "PAGE_UP", "scrollUpChangeSelection",
- "shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
- "ctrl PAGE_UP", "scrollLeftChangeSelection",
- "PAGE_DOWN", "scrollDownChangeSelection",
- "shift PAGE_DOWN", "scrollDownExtendSelection",
- "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
- "ctrl PAGE_DOWN", "scrollRightChangeSelection",
- "TAB", "selectNextColumnCell",
- "shift TAB", "selectPreviousColumnCell",
- "ENTER", "selectNextRowCell",
- "shift ENTER", "selectPreviousRowCell",
- "ctrl A", "selectAll",
- "ctrl SLASH", "selectAll",
- "ctrl BACK_SLASH", "clearSelection",
- "ESCAPE", "cancel",
- "F2", "startEditing",
- "SPACE", "addToSelection",
- "ctrl SPACE", "toggleAndAnchor",
- "shift SPACE", "extendTo",
- "ctrl shift SPACE", "moveSelectionTo",
- "F8", "focusHeader"
- }),
- "Table.sortIconHighlight", ControlShadowColor,
- "Table.sortIconLight", white,
-
- "TableHeader.font", ControlFont,
- "TableHeader.foreground", ControlTextColor, // header text color
- "TableHeader.background", ControlBackgroundColor, // header background
- "TableHeader.focusCellBackground",
- new XPValue(XPValue.NULL_VALUE, // use default bg from XP styles
- WindowBackgroundColor), // or white bg otherwise
-
- // *** TextArea
- "TextArea.font", FixedControlFont,
- "TextArea.background", WindowBackgroundColor,
- "TextArea.foreground", WindowTextColor,
- "TextArea.inactiveForeground", InactiveTextColor,
- "TextArea.inactiveBackground", WindowBackgroundColor,
- "TextArea.disabledBackground", DisabledTextBackground,
- "TextArea.selectionBackground", SelectionBackgroundColor,
- "TextArea.selectionForeground", SelectionTextColor,
- "TextArea.caretForeground", WindowTextColor,
-
- // *** TextField
- "TextField.font", ControlFont,
- "TextField.background", TextBackground,
- "TextField.foreground", WindowTextColor,
- "TextField.shadow", ControlShadowColor,
- "TextField.darkShadow", ControlDarkShadowColor,
- "TextField.light", ControlLightColor,
- "TextField.highlight", ControlHighlightColor,
- "TextField.inactiveForeground", InactiveTextColor, // for disabled
- "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly
- "TextField.disabledBackground", DisabledTextBackground, // for disabled
- "TextField.selectionBackground", SelectionBackgroundColor,
- "TextField.selectionForeground", SelectionTextColor,
- "TextField.caretForeground", WindowTextColor,
-
- // *** TextPane
- "TextPane.font", ControlFont,
- "TextPane.background", WindowBackgroundColor,
- "TextPane.foreground", WindowTextColor,
- "TextPane.selectionBackground", SelectionBackgroundColor,
- "TextPane.selectionForeground", SelectionTextColor,
- "TextPane.inactiveBackground", WindowBackgroundColor,
- "TextPane.disabledBackground", DisabledTextBackground,
- "TextPane.caretForeground", WindowTextColor,
-
- // *** TitledBorder
- "TitledBorder.font", ControlFont,
- "TitledBorder.titleColor",
- new XPColorValue(Part.BP_GROUPBOX, null, Prop.TEXTCOLOR,
- WindowTextColor),
-
- // *** ToggleButton
- "ToggleButton.font", ControlFont,
- "ToggleButton.background", ControlBackgroundColor,
- "ToggleButton.foreground", ControlTextColor,
- "ToggleButton.shadow", ControlShadowColor,
- "ToggleButton.darkShadow", ControlDarkShadowColor,
- "ToggleButton.light", ControlLightColor,
- "ToggleButton.highlight", ControlHighlightColor,
- "ToggleButton.focus", ControlTextColor,
- "ToggleButton.textShiftOffset", Integer.valueOf(1),
- "ToggleButton.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "SPACE", "pressed",
- "released SPACE", "released"
- }),
-
- // *** ToolBar
- "ToolBar.font", MenuFont,
- "ToolBar.background", ControlBackgroundColor,
- "ToolBar.foreground", ControlTextColor,
- "ToolBar.shadow", ControlShadowColor,
- "ToolBar.darkShadow", ControlDarkShadowColor,
- "ToolBar.light", ControlLightColor,
- "ToolBar.highlight", ControlHighlightColor,
- "ToolBar.dockingBackground", ControlBackgroundColor,
- "ToolBar.dockingForeground", red,
- "ToolBar.floatingBackground", ControlBackgroundColor,
- "ToolBar.floatingForeground", darkGray,
- "ToolBar.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "UP", "navigateUp",
- "KP_UP", "navigateUp",
- "DOWN", "navigateDown",
- "KP_DOWN", "navigateDown",
- "LEFT", "navigateLeft",
- "KP_LEFT", "navigateLeft",
- "RIGHT", "navigateRight",
- "KP_RIGHT", "navigateRight"
- }),
- "ToolBar.separatorSize", null,
-
- // *** ToolTip
- "ToolTip.font", ToolTipFont,
- "ToolTip.background", new WindowsDesktopProperty("win.tooltip.backgroundColor", table.get("info")),
- "ToolTip.foreground", new WindowsDesktopProperty("win.tooltip.textColor", table.get("infoText")),
-
- // *** ToolTipManager
- "ToolTipManager.enableToolTipMode", "activeApplication",
-
- // *** Tree
- "Tree.selectionBorderColor", black,
- "Tree.drawDashedFocusIndicator", Boolean.TRUE,
- "Tree.lineTypeDashed", Boolean.TRUE,
- "Tree.font", ControlFont,
- "Tree.background", WindowBackgroundColor,
- "Tree.foreground", WindowTextColor,
- "Tree.hash", gray,
- "Tree.leftChildIndent", Integer.valueOf(8),
- "Tree.rightChildIndent", Integer.valueOf(11),
- "Tree.textForeground", WindowTextColor,
- "Tree.textBackground", WindowBackgroundColor,
- "Tree.selectionForeground", SelectionTextColor,
- "Tree.selectionBackground", SelectionBackgroundColor,
- "Tree.expandedIcon", treeExpandedIcon,
- "Tree.collapsedIcon", treeCollapsedIcon,
- "Tree.openIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
- "shell32Icon 5", "icons/TreeOpen.gif"),
- "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
- "shell32Icon 4", "icons/TreeClosed.gif"),
- "Tree.focusInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ADD", "expand",
- "SUBTRACT", "collapse",
- "ctrl C", "copy",
- "ctrl V", "paste",
- "ctrl X", "cut",
- "COPY", "copy",
- "PASTE", "paste",
- "CUT", "cut",
- "control INSERT", "copy",
- "shift INSERT", "paste",
- "shift DELETE", "cut",
- "UP", "selectPrevious",
- "KP_UP", "selectPrevious",
- "shift UP", "selectPreviousExtendSelection",
- "shift KP_UP", "selectPreviousExtendSelection",
- "ctrl shift UP", "selectPreviousExtendSelection",
- "ctrl shift KP_UP", "selectPreviousExtendSelection",
- "ctrl UP", "selectPreviousChangeLead",
- "ctrl KP_UP", "selectPreviousChangeLead",
- "DOWN", "selectNext",
- "KP_DOWN", "selectNext",
- "shift DOWN", "selectNextExtendSelection",
- "shift KP_DOWN", "selectNextExtendSelection",
- "ctrl shift DOWN", "selectNextExtendSelection",
- "ctrl shift KP_DOWN", "selectNextExtendSelection",
- "ctrl DOWN", "selectNextChangeLead",
- "ctrl KP_DOWN", "selectNextChangeLead",
- "RIGHT", "selectChild",
- "KP_RIGHT", "selectChild",
- "LEFT", "selectParent",
- "KP_LEFT", "selectParent",
- "PAGE_UP", "scrollUpChangeSelection",
- "shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl PAGE_UP", "scrollUpChangeLead",
- "PAGE_DOWN", "scrollDownChangeSelection",
- "shift PAGE_DOWN", "scrollDownExtendSelection",
- "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
- "ctrl PAGE_DOWN", "scrollDownChangeLead",
- "HOME", "selectFirst",
- "shift HOME", "selectFirstExtendSelection",
- "ctrl shift HOME", "selectFirstExtendSelection",
- "ctrl HOME", "selectFirstChangeLead",
- "END", "selectLast",
- "shift END", "selectLastExtendSelection",
- "ctrl shift END", "selectLastExtendSelection",
- "ctrl END", "selectLastChangeLead",
- "F2", "startEditing",
- "ctrl A", "selectAll",
- "ctrl SLASH", "selectAll",
- "ctrl BACK_SLASH", "clearSelection",
- "ctrl LEFT", "scrollLeft",
- "ctrl KP_LEFT", "scrollLeft",
- "ctrl RIGHT", "scrollRight",
- "ctrl KP_RIGHT", "scrollRight",
- "SPACE", "addToSelection",
- "ctrl SPACE", "toggleAndAnchor",
- "shift SPACE", "extendTo",
- "ctrl shift SPACE", "moveSelectionTo"
- }),
- "Tree.ancestorInputMap",
- new UIDefaults.LazyInputMap(new Object[] {
- "ESCAPE", "cancel"
- }),
-
- // *** Viewport
- "Viewport.font", ControlFont,
- "Viewport.background", ControlBackgroundColor,
- "Viewport.foreground", WindowTextColor,
-
-
- };
-
- table.putDefaults(defaults);
- table.putDefaults(getLazyValueDefaults());
- initVistaComponentDefaults(table);
- }
-
- static boolean isOnVista() {
- return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
- && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) >= 0;
- }
-
- static boolean isOnWindows7() {
- return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
- && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_7) >= 0;
- }
-
- private void initVistaComponentDefaults(UIDefaults table) {
- if (! isOnVista()) {
- return;
- }
- /* START handling menus for Vista */
- String[] menuClasses = { "MenuItem", "Menu",
- "CheckBoxMenuItem", "RadioButtonMenuItem",
- };
-
- Object menuDefaults[] = new Object[menuClasses.length * 2];
-
- /* all the menus need to be non opaque. */
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".opaque";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(Boolean.FALSE, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /*
- * acceleratorSelectionForeground color is the same as
- * acceleratorForeground
- */
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".acceleratorSelectionForeground";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(
- table.getColor(
- menuClasses[i] + ".acceleratorForeground"),
- oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /* they have the same MenuItemCheckIconFactory */
- VistaMenuItemCheckIconFactory menuItemCheckIconFactory =
- WindowsIconFactory.getMenuItemCheckIconFactory();
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".checkIconFactory";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(menuItemCheckIconFactory, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".checkIcon";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]),
- oldValue);
- }
- table.putDefaults(menuDefaults);
-
-
- /* height can be even */
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".evenHeight";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /*For Windows7 margin and checkIconOffset should be greater than 0 */
- if (!isOnWindows7()) {
- /* no margins */
- InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0);
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".margin";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] = new XPValue(insets, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /* set checkIcon offset */
- Integer checkIconOffsetInteger =
- Integer.valueOf(0);
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".checkIconOffset";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(checkIconOffsetInteger, oldValue);
- }
- table.putDefaults(menuDefaults);
- }
- /* set width of the gap after check icon */
- Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter()
- + WindowsPopupMenuUI.getGutterWidth()
- + WindowsPopupMenuUI.getSpanAfterGutter();
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".afterCheckIconGap";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] =
- new XPValue(afterCheckIconGap, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /* text is started after this position */
- Object minimumTextOffset = new UIDefaults.ActiveValue() {
- public Object createValue(UIDefaults table) {
- return VistaMenuItemCheckIconFactory.getIconWidth()
- + WindowsPopupMenuUI.getSpanBeforeGutter()
- + WindowsPopupMenuUI.getGutterWidth()
- + WindowsPopupMenuUI.getSpanAfterGutter();
- }
- };
- for (int i = 0, j = 0; i < menuClasses.length; i++) {
- String key = menuClasses[i] + ".minimumTextOffset";
- Object oldValue = table.get(key);
- menuDefaults[j++] = key;
- menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue);
- }
- table.putDefaults(menuDefaults);
-
- /*
- * JPopupMenu has a bit of free space around menu items
- */
- String POPUP_MENU_BORDER = "PopupMenu.border";
-
- Object popupMenuBorder = new XPBorderValue(Part.MENU,
- (LazyValue) t -> BasicBorders.getInternalFrameBorder(),
- BorderFactory.createEmptyBorder(2, 2, 2, 2));
- table.put(POPUP_MENU_BORDER, popupMenuBorder);
- /* END handling menus for Vista */
-
- /* START table handling for Vista */
- table.put("Table.ascendingSortIcon", new XPValue(
- new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
- (LazyValue) t -> new ClassicSortArrowIcon(true)));
- table.put("Table.descendingSortIcon", new XPValue(
- new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
- (LazyValue) t -> new ClassicSortArrowIcon(false)));
- /* END table handling for Vista */
- }
-
- /**
- * If we support loading of fonts from the desktop this will return
- * a WindowsDesktopProperty representing the font. If the font can't be
- * represented in the current encoding this will return null and
- * turn off the use of system fonts.
- */
- private Object getDesktopFontValue(String fontName, Object backup) {
- if (useSystemFontSettings) {
- return new WindowsFontProperty(fontName, backup);
- }
- return null;
- }
-
- // When a desktop property change is detected, these classes must be
- // reinitialized in the defaults table to ensure the classes reference
- // the updated desktop property values (colors mostly)
- //
- private Object[] getLazyValueDefaults() {
-
- Object buttonBorder =
- new XPBorderValue(Part.BP_PUSHBUTTON,
- (LazyValue) t -> BasicBorders.getButtonBorder());
-
- Object textFieldBorder =
- new XPBorderValue(Part.EP_EDIT,
- (LazyValue) t -> BasicBorders.getTextFieldBorder());
-
- Object textFieldMargin =
- new XPValue(new InsetsUIResource(2, 2, 2, 2),
- new InsetsUIResource(1, 1, 1, 1));
-
- Object spinnerBorder =
- new XPBorderValue(Part.EP_EDIT, textFieldBorder,
- new EmptyBorder(2, 2, 2, 2));
-
- Object spinnerArrowInsets =
- new XPValue(new InsetsUIResource(1, 1, 1, 1),
- null);
-
- Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder);
-
- // For focus rectangle for cells and trees.
- LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
-
- LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
-
- LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
-
- LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
-
-
- LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
-
- LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
-
-
- Object popupMenuBorder = new XPBorderValue(Part.MENU,
- (LazyValue) t -> BasicBorders.getInternalFrameBorder());
-
- // *** ProgressBar
- LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
-
- LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
-
- Object scrollPaneBorder =
- new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
-
- Object tableScrollPaneBorder =
- new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
-
- LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
-
- // *** ToolBar
- LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
-
- // *** ToolTips
- LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
-
-
-
- LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
-
- LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
-
- LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
-
- LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
-
- LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
-
- LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
-
- Color highlight = (Color) Toolkit.getDefaultToolkit().
- getDesktopProperty("win.3d.highlightColor");
-
- Color shadow = (Color) Toolkit.getDefaultToolkit().
- getDesktopProperty("win.3d.shadowColor");
-
- Object[] lazyDefaults = {
- "Button.border", buttonBorder,
- "CheckBox.border", radioButtonBorder,
- "ComboBox.border", comboBoxBorder,
- "DesktopIcon.border", internalFrameBorder,
- "FormattedTextField.border", textFieldBorder,
- "FormattedTextField.margin", textFieldMargin,
- "InternalFrame.border", internalFrameBorder,
- "List.focusCellHighlightBorder", focusCellHighlightBorder,
- "Table.focusCellHighlightBorder", focusCellHighlightBorder,
- "Menu.border", marginBorder,
- "MenuBar.border", menuBarBorder,
- "MenuItem.border", marginBorder,
- "PasswordField.border", textFieldBorder,
- "PasswordField.margin", textFieldMargin,
- "PopupMenu.border", popupMenuBorder,
- "ProgressBar.border", progressBarBorder,
- "RadioButton.border", radioButtonBorder,
- "ScrollPane.border", scrollPaneBorder,
- "Spinner.border", spinnerBorder,
- "Spinner.arrowButtonInsets", spinnerArrowInsets,
- "Spinner.arrowButtonSize", new Dimension(17, 9),
- "Table.scrollPaneBorder", tableScrollPaneBorder,
- "TableHeader.cellBorder", tableHeaderBorder,
- "TextArea.margin", textFieldMargin,
- "TextField.border", textFieldBorder,
- "TextField.margin", textFieldMargin,
- "TitledBorder.border", new UIDefaults.LazyValue() {
- public Object createValue(UIDefaults table) {
- return new BorderUIResource.
- EtchedBorderUIResource(highlight, shadow);
- }
- },
- "ToggleButton.border", radioButtonBorder,
- "ToolBar.border", toolBarBorder,
- "ToolTip.border", toolTipBorder,
-
- "CheckBox.icon", checkBoxIcon,
- "Menu.arrowIcon", menuArrowIcon,
- "MenuItem.checkIcon", menuItemCheckIcon,
- "MenuItem.arrowIcon", menuItemArrowIcon,
- "RadioButton.icon", radioButtonIcon,
- "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
- "InternalFrame.layoutTitlePaneAtOrigin",
- new XPValue(Boolean.TRUE, Boolean.FALSE),
- "Table.ascendingSortIcon", new XPValue(
- (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
- (LazyValue) t -> new ClassicSortArrowIcon(true)),
- "Table.descendingSortIcon", new XPValue(
- (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
- (LazyValue) t -> new ClassicSortArrowIcon(false)),
- };
-
- return lazyDefaults;
- }
-
- public void uninitialize() {
- super.uninitialize();
-
- if (WindowsPopupMenuUI.mnemonicListener != null) {
- MenuSelectionManager.defaultManager().
- removeChangeListener(WindowsPopupMenuUI.mnemonicListener);
- }
- KeyboardFocusManager.getCurrentKeyboardFocusManager().
- removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
- WindowsDesktopProperty.flushUnreferencedProperties();
- }
-
-
- // Toggle flag for drawing the mnemonic state
- private static boolean isMnemonicHidden = true;
-
- // Flag which indicates that the Win98/Win2k/WinME features
- // should be disabled.
- private static boolean isClassicWindows = false;
-
- /**
- * Sets the state of the hide mnemonic flag. This flag is used by the
- * component UI delegates to determine if the mnemonic should be rendered.
- * This method is a non operation if the underlying operating system
- * does not support the mnemonic hiding feature.
- *
- * @param hide true if mnemonics should be hidden
- * @since 1.4
- */
- public static void setMnemonicHidden(boolean hide) {
- if (UIManager.getBoolean("Button.showMnemonics") == true) {
- // Do not hide mnemonics if the UI defaults do not support this
- isMnemonicHidden = false;
- } else {
- isMnemonicHidden = hide;
- }
- }
-
- /**
- * Gets the state of the hide mnemonic flag. This only has meaning
- * if this feature is supported by the underlying OS.
- *
- * @return true if mnemonics are hidden, otherwise, false
- * @see #setMnemonicHidden
- * @since 1.4
- */
- public static boolean isMnemonicHidden() {
- if (UIManager.getBoolean("Button.showMnemonics") == true) {
- // Do not hide mnemonics if the UI defaults do not support this
- isMnemonicHidden = false;
- }
- return isMnemonicHidden;
- }
-
- /**
- * Gets the state of the flag which indicates if the old Windows
- * look and feel should be rendered. This flag is used by the
- * component UI delegates as a hint to determine which style the component
- * should be rendered.
- *
- * @return true if Windows 95 and Windows NT 4 look and feel should
- * be rendered
- * @since 1.4
- */
- public static boolean isClassicWindows() {
- return isClassicWindows;
- }
-
- /**
- * <p>
- * Invoked when the user attempts an invalid operation,
- * such as pasting into an uneditable <code>JTextField</code>
- * that has focus.
- * </p>
- * <p>
- * If the user has enabled visual error indication on
- * the desktop, this method will flash the caption bar
- * of the active window. The user can also set the
- * property awt.visualbell=true to achieve the same
- * results.
- * </p>
- *
- * @param component Component the error occurred in, may be
- * null indicating the error condition is
- * not directly associated with a
- * <code>Component</code>.
- *
- * @see javax.swing.LookAndFeel#provideErrorFeedback
- */
- public void provideErrorFeedback(Component component) {
- super.provideErrorFeedback(component);
- }
-
- /**
- * {@inheritDoc}
- */
- public LayoutStyle getLayoutStyle() {
- LayoutStyle style = this.style;
- if (style == null) {
- style = new WindowsLayoutStyle();
- this.style = style;
- }
- return style;
- }
-
- // ********* Auditory Cue support methods and objects *********
-
- /**
- * Returns an <code>Action</code>.
- * <P>
- * This Action contains the information and logic to render an
- * auditory cue. The <code>Object</code> that is passed to this
- * method contains the information needed to render the auditory
- * cue. Normally, this <code>Object</code> is a <code>String</code>
- * that points to a <code>Toolkit</code> <code>desktopProperty</code>.
- * This <code>desktopProperty</code> is resolved by AWT and the
- * Windows OS.
- * <P>
- * This <code>Action</code>'s <code>actionPerformed</code> method
- * is fired by the <code>playSound</code> method.
- *
- * @return an Action which knows how to render the auditory
- * cue for one particular system or user activity
- * @see #playSound(Action)
- * @since 1.4
- */
- protected Action createAudioAction(Object key) {
- if (key != null) {
- String audioKey = (String)key;
- String audioValue = (String)UIManager.get(key);
- return new AudioAction(audioKey, audioValue);
- } else {
- return null;
- }
- }
-
- static void repaintRootPane(Component c) {
- JRootPane root = null;
- for (; c != null; c = c.getParent()) {
- if (c instanceof JRootPane) {
- root = (JRootPane)c;
- }
- }
-
- if (root != null) {
- root.repaint();
- } else {
- c.repaint();
- }
- }
-
- /**
- * Pass the name String to the super constructor. This is used
- * later to identify the Action and decide whether to play it or
- * not. Store the resource String. It is used to get the audio
- * resource. In this case, the resource is a <code>Runnable</code>
- * supplied by <code>Toolkit</code>. This <code>Runnable</code> is
- * effectively a pointer down into the Win32 OS that knows how to
- * play the right sound.
- *
- * @since 1.4
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private static class AudioAction extends AbstractAction {
- private Runnable audioRunnable;
- private String audioResource;
- /**
- * We use the String as the name of the Action and as a pointer to
- * the underlying OSes audio resource.
- */
- public AudioAction(String name, String resource) {
- super(name);
- audioResource = resource;
- }
- public void actionPerformed(ActionEvent e) {
- if (audioRunnable == null) {
- audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource);
- }
- if (audioRunnable != null) {
- // Runnable appears to block until completed playing, hence
- // start up another thread to handle playing.
- new Thread(null, audioRunnable, "Audio", 0, false).start();
- }
- }
- }
-
- /**
- * Gets an <code>Icon</code> from the native libraries if available,
- * otherwise gets it from an image resource file.
- */
- private static class LazyWindowsIcon implements UIDefaults.LazyValue {
- private String nativeImage;
- private String resource;
-
- LazyWindowsIcon(String nativeImage, String resource) {
- this.nativeImage = nativeImage;
- this.resource = resource;
- }
-
- public Object createValue(UIDefaults table) {
- if (nativeImage != null) {
- Image image = (Image)ShellFolder.get(nativeImage);
- if (image != null) {
- return new ImageIcon(image);
- }
- }
- return SwingUtilities2.makeIcon(getClass(),
- WindowsLookAndFeel.class,
- resource);
- }
- }
-
-
- /**
- * Gets an <code>Icon</code> from the native libraries if available.
- * A desktop property is used to trigger reloading the icon when needed.
- */
- private class ActiveWindowsIcon implements UIDefaults.ActiveValue {
- private Icon icon;
- private String nativeImageName;
- private String fallbackName;
- private WindowsDesktopProperty desktopProperty;
-
- ActiveWindowsIcon(String desktopPropertyName,
- String nativeImageName, String fallbackName) {
- this.nativeImageName = nativeImageName;
- this.fallbackName = fallbackName;
-
- if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
- OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) {
- // This desktop property is needed to trigger reloading the icon.
- // It is kept in member variable to avoid GC.
- this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) {
- @Override protected void updateUI() {
- icon = null;
- super.updateUI();
- }
- };
- }
- }
-
- @Override
- public Object createValue(UIDefaults table) {
- if (icon == null) {
- Image image = (Image)ShellFolder.get(nativeImageName);
- if (image != null) {
- icon = new ImageIconUIResource(image);
- }
- }
- if (icon == null && fallbackName != null) {
- UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
- SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
- BasicLookAndFeel.class, fallbackName);
- icon = (Icon) fallback.createValue(table);
- }
- return icon;
- }
- }
-
- /**
- * Icon backed-up by XP Skin.
- */
- private static class SkinIcon implements Icon, UIResource {
- private final Part part;
- private final State state;
- SkinIcon(Part part, State state) {
- this.part = part;
- this.state = state;
- }
-
- /**
- * Draw the icon at the specified location. Icon implementations
- * may use the Component argument to get properties useful for
- * painting, e.g. the foreground or background color.
- */
- public void paintIcon(Component c, Graphics g, int x, int y) {
- XPStyle xp = XPStyle.getXP();
- assert xp != null;
- if (xp != null) {
- Skin skin = xp.getSkin(null, part);
- skin.paintSkin(g, x, y, state);
- }
- }
-
- /**
- * Returns the icon's width.
- *
- * @return an int specifying the fixed width of the icon.
- */
- public int getIconWidth() {
- int width = 0;
- XPStyle xp = XPStyle.getXP();
- assert xp != null;
- if (xp != null) {
- Skin skin = xp.getSkin(null, part);
- width = skin.getWidth();
- }
- return width;
- }
-
- /**
- * Returns the icon's height.
- *
- * @return an int specifying the fixed height of the icon.
- */
- public int getIconHeight() {
- int height = 0;
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(null, part);
- height = skin.getHeight();
- }
- return height;
- }
-
- }
-
- /**
- * WindowsDesktopProperty for fonts. If a font with the name 'MS Sans Serif'
- * is returned, it is mapped to 'Microsoft Sans Serif'.
- */
- private static class WindowsFontProperty extends WindowsDesktopProperty {
- WindowsFontProperty(String key, Object backup) {
- super(key, backup);
- }
-
- public void invalidate(LookAndFeel laf) {
- if ("win.defaultGUI.font.height".equals(getKey())) {
- ((WindowsLookAndFeel)laf).style = null;
- }
- super.invalidate(laf);
- }
-
- protected Object configureValue(Object value) {
- if (value instanceof Font) {
- Font font = (Font)value;
- if ("MS Sans Serif".equals(font.getName())) {
- int size = font.getSize();
- // 4950968: Workaround to mimic the way Windows maps the default
- // font size of 6 pts to the smallest available bitmap font size.
- // This happens mostly on Win 98/Me & NT.
- int dpi;
- try {
- dpi = Toolkit.getDefaultToolkit().getScreenResolution();
- } catch (HeadlessException ex) {
- dpi = 96;
- }
- if (Math.round(size * 72F / dpi) < 8) {
- size = Math.round(8 * dpi / 72F);
- }
- Font msFont = new FontUIResource("Microsoft Sans Serif",
- font.getStyle(), size);
- if (msFont.getName() != null &&
- msFont.getName().equals(msFont.getFamily())) {
- font = msFont;
- } else if (size != font.getSize()) {
- font = new FontUIResource("MS Sans Serif",
- font.getStyle(), size);
- }
- }
-
- if (FontUtilities.fontSupportsDefaultEncoding(font)) {
- if (!(font instanceof UIResource)) {
- font = new FontUIResource(font);
- }
- }
- else {
- font = FontUtilities.getCompositeFontUIResource(font);
- }
- return font;
-
- }
- return super.configureValue(value);
- }
- }
-
-
- /**
- * WindowsDesktopProperty for fonts that only gets sizes from the desktop,
- * font name and style are passed into the constructor
- */
- private static class WindowsFontSizeProperty extends
- WindowsDesktopProperty {
- private String fontName;
- private int fontSize;
- private int fontStyle;
-
- WindowsFontSizeProperty(String key, String fontName,
- int fontStyle, int fontSize) {
- super(key, null);
- this.fontName = fontName;
- this.fontSize = fontSize;
- this.fontStyle = fontStyle;
- }
-
- protected Object configureValue(Object value) {
- if (value == null) {
- value = new FontUIResource(fontName, fontStyle, fontSize);
- }
- else if (value instanceof Integer) {
- value = new FontUIResource(fontName, fontStyle,
- ((Integer)value).intValue());
- }
- return value;
- }
- }
-
-
- /**
- * A value wrapper that actively retrieves values from xp or falls back
- * to the classic value if not running XP styles.
- */
- private static class XPValue implements UIDefaults.ActiveValue {
- protected Object classicValue, xpValue;
-
- // A constant that lets you specify null when using XP styles.
- private static final Object NULL_VALUE = new Object();
-
- XPValue(Object xpValue, Object classicValue) {
- this.xpValue = xpValue;
- this.classicValue = classicValue;
- }
-
- public Object createValue(UIDefaults table) {
- Object value = null;
- if (XPStyle.getXP() != null) {
- value = getXPValue(table);
- }
-
- if (value == null) {
- value = getClassicValue(table);
- } else if (value == NULL_VALUE) {
- value = null;
- }
-
- return value;
- }
-
- protected Object getXPValue(UIDefaults table) {
- return recursiveCreateValue(xpValue, table);
- }
-
- protected Object getClassicValue(UIDefaults table) {
- return recursiveCreateValue(classicValue, table);
- }
-
- private Object recursiveCreateValue(Object value, UIDefaults table) {
- if (value instanceof UIDefaults.LazyValue) {
- value = ((UIDefaults.LazyValue)value).createValue(table);
- }
- if (value instanceof UIDefaults.ActiveValue) {
- return ((UIDefaults.ActiveValue)value).createValue(table);
- } else {
- return value;
- }
- }
- }
-
- private static class XPBorderValue extends XPValue {
- private final Border extraMargin;
-
- XPBorderValue(Part xpValue, Object classicValue) {
- this(xpValue, classicValue, null);
- }
-
- XPBorderValue(Part xpValue, Object classicValue, Border extraMargin) {
- super(xpValue, classicValue);
- this.extraMargin = extraMargin;
- }
-
- public Object getXPValue(UIDefaults table) {
- XPStyle xp = XPStyle.getXP();
- Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null;
- if (xpBorder != null && extraMargin != null) {
- return new BorderUIResource.
- CompoundBorderUIResource(xpBorder, extraMargin);
- } else {
- return xpBorder;
- }
- }
- }
-
- private static class XPColorValue extends XPValue {
- XPColorValue(Part part, State state, Prop prop, Object classicValue) {
- super(new XPColorValueKey(part, state, prop), classicValue);
- }
-
- public Object getXPValue(UIDefaults table) {
- XPColorValueKey key = (XPColorValueKey)xpValue;
- XPStyle xp = XPStyle.getXP();
- return xp != null ? xp.getColor(key.skin, key.prop, null) : null;
- }
-
- private static class XPColorValueKey {
- Skin skin;
- Prop prop;
-
- XPColorValueKey(Part part, State state, Prop prop) {
- this.skin = new Skin(part, state);
- this.prop = prop;
- }
- }
- }
-
- private class XPDLUValue extends XPValue {
- private int direction;
-
- XPDLUValue(int xpdlu, int classicdlu, int direction) {
- super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu));
- this.direction = direction;
- }
-
- public Object getXPValue(UIDefaults table) {
- int px = dluToPixels(((Integer)xpValue).intValue(), direction);
- return Integer.valueOf(px);
- }
-
- public Object getClassicValue(UIDefaults table) {
- int px = dluToPixels(((Integer)classicValue).intValue(), direction);
- return Integer.valueOf(px);
- }
- }
-
- private class TriggerDesktopProperty extends WindowsDesktopProperty {
- TriggerDesktopProperty(String key) {
- super(key, null);
- // This call adds a property change listener for the property,
- // which triggers a call to updateUI(). The value returned
- // is not interesting here.
- getValueFromDesktop();
- }
-
- protected void updateUI() {
- super.updateUI();
-
- // Make sure property change listener is readded each time
- getValueFromDesktop();
- }
- }
-
- private class FontDesktopProperty extends TriggerDesktopProperty {
- FontDesktopProperty(String key) {
- super(key);
- }
-
- protected void updateUI() {
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- SwingUtilities2.putAATextInfo(true, defaults);
- super.updateUI();
- }
- }
-
- // Windows LayoutStyle. From:
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
- @SuppressWarnings("fallthrough")
- private class WindowsLayoutStyle extends DefaultLayoutStyle {
- @Override
- public int getPreferredGap(JComponent component1,
- JComponent component2, ComponentPlacement type, int position,
- Container parent) {
- // Checks args
- super.getPreferredGap(component1, component2, type, position,
- parent);
-
- switch(type) {
- case INDENT:
- // Windows doesn't spec this
- if (position == SwingConstants.EAST ||
- position == SwingConstants.WEST) {
- int indent = getIndent(component1, position);
- if (indent > 0) {
- return indent;
- }
- return 10;
- }
- // Fall through to related.
- case RELATED:
- if (isLabelAndNonlabel(component1, component2, position)) {
- // Between text labels and their associated controls (for
- // example, text boxes and list boxes): 3
- // NOTE: We're not honoring:
- // 'Text label beside a button 3 down from the top of
- // the button,' but I suspect that is an attempt to
- // enforce a baseline layout which will be handled
- // separately. In order to enforce this we would need
- // this API to return a more complicated type (Insets,
- // or something else).
- return getButtonGap(component1, component2, position,
- dluToPixels(3, position));
- }
- // Between related controls: 4
- return getButtonGap(component1, component2, position,
- dluToPixels(4, position));
- case UNRELATED:
- // Between unrelated controls: 7
- return getButtonGap(component1, component2, position,
- dluToPixels(7, position));
- }
- return 0;
- }
-
- @Override
- public int getContainerGap(JComponent component, int position,
- Container parent) {
- // Checks args
- super.getContainerGap(component, position, parent);
- return getButtonGap(component, position, dluToPixels(7, position));
- }
-
- }
-
- /**
- * Converts the dialog unit argument to pixels along the specified
- * axis.
- */
- private int dluToPixels(int dlu, int direction) {
- if (baseUnitX == 0) {
- calculateBaseUnits();
- }
- if (direction == SwingConstants.EAST ||
- direction == SwingConstants.WEST) {
- return dlu * baseUnitX / 4;
- }
- assert (direction == SwingConstants.NORTH ||
- direction == SwingConstants.SOUTH);
- return dlu * baseUnitY / 8;
- }
-
- /**
- * Calculates the dialog unit mapping.
- */
- @SuppressWarnings("deprecation")
- private void calculateBaseUnits() {
- // This calculation comes from:
- // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
- FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
- UIManager.getFont("Button.font"));
- baseUnitX = metrics.stringWidth(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
- baseUnitX = (baseUnitX / 26 + 1) / 2;
- // The -1 comes from experimentation.
- baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
- }
-
- /**
- * {@inheritDoc}
- *
- * @since 1.6
- */
- public Icon getDisabledIcon(JComponent component, Icon icon) {
- // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
- // client property set to Boolean.TRUE, then use the new
- // hi res algorithm for creating the disabled icon (used
- // in particular by the WindowsFileChooserUI class)
- if (icon != null
- && component != null
- && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
- && icon.getIconWidth() > 0
- && icon.getIconHeight() > 0) {
- BufferedImage img = new BufferedImage(icon.getIconWidth(),
- icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
- icon.paintIcon(component, img.getGraphics(), 0, 0);
- ImageFilter filter = new RGBGrayFilter();
- ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
- Image resultImage = component.createImage(producer);
- return new ImageIconUIResource(resultImage);
- }
- return super.getDisabledIcon(component, icon);
- }
-
- private static class RGBGrayFilter extends RGBImageFilter {
- public RGBGrayFilter() {
- canFilterIndexColorModel = true;
- }
- public int filterRGB(int x, int y, int rgb) {
- // find the average of red, green, and blue
- float avg = (((rgb >> 16) & 0xff) / 255f +
- ((rgb >> 8) & 0xff) / 255f +
- (rgb & 0xff) / 255f) / 3;
- // pull out the alpha channel
- float alpha = (((rgb>>24)&0xff)/255f);
- // calc the average
- avg = Math.min(1.0f, (1f-avg)/(100.0f/35.0f) + avg);
- // turn back into rgb
- int rgbval = (int)(alpha * 255f) << 24 |
- (int)(avg * 255f) << 16 |
- (int)(avg * 255f) << 8 |
- (int)(avg * 255f);
- return rgbval;
- }
- }
-
- private static class FocusColorProperty extends WindowsDesktopProperty {
- public FocusColorProperty () {
- // Fallback value is never used because of the configureValue method doesn't return null
- super("win.3d.backgroundColor", Color.BLACK);
- }
-
- @Override
- protected Object configureValue(Object value) {
- Object highContrastOn = Toolkit.getDefaultToolkit().
- getDesktopProperty("win.highContrast.on");
- if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) {
- return Color.BLACK;
- }
- return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
- }
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.ActionMapUIResource;
-import javax.swing.plaf.ComponentUI;
-import java.awt.event.ActionEvent;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.HierarchyListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.awt.event.WindowStateListener;
-
-import java.awt.*;
-
-import com.sun.java.swing.plaf.windows.TMSchema.*;
-import com.sun.java.swing.plaf.windows.XPStyle.*;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsMenuBarUI extends BasicMenuBarUI
-{
- /* to be accessed on the EDT only */
- private WindowListener windowListener = null;
- private HierarchyListener hierarchyListener = null;
- private Window window = null;
-
- public static ComponentUI createUI(JComponent x) {
- return new WindowsMenuBarUI();
- }
-
- @Override
- protected void uninstallListeners() {
- uninstallWindowListener();
- if (hierarchyListener != null) {
- menuBar.removeHierarchyListener(hierarchyListener);
- hierarchyListener = null;
- }
- super.uninstallListeners();
- }
- private void installWindowListener() {
- if (windowListener == null) {
- Component component = menuBar.getTopLevelAncestor();
- if (component instanceof Window) {
- window = (Window) component;
- windowListener = new WindowAdapter() {
- @Override
- public void windowActivated(WindowEvent e) {
- menuBar.repaint();
- }
- @Override
- public void windowDeactivated(WindowEvent e) {
- menuBar.repaint();
- }
- };
- ((Window) component).addWindowListener(windowListener);
- }
- }
- }
- private void uninstallWindowListener() {
- if (windowListener != null && window != null) {
- window.removeWindowListener(windowListener);
- }
- window = null;
- windowListener = null;
- }
- @Override
- protected void installListeners() {
- if (WindowsLookAndFeel.isOnVista()) {
- installWindowListener();
- hierarchyListener =
- new HierarchyListener() {
- public void hierarchyChanged(HierarchyEvent e) {
- if ((e.getChangeFlags()
- & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
- if (menuBar.isDisplayable()) {
- installWindowListener();
- } else {
- uninstallWindowListener();
- }
- }
- }
- };
- menuBar.addHierarchyListener(hierarchyListener);
- }
- super.installListeners();
- }
-
- protected void installKeyboardActions() {
- super.installKeyboardActions();
- ActionMap map = SwingUtilities.getUIActionMap(menuBar);
- if (map == null) {
- map = new ActionMapUIResource();
- SwingUtilities.replaceUIActionMap(menuBar, map);
- }
- map.put("takeFocus", new TakeFocus());
- }
-
- /**
- * Action that activates the menu (e.g. when F10 is pressed).
- * Unlike BasicMenuBarUI.TakeFocus, this Action will not show menu popup.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private static class TakeFocus extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- JMenuBar menuBar = (JMenuBar)e.getSource();
- JMenu menu = menuBar.getMenu(0);
- if (menu != null) {
- MenuSelectionManager msm =
- MenuSelectionManager.defaultManager();
- MenuElement path[] = new MenuElement[2];
- path[0] = (MenuElement)menuBar;
- path[1] = (MenuElement)menu;
- msm.setSelectedPath(path);
-
- // show mnemonics
- WindowsLookAndFeel.setMnemonicHidden(false);
- WindowsLookAndFeel.repaintRootPane(menuBar);
- }
- }
- }
-
- @Override
- public void paint(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- Skin skin;
- skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
- int width = c.getWidth();
- int height = c.getHeight();
- State state = isActive(c) ? State.ACTIVE : State.INACTIVE;
- skin.paintSkin(g, 0, 0, width, height, state);
- } else {
- super.paint(g, c);
- }
- }
-
- /**
- * Checks if component belongs to an active window.
- * @param c component to check
- * @return true if component belongs to an active window
- */
- static boolean isActive(JComponent c) {
- JRootPane rootPane = c.getRootPane();
- if (rootPane != null) {
- Component component = rootPane.getParent();
- if (component instanceof Window) {
- return ((Window) component).isActive();
- }
- }
- return true;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-
-import sun.swing.SwingUtilities2;
-
-import com.sun.java.swing.plaf.windows.TMSchema.*;
-import com.sun.java.swing.plaf.windows.XPStyle.*;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Igor Kushnirskiy
- */
-
-public class WindowsMenuItemUI extends BasicMenuItemUI {
- final WindowsMenuItemUIAccessor accessor =
- new WindowsMenuItemUIAccessor() {
-
- public JMenuItem getMenuItem() {
- return menuItem;
- }
-
- public State getState(JMenuItem menuItem) {
- return WindowsMenuItemUI.getState(this, menuItem);
- }
-
- public Part getPart(JMenuItem menuItem) {
- return WindowsMenuItemUI.getPart(this, menuItem);
- }
- };
- public static ComponentUI createUI(JComponent c) {
- return new WindowsMenuItemUI();
- }
-
- /**
- * Method which renders the text of the current menu item.
- *
- * @param g Graphics context
- * @param menuItem Current menu item to render
- * @param textRect Bounding rectangle to render the text.
- * @param text String to render
- */
- protected void paintText(Graphics g, JMenuItem menuItem,
- Rectangle textRect, String text) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
- return;
- }
- ButtonModel model = menuItem.getModel();
- Color oldColor = g.getColor();
-
- if(model.isEnabled() &&
- (model.isArmed() || (menuItem instanceof JMenu &&
- model.isSelected()))) {
- g.setColor(selectionForeground); // Uses protected field.
- }
-
- WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
-
- g.setColor(oldColor);
- }
-
- @Override
- protected void paintBackground(Graphics g, JMenuItem menuItem,
- Color bgColor) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
- return;
- }
- super.paintBackground(g, menuItem, bgColor);
- }
-
- static void paintBackground(WindowsMenuItemUIAccessor menuItemUI,
- Graphics g, JMenuItem menuItem, Color bgColor) {
- XPStyle xp = XPStyle.getXP();
- assert isVistaPainting(xp);
- if (isVistaPainting(xp)) {
- int menuWidth = menuItem.getWidth();
- int menuHeight = menuItem.getHeight();
- if (menuItem.isOpaque()) {
- Color oldColor = g.getColor();
- g.setColor(menuItem.getBackground());
- g.fillRect(0,0, menuWidth, menuHeight);
- g.setColor(oldColor);
- }
- Part part = menuItemUI.getPart(menuItem);
- Skin skin = xp.getSkin(menuItem, part);
- skin.paintSkin(g, 0 , 0,
- menuWidth,
- menuHeight,
- menuItemUI.getState(menuItem));
- }
- }
-
- static void paintText(WindowsMenuItemUIAccessor menuItemUI, Graphics g,
- JMenuItem menuItem, Rectangle textRect,
- String text) {
- assert isVistaPainting();
- if (isVistaPainting()) {
- State state = menuItemUI.getState(menuItem);
-
- /* part of it copied from WindowsGraphicsUtils.java */
- FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
- int mnemIndex = menuItem.getDisplayedMnemonicIndex();
- // W2K Feature: Check to see if the Underscore should be rendered.
- if (WindowsLookAndFeel.isMnemonicHidden() == true) {
- mnemIndex = -1;
- }
- WindowsGraphicsUtils.paintXPText(menuItem,
- menuItemUI.getPart(menuItem), state,
- g, textRect.x,
- textRect.y + fm.getAscent(),
- text, mnemIndex);
- }
- }
-
- static State getState(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
- State state;
- ButtonModel model = menuItem.getModel();
- if (model.isArmed()) {
- state = (model.isEnabled()) ? State.HOT : State.DISABLEDHOT;
- } else {
- state = (model.isEnabled()) ? State.NORMAL : State.DISABLED;
- }
- return state;
- }
-
- static Part getPart(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
- return Part.MP_POPUPITEM;
- }
-
- /*
- * TODO idk can we use XPStyle.isVista?
- * is it possible that in some theme some Vista parts are not defined while
- * others are?
- */
- static boolean isVistaPainting(final XPStyle xp) {
- return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM);
- }
-
- static boolean isVistaPainting() {
- return isVistaPainting(XPStyle.getXP());
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUIAccessor.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.Color;
-import java.awt.Graphics;
-
-import javax.swing.JMenuItem;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-
-/**
- * Accessor interface for WindowsMenuItemUI to allow for "multiple implementation
- * inheritance".
- *
- * @author Igor Kushnirskiy
- */
-interface WindowsMenuItemUIAccessor {
- JMenuItem getMenuItem();
- State getState(JMenuItem menuItem);
- Part getPart(JMenuItem menuItem);
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.MouseEvent;
-
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.basic.BasicMenuUI;
-import javax.swing.event.MouseInputListener;
-import javax.swing.*;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsMenuUI extends BasicMenuUI {
- protected Integer menuBarHeight;
- protected boolean hotTrackingOn;
-
- final WindowsMenuItemUIAccessor accessor =
- new WindowsMenuItemUIAccessor() {
-
- public JMenuItem getMenuItem() {
- return menuItem;
- }
-
- public State getState(JMenuItem menu) {
- State state = menu.isEnabled() ? State.NORMAL
- : State.DISABLED;
- ButtonModel model = menu.getModel();
- if (model.isArmed() || model.isSelected()) {
- state = (menu.isEnabled()) ? State.PUSHED
- : State.DISABLEDPUSHED;
- } else if (model.isRollover()
- && ((JMenu) menu).isTopLevelMenu()) {
- /*
- * Only paint rollover if no other menu on menubar is
- * selected
- */
- State stateTmp = state;
- state = (menu.isEnabled()) ? State.HOT
- : State.DISABLEDHOT;
- for (MenuElement menuElement :
- ((JMenuBar) menu.getParent()).getSubElements()) {
- if (((JMenuItem) menuElement).isSelected()) {
- state = stateTmp;
- break;
- }
- }
- }
-
- //non top level menus have HOT state instead of PUSHED
- if (!((JMenu) menu).isTopLevelMenu()) {
- if (state == State.PUSHED) {
- state = State.HOT;
- } else if (state == State.DISABLEDPUSHED) {
- state = State.DISABLEDHOT;
- }
- }
-
- /*
- * on Vista top level menu for non active frame looks disabled
- */
- if (((JMenu) menu).isTopLevelMenu() && WindowsMenuItemUI.isVistaPainting()) {
- if (! WindowsMenuBarUI.isActive(menu)) {
- state = State.DISABLED;
- }
- }
- return state;
- }
-
- public Part getPart(JMenuItem menuItem) {
- return ((JMenu) menuItem).isTopLevelMenu() ? Part.MP_BARITEM
- : Part.MP_POPUPITEM;
- }
- };
- public static ComponentUI createUI(JComponent x) {
- return new WindowsMenuUI();
- }
-
- protected void installDefaults() {
- super.installDefaults();
- if (!WindowsLookAndFeel.isClassicWindows()) {
- menuItem.setRolloverEnabled(true);
- }
-
- menuBarHeight = (Integer)UIManager.getInt("MenuBar.height");
-
- Object obj = UIManager.get("MenuBar.rolloverEnabled");
- hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
- }
-
- /**
- * Draws the background of the menu.
- * @since 1.4
- */
- protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
- return;
- }
-
- JMenu menu = (JMenu)menuItem;
- ButtonModel model = menu.getModel();
-
- // Use superclass method for the old Windows LAF,
- // for submenus, and for XP toplevel if selected or pressed
- if (WindowsLookAndFeel.isClassicWindows() ||
- !menu.isTopLevelMenu() ||
- (XPStyle.getXP() != null && (model.isArmed() || model.isSelected()))) {
-
- super.paintBackground(g, menu, bgColor);
- return;
- }
-
- Color oldColor = g.getColor();
- int menuWidth = menu.getWidth();
- int menuHeight = menu.getHeight();
-
- UIDefaults table = UIManager.getLookAndFeelDefaults();
- Color highlight = table.getColor("controlLtHighlight");
- Color shadow = table.getColor("controlShadow");
-
- g.setColor(menu.getBackground());
- g.fillRect(0,0, menuWidth, menuHeight);
-
- if (menu.isOpaque()) {
- if (model.isArmed() || model.isSelected()) {
- // Draw a lowered bevel border
- g.setColor(shadow);
- g.drawLine(0,0, menuWidth - 1,0);
- g.drawLine(0,0, 0,menuHeight - 2);
-
- g.setColor(highlight);
- g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
- g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
- } else if (model.isRollover() && model.isEnabled()) {
- // Only paint rollover if no other menu on menubar is selected
- boolean otherMenuSelected = false;
- MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
- for (int i = 0; i < menus.length; i++) {
- if (((JMenuItem)menus[i]).isSelected()) {
- otherMenuSelected = true;
- break;
- }
- }
- if (!otherMenuSelected) {
- if (XPStyle.getXP() != null) {
- g.setColor(selectionBackground); // Uses protected field.
- g.fillRect(0, 0, menuWidth, menuHeight);
- } else {
- // Draw a raised bevel border
- g.setColor(highlight);
- g.drawLine(0,0, menuWidth - 1,0);
- g.drawLine(0,0, 0,menuHeight - 2);
-
- g.setColor(shadow);
- g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
- g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
- }
- }
- }
- }
- g.setColor(oldColor);
- }
-
- /**
- * Method which renders the text of the current menu item.
- *
- * @param g Graphics context
- * @param menuItem Current menu item to render
- * @param textRect Bounding rectangle to render the text.
- * @param text String to render
- * @since 1.4
- */
- protected void paintText(Graphics g, JMenuItem menuItem,
- Rectangle textRect, String text) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
- return;
- }
- JMenu menu = (JMenu)menuItem;
- ButtonModel model = menuItem.getModel();
- Color oldColor = g.getColor();
-
- // Only paint rollover if no other menu on menubar is selected
- boolean paintRollover = model.isRollover();
- if (paintRollover && menu.isTopLevelMenu()) {
- MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
- for (int i = 0; i < menus.length; i++) {
- if (((JMenuItem)menus[i]).isSelected()) {
- paintRollover = false;
- break;
- }
- }
- }
-
- if ((model.isSelected() && (WindowsLookAndFeel.isClassicWindows() ||
- !menu.isTopLevelMenu())) ||
- (XPStyle.getXP() != null && (paintRollover ||
- model.isArmed() ||
- model.isSelected()))) {
- g.setColor(selectionForeground); // Uses protected field.
- }
-
- WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
-
- g.setColor(oldColor);
- }
-
- protected MouseInputListener createMouseInputListener(JComponent c) {
- return new WindowsMouseInputHandler();
- }
-
- /**
- * This class implements a mouse handler that sets the rollover flag to
- * true when the mouse enters the menu and false when it exits.
- * @since 1.4
- */
- protected class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler {
- public void mouseEntered(MouseEvent evt) {
- super.mouseEntered(evt);
-
- JMenu menu = (JMenu)evt.getSource();
- if (hotTrackingOn && menu.isTopLevelMenu() && menu.isRolloverEnabled()) {
- menu.getModel().setRollover(true);
- menuItem.repaint();
- }
- }
-
- public void mouseExited(MouseEvent evt) {
- super.mouseExited(evt);
-
- JMenu menu = (JMenu)evt.getSource();
- ButtonModel model = menu.getModel();
- if (menu.isRolloverEnabled()) {
- model.setRollover(false);
- menuItem.repaint();
- }
- }
- }
-
- protected Dimension getPreferredMenuItemSize(JComponent c,
- Icon checkIcon,
- Icon arrowIcon,
- int defaultTextIconGap) {
-
- Dimension d = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon,
- defaultTextIconGap);
-
- // Note: When toolbar containers (rebars) are implemented, only do
- // this if the JMenuBar is not in a rebar (i.e. ignore the desktop
- // property win.menu.height if in a rebar.)
- if (c instanceof JMenu && ((JMenu)c).isTopLevelMenu() &&
- menuBarHeight != null && d.height < menuBarHeight) {
-
- d.height = menuBarHeight;
- }
-
- return d;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsOptionPaneUI extends BasicOptionPaneUI {
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.text.Caret;
-
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsPasswordFieldUI extends BasicPasswordFieldUI {
-
- /**
- * Creates a UI for a JPasswordField
- *
- * @param c the password field
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsPasswordFieldUI();
- }
-
-
- /**
- * Creates the object to use for a caret. By default an
- * instance of WindowsCaret is created. This method
- * can be redefined to provide something else that implements
- * the InputPosition interface or a subclass of DefaultCaret.
- *
- * @return the caret object
- */
- protected Caret createCaret() {
- return new WindowsTextUI.WindowsCaret();
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI;
-import javax.swing.plaf.ComponentUI;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-import com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-/**
- * Windows {@literal L&F} implementation of PopupMenuSeparatorUI.
- *
- * @author Leif Samuelsson
- * @author Igor Kushnirskiy
- */
-
-public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsPopupMenuSeparatorUI();
- }
-
- public void paint(Graphics g, JComponent c) {
- Dimension s = c.getSize();
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- int x = 1;
- Component parent = c.getParent();
- if (parent instanceof JComponent) {
- Object gutterOffsetObject =
- ((JComponent) parent).getClientProperty(
- WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
- if (gutterOffsetObject instanceof Integer) {
- /*
- * gutter offset is in parent's coordinates.
- * See comment in
- * WindowsPopupMenuUI.getTextOffset(JComponent)
- */
- x = ((Integer) gutterOffsetObject).intValue() - c.getX();
- x += WindowsPopupMenuUI.getGutterWidth();
- }
- }
- Skin skin = xp.getSkin(c, Part.MP_POPUPSEPARATOR);
- int skinHeight = skin.getHeight();
- int y = (s.height - skinHeight) / 2;
- skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
- } else {
- int y = s.height / 2;
- g.setColor(c.getForeground());
- g.drawLine(1, y - 1, s.width - 2, y - 1);
-
- g.setColor(c.getBackground());
- g.drawLine(1, y, s.width - 2, y);
- }
- }
-
- public Dimension getPreferredSize(JComponent c) {
- int fontHeight = 0;
- Font font = c.getFont();
- if (font != null) {
- fontHeight = c.getFontMetrics(font).getHeight();
- }
-
- return new Dimension(0, fontHeight/2 + 2);
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Insets;
-import java.awt.KeyEventPostProcessor;
-import java.awt.KeyboardFocusManager;
-import java.awt.Window;
-import java.awt.event.KeyEvent;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-
-import sun.swing.StringUIClientPropertyKey;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-import com.sun.java.swing.plaf.windows.XPStyle.Skin;
-import static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Igor Kushnirskiy
- */
-public class WindowsPopupMenuUI extends BasicPopupMenuUI {
-
- static MnemonicListener mnemonicListener = null;
- static final Object GUTTER_OFFSET_KEY =
- new StringUIClientPropertyKey("GUTTER_OFFSET_KEY");
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsPopupMenuUI();
- }
-
- public void installListeners() {
- super.installListeners();
- if (! UIManager.getBoolean("Button.showMnemonics") &&
- mnemonicListener == null) {
-
- mnemonicListener = new MnemonicListener();
- MenuSelectionManager.defaultManager().
- addChangeListener(mnemonicListener);
- }
- }
-
- /**
- * Returns the <code>Popup</code> that will be responsible for
- * displaying the <code>JPopupMenu</code>.
- *
- * @param popupMenu JPopupMenu requesting Popup
- * @param x Screen x location Popup is to be shown at
- * @param y Screen y location Popup is to be shown at.
- * @return Popup that will show the JPopupMenu
- * @since 1.4
- */
- public Popup getPopup(JPopupMenu popupMenu, int x, int y) {
- PopupFactory popupFactory = PopupFactory.getSharedInstance();
- return popupFactory.getPopup(popupMenu.getInvoker(), popupMenu, x, y);
- }
-
- static class MnemonicListener implements ChangeListener {
- JRootPane repaintRoot = null;
-
- public void stateChanged(ChangeEvent ev) {
- MenuSelectionManager msm = (MenuSelectionManager)ev.getSource();
- MenuElement[] path = msm.getSelectedPath();
- if (path.length == 0) {
- if(!WindowsLookAndFeel.isMnemonicHidden()) {
- // menu was canceled -- hide mnemonics
- WindowsLookAndFeel.setMnemonicHidden(true);
- if (repaintRoot != null) {
- Window win =
- SwingUtilities.getWindowAncestor(repaintRoot);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(win);
- }
- }
- } else {
- Component c = (Component)path[0];
- if (c instanceof JPopupMenu) c = ((JPopupMenu)c).getInvoker();
- repaintRoot = SwingUtilities.getRootPane(c);
- }
- }
- }
-
- /**
- * Returns offset for the text.
- * BasicMenuItemUI sets max text offset on the JPopupMenuUI.
- * @param c PopupMenu to return text offset for.
- * @return text offset for the component
- */
- static int getTextOffset(JComponent c) {
- int rv = -1;
- Object maxTextOffset =
- c.getClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET);
- if (maxTextOffset instanceof Integer) {
- /*
- * this is in JMenuItem coordinates.
- * Let's assume all the JMenuItem have the same offset along X.
- */
- rv = (Integer) maxTextOffset;
- int menuItemOffset = 0;
- Component component = c.getComponent(0);
- if (component != null) {
- menuItemOffset = component.getX();
- }
- rv += menuItemOffset;
- }
- return rv;
- }
-
- /**
- * Returns span before gutter.
- * used only on Vista.
- * @return span before gutter
- */
- static int getSpanBeforeGutter() {
- return 3;
- }
-
- /**
- * Returns span after gutter.
- * used only on Vista.
- * @return span after gutter
- */
- static int getSpanAfterGutter() {
- return 3;
- }
-
- /**
- * Returns gutter width.
- * used only on Vista.
- * @return width of the gutter
- */
- static int getGutterWidth() {
- int rv = 2;
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(null, Part.MP_POPUPGUTTER);
- rv = skin.getWidth();
- }
- return rv;
- }
-
- /**
- * Checks if PopupMenu is leftToRight
- * The orientation is derived from the children of the component.
- * It is leftToRight if all the children are leftToRight
- *
- * @param c component to return orientation for
- * @return true if all the children are leftToRight
- */
- private static boolean isLeftToRight(JComponent c) {
- boolean leftToRight = true;
- for (int i = c.getComponentCount() - 1; i >=0 && leftToRight; i-- ) {
- leftToRight =
- c.getComponent(i).getComponentOrientation().isLeftToRight();
- }
- return leftToRight;
- }
-
- @Override
- public void paint(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (WindowsMenuItemUI.isVistaPainting(xp)) {
- Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND);
- skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL);
- int textOffset = getTextOffset(c);
- if (textOffset >= 0
- /* paint gutter only for leftToRight case */
- && isLeftToRight(c)) {
- skin = xp.getSkin(c, Part.MP_POPUPGUTTER);
- int gutterWidth = getGutterWidth();
- int gutterOffset =
- textOffset - getSpanAfterGutter() - gutterWidth;
- c.putClientProperty(GUTTER_OFFSET_KEY,
- Integer.valueOf(gutterOffset));
- Insets insets = c.getInsets();
- skin.paintSkin(g, gutterOffset, insets.top,
- gutterWidth, c.getHeight() - insets.bottom - insets.top,
- State.NORMAL);
- } else {
- if (c.getClientProperty(GUTTER_OFFSET_KEY) != null) {
- c.putClientProperty(GUTTER_OFFSET_KEY, null);
- }
- }
- } else {
- super.paint(g, c);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.JWindow;
-import java.awt.Window;
-import java.awt.Graphics;
-
-/**
- * A class which tags a window with a particular semantic usage,
- * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
- * This is used as a temporary solution for getting native AWT support
- * for transition effects in Windows 98 and Windows 2000. The native
- * code will interpret the windowType property and automatically
- * implement appropriate animation when the window is shown/hidden.
- * <p>
- * Note that support for transition effects may be supported with a
- * different mechanism in the future and so this class is
- * package-private and targeted for Swing implementation use only.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Amy Fowler
- */
-@SuppressWarnings("serial") // Superclass is not serializable across versions
-class WindowsPopupWindow extends JWindow {
-
- static final int UNDEFINED_WINDOW_TYPE = 0;
- static final int TOOLTIP_WINDOW_TYPE = 1;
- static final int MENU_WINDOW_TYPE = 2;
- static final int SUBMENU_WINDOW_TYPE = 3;
- static final int POPUPMENU_WINDOW_TYPE = 4;
- static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
-
- private int windowType;
-
- WindowsPopupWindow(Window parent) {
- super(parent);
- setFocusableWindowState(false);
- }
-
- void setWindowType(int type) {
- windowType = type;
- }
-
- int getWindowType() {
- return windowType;
- }
-
- public void update(Graphics g) {
- paint(g);
- }
-
- @SuppressWarnings("deprecation")
- public void hide() {
- super.hide();
- /** We need to call removeNotify() here because hide() does
- * something only if Component.visible is true. When the app
- * frame is miniaturized, the parent frame of this frame is
- * invisible, causing AWT to believe that this frame
- * is invisible and causing hide() to do nothing
- */
- removeNotify();
- }
-
- @SuppressWarnings("deprecation")
- public void show() {
- super.show();
- this.pack();
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,412 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.*;
-import javax.swing.*;
-import java.awt.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Michael C. Albers
- */
-public class WindowsProgressBarUI extends BasicProgressBarUI
-{
-
- private Rectangle previousFullBox;
- private Insets indeterminateInsets;
-
- public static ComponentUI createUI(JComponent x) {
- return new WindowsProgressBarUI();
- }
-
-
- protected void installDefaults() {
- super.installDefaults();
-
- if (XPStyle.getXP() != null) {
- LookAndFeel.installProperty(progressBar, "opaque", Boolean.FALSE);
- progressBar.setBorder(null);
- indeterminateInsets = UIManager.getInsets("ProgressBar.indeterminateInsets");
- }
- }
-
- /**
- * Returns the baseline.
- *
- * @throws NullPointerException {@inheritDoc}
- * @throws IllegalArgumentException {@inheritDoc}
- * @see javax.swing.JComponent#getBaseline(int, int)
- * @since 1.6
- */
- public int getBaseline(JComponent c, int width, int height) {
- int baseline = super.getBaseline(c, width, height);
- if (XPStyle.getXP() != null && progressBar.isStringPainted() &&
- progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
- FontMetrics metrics = progressBar.
- getFontMetrics(progressBar.getFont());
- int y = progressBar.getInsets().top;
- if (progressBar.isIndeterminate()) {
- y = -1;
- height--;
- }
- else {
- y = 0;
- height -= 3;
- }
- baseline = y + (height + metrics.getAscent() -
- metrics.getLeading() -
- metrics.getDescent()) / 2;
- }
- return baseline;
- }
-
- protected Dimension getPreferredInnerHorizontal() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(progressBar, Part.PP_BAR);
- return new Dimension(
- (int)super.getPreferredInnerHorizontal().getWidth(),
- skin.getHeight());
- }
- return super.getPreferredInnerHorizontal();
- }
-
- protected Dimension getPreferredInnerVertical() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Skin skin = xp.getSkin(progressBar, Part.PP_BARVERT);
- return new Dimension(
- skin.getWidth(),
- (int)super.getPreferredInnerVertical().getHeight());
- }
- return super.getPreferredInnerVertical();
- }
-
- protected void paintDeterminate(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
- boolean isLeftToRight = WindowsGraphicsUtils.isLeftToRight(c);
- int barRectWidth = progressBar.getWidth();
- int barRectHeight = progressBar.getHeight()-1;
- // amount of progress to draw
- int amountFull = getAmountFull(null, barRectWidth, barRectHeight);
-
- paintXPBackground(g, vertical, barRectWidth, barRectHeight);
- // Paint progress
- if (progressBar.isStringPainted()) {
- // Do not paint the standard stripes from the skin, because they obscure
- // the text
- g.setColor(progressBar.getForeground());
- barRectHeight -= 2;
- barRectWidth -= 2;
-
- if (barRectWidth <= 0 || barRectHeight <= 0) {
- return;
- }
-
- Graphics2D g2 = (Graphics2D)g;
- g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
- BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
- if (!vertical) {
- if (isLeftToRight) {
- g2.drawLine(2, barRectHeight / 2 + 1,
- amountFull - 2, barRectHeight / 2 + 1);
- } else {
- g2.drawLine(2 + barRectWidth,
- barRectHeight / 2 + 1,
- 2 + barRectWidth - (amountFull - 2),
- barRectHeight / 2 + 1);
- }
- paintString(g, 0, 0, barRectWidth, barRectHeight, amountFull, null);
- } else {
- g2.drawLine(barRectWidth/2 + 1, barRectHeight + 1,
- barRectWidth/2 + 1, barRectHeight + 1 - amountFull + 2);
- paintString(g, 2, 2, barRectWidth, barRectHeight, amountFull, null);
- }
-
- } else {
- Skin skin = xp.getSkin(progressBar, vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK);
- int thickness;
- if (vertical) {
- thickness = barRectWidth - 5;
- } else {
- thickness = barRectHeight - 5;
- }
-
- int chunkSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSCHUNKSIZE, 2);
- int spaceSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSSPACESIZE, 0);
- int nChunks = (amountFull-4) / (chunkSize + spaceSize);
-
- // See if we can squeeze in an extra chunk without spacing after
- if (spaceSize > 0 && (nChunks * (chunkSize + spaceSize) + chunkSize) < (amountFull-4)) {
- nChunks++;
- }
-
- for (int i = 0; i < nChunks; i++) {
- if (vertical) {
- skin.paintSkin(g,
- 3, barRectHeight - i * (chunkSize + spaceSize) - chunkSize - 2,
- thickness, chunkSize, null);
- } else {
- if (isLeftToRight) {
- skin.paintSkin(g,
- 4 + i * (chunkSize + spaceSize), 2,
- chunkSize, thickness, null);
- } else {
- skin.paintSkin(g,
- barRectWidth - (2 + (i+1) * (chunkSize + spaceSize)), 2,
- chunkSize, thickness, null);
- }
- }
- }
- }
- } else {
- super.paintDeterminate(g, c);
- }
- }
-
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected void setAnimationIndex(int newValue) {
- super.setAnimationIndex(newValue);
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- if (boxRect != null) {
- // get the full repaint area and add it the
- // previous one so we can erase it
- Rectangle chunk = getFullChunkBounds(boxRect);
- if (previousFullBox != null) {
- chunk.add(previousFullBox);
- }
- progressBar.repaint(chunk);
- } else {
- progressBar.repaint();
- }
- }
- }
-
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected int getBoxLength(int availableLength, int otherDimension) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return 6; // an apparently hard coded value in Windows
- }
- return super.getBoxLength(availableLength, otherDimension);
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected Rectangle getBox(Rectangle r) {
- Rectangle rect = super.getBox(r);
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- boolean vertical = (progressBar.getOrientation()
- == JProgressBar.VERTICAL);
- Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
- Insets ins = indeterminateInsets;
-
- int currentFrame = getAnimationIndex();
- int framecount = getFrameCount()/2;
-
- int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
- Prop.PROGRESSSPACESIZE, 0);
- currentFrame = currentFrame % framecount;
-
- // this code adjusts the chunk size to properly account for the
- // size and gap specified in the XP style. It also does it's own
- // box placement for the chunk animation. This is required because
- // the inherited algorithm from BasicProgressBarUI goes back and
- // forth whereas XP only goes in one direction. XP also has ghosted
- // trailing chunks to create the illusion of speed. This code
- // adjusts the pixel length of the animation to account for the
- // trails.
- if (!vertical) {
- rect.y = rect.y + ins.top;
- rect.height = progressBar.getHeight() - ins.top - ins.bottom;
- int len = progressBar.getWidth() - ins.left - ins.right;
- len += (rect.width+gap)*2; // add 2x for the trails
- double delta = (double)(len) / (double)framecount;
- rect.x = (int)(delta * currentFrame) + ins.left;
- } else {
- rect.x = rect.x + ins.left;
- rect.width = progressBar.getWidth() - ins.left - ins.right;
- int len = progressBar.getHeight() - ins.top - ins.bottom;
- len += (rect.height+gap)*2; // add 2x for the trails
- double delta = (double)(len) / (double)framecount;
- rect.y = (int)(delta * currentFrame) + ins.top;
- }
- }
- return rect;
- }
-
-
- protected void paintIndeterminate(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- boolean vertical = (progressBar.getOrientation()
- == JProgressBar.VERTICAL);
- int barRectWidth = progressBar.getWidth();
- int barRectHeight = progressBar.getHeight();
- paintXPBackground(g, vertical, barRectWidth, barRectHeight);
-
- // Paint the bouncing box.
- boxRect = getBox(boxRect);
- if (boxRect != null) {
- g.setColor(progressBar.getForeground());
- if (!(g instanceof Graphics2D)) {
- return;
- }
- paintIndeterminateFrame(boxRect, (Graphics2D)g, vertical,
- barRectWidth, barRectHeight);
- if (progressBar.isStringPainted()) {
- if (!vertical) {
- paintString(g, -1, -1, barRectWidth, barRectHeight, 0, null);
- } else {
- paintString(g, 1, 1, barRectWidth, barRectHeight, 0, null);
- }
- }
- }
- } else {
- super.paintIndeterminate(g, c);
- }
- }
-
- private Rectangle getFullChunkBounds(Rectangle box) {
- boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
- XPStyle xp = XPStyle.getXP();
- int gap = (xp != null) ? xp.getInt(progressBar, Part.PP_PROGRESS,
- null, Prop.PROGRESSSPACESIZE, 0)
- : 0;
-
- if (!vertical) {
- int chunksize = box.width+gap;
- return new Rectangle(box.x-chunksize*2, box.y, chunksize*3, box.height);
- } else {
- int chunksize = box.height+gap;
- return new Rectangle(box.x, box.y-chunksize*2, box.width, chunksize*3);
- }
- }
-
- private void paintIndeterminateFrame(Rectangle box, Graphics2D g,
- boolean vertical,
- int bgwidth, int bgheight) {
- XPStyle xp = XPStyle.getXP();
- if (xp == null) {
- return;
- }
-
- // create a new graphics to keep drawing surface state
- Graphics2D gfx = (Graphics2D)g.create();
-
- Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
- Part chunk = vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK;
-
- // calculate the chunk offsets
- int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
- Prop.PROGRESSSPACESIZE, 0);
- int deltax = 0;
- int deltay = 0;
- if (!vertical) {
- deltax = -box.width - gap;
- deltay = 0;
- } else {
- deltax = 0;
- deltay = -box.height - gap;
- }
-
- // Calculate the area of the chunks combined
- Rectangle fullBox = getFullChunkBounds(box);
-
- // save this box for the next time
- previousFullBox = fullBox;
-
- // this is the entire progress bar minus the track and borders
- Insets ins = indeterminateInsets;
- Rectangle progbarExtents = new Rectangle(ins.left, ins.top,
- bgwidth - ins.left - ins.right,
- bgheight - ins.top - ins.bottom);
-
- // only paint where the chunks overlap with the progress bar drawing area
- Rectangle repaintArea = progbarExtents.intersection(fullBox);
-
- // adjust the cliprect to chop the chunks when they go off the end
- gfx.clip(repaintArea);
-
- // get the skin
- XPStyle.Skin skin = xp.getSkin(progressBar, chunk);
-
- // do the drawing
- gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
- skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
- box.translate(deltax, deltay);
- gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
- skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
- box.translate(deltax, deltay);
- gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
- skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
-
- // get rid of our clip and composite changes
- gfx.dispose();
- }
-
- private void paintXPBackground(Graphics g, boolean vertical,
- int barRectWidth, int barRectHeight) {
- XPStyle xp = XPStyle.getXP();
- if (xp == null) {
- return;
- }
- Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
- Skin skin = xp.getSkin(progressBar, part);
-
- // Paint background
- skin.paintSkin(g, 0, 0, barRectWidth, barRectHeight, null);
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-
-import com.sun.java.swing.plaf.windows.TMSchema.Part;
-import com.sun.java.swing.plaf.windows.TMSchema.State;
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI {
-
- final WindowsMenuItemUIAccessor accessor =
- new WindowsMenuItemUIAccessor() {
-
- public JMenuItem getMenuItem() {
- return menuItem;
- }
-
- public State getState(JMenuItem menuItem) {
- return WindowsMenuItemUI.getState(this, menuItem);
- }
-
- public Part getPart(JMenuItem menuItem) {
- return WindowsMenuItemUI.getPart(this, menuItem);
- }
- };
- public static ComponentUI createUI(JComponent b) {
- return new WindowsRadioButtonMenuItemUI();
- }
-
- @Override
- protected void paintBackground(Graphics g, JMenuItem menuItem,
- Color bgColor) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
- return;
- }
- super.paintBackground(g, menuItem, bgColor);
- }
-
- /**
- * Method which renders the text of the current menu item.
- *
- * @param g Graphics context
- * @param menuItem Current menu item to render
- * @param textRect Bounding rectangle to render the text.
- * @param text String to render
- * @since 1.4
- */
- protected void paintText(Graphics g, JMenuItem menuItem,
- Rectangle textRect, String text) {
- if (WindowsMenuItemUI.isVistaPainting()) {
- WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
- return;
- }
- ButtonModel model = menuItem.getModel();
- Color oldColor = g.getColor();
-
- if(model.isEnabled() && model.isArmed()) {
- g.setColor(selectionForeground); // Uses protected field.
- }
-
- WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
-
- g.setColor(oldColor);
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.awt.AppContext;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-
-import java.awt.*;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsRadioButtonUI extends BasicRadioButtonUI
-{
- private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object();
-
- protected int dashedRectGapX;
- protected int dashedRectGapY;
- protected int dashedRectGapWidth;
- protected int dashedRectGapHeight;
-
- protected Color focusColor;
-
- private boolean initialized = false;
-
- // ********************************
- // Create PLAF
- // ********************************
- public static ComponentUI createUI(JComponent c) {
- AppContext appContext = AppContext.getAppContext();
- WindowsRadioButtonUI windowsRadioButtonUI =
- (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
- if (windowsRadioButtonUI == null) {
- windowsRadioButtonUI = new WindowsRadioButtonUI();
- appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
- }
- return windowsRadioButtonUI;
- }
-
- // ********************************
- // Defaults
- // ********************************
- public void installDefaults(AbstractButton b) {
- super.installDefaults(b);
- if(!initialized) {
- dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
- dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
- dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
- dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
- focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
- initialized = true;
- }
- if (XPStyle.getXP() != null) {
- LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
- }
- }
-
- protected void uninstallDefaults(AbstractButton b) {
- super.uninstallDefaults(b);
- initialized = false;
- }
-
- protected Color getFocusColor() {
- return focusColor;
- }
-
- // ********************************
- // Paint Methods
- // ********************************
-
- /**
- * Overridden method to render the text without the mnemonic
- */
- protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
- WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
- }
-
-
- protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
- g.setColor(getFocusColor());
- BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
- }
-
- // ********************************
- // Layout Methods
- // ********************************
- public Dimension getPreferredSize(JComponent c) {
- Dimension d = super.getPreferredSize(c);
-
- /* Ensure that the width and height of the button is odd,
- * to allow for the focus line if focus is painted
- */
- AbstractButton b = (AbstractButton)c;
- if (d != null && b.isFocusPainted()) {
- if(d.width % 2 == 0) { d.width += 1; }
- if(d.height % 2 == 0) { d.height += 1; }
- }
- return d;
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Event;
-import java.awt.KeyEventPostProcessor;
-import java.awt.Window;
-import java.awt.Toolkit;
-
-import sun.awt.AWTAccessor;
-import sun.awt.SunToolkit;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.ActionMap;
-import javax.swing.InputMap;
-import javax.swing.KeyStroke;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JRootPane;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.AbstractButton;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.MenuElement;
-import javax.swing.MenuSelectionManager;
-
-import javax.swing.plaf.ActionMapUIResource;
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.InputMapUIResource;
-
-import javax.swing.plaf.basic.BasicRootPaneUI;
-import javax.swing.plaf.basic.ComboPopup;
-
-/**
- * Windows implementation of RootPaneUI, there is one shared between all
- * JRootPane instances.
- *
- * @author Mark Davidson
- * @since 1.4
- */
-public class WindowsRootPaneUI extends BasicRootPaneUI {
-
- private static final WindowsRootPaneUI windowsRootPaneUI = new WindowsRootPaneUI();
- static final AltProcessor altProcessor = new AltProcessor();
-
- public static ComponentUI createUI(JComponent c) {
- return windowsRootPaneUI;
- }
-
- static class AltProcessor implements KeyEventPostProcessor {
- static boolean altKeyPressed = false;
- static boolean menuCanceledOnPress = false;
- static JRootPane root = null;
- static Window winAncestor = null;
-
- void altPressed(KeyEvent ev) {
- MenuSelectionManager msm =
- MenuSelectionManager.defaultManager();
- MenuElement[] path = msm.getSelectedPath();
- if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
- msm.clearSelectedPath();
- menuCanceledOnPress = true;
- ev.consume();
- } else if(path.length > 0) { // We are in ComboBox
- menuCanceledOnPress = false;
- WindowsLookAndFeel.setMnemonicHidden(false);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- ev.consume();
- } else {
- menuCanceledOnPress = false;
- WindowsLookAndFeel.setMnemonicHidden(false);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- JMenuBar mbar = root != null ? root.getJMenuBar() : null;
- if(mbar == null && winAncestor instanceof JFrame) {
- mbar = ((JFrame)winAncestor).getJMenuBar();
- }
- JMenu menu = mbar != null ? mbar.getMenu(0) : null;
- if(menu != null) {
- ev.consume();
- }
- }
- }
-
- void altReleased(KeyEvent ev) {
- if (menuCanceledOnPress) {
- WindowsLookAndFeel.setMnemonicHidden(true);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- return;
- }
-
- MenuSelectionManager msm =
- MenuSelectionManager.defaultManager();
- if (msm.getSelectedPath().length == 0) {
- // if no menu is active, we try activating the menubar
-
- JMenuBar mbar = root != null ? root.getJMenuBar() : null;
- if(mbar == null && winAncestor instanceof JFrame) {
- mbar = ((JFrame)winAncestor).getJMenuBar();
- }
- JMenu menu = mbar != null ? mbar.getMenu(0) : null;
-
- // It might happen that the altRelease event is processed
- // with a reasonable delay since it has been generated.
- // Here we check the last deactivation time of the containing
- // window. If this time appears to be greater than the altRelease
- // event time the event is skipped to avoid unexpected menu
- // activation. See 7121442.
- // Also we must ensure that original source of key event belongs
- // to the same window object as winAncestor. See 8001633.
- boolean skip = false;
- Toolkit tk = Toolkit.getDefaultToolkit();
- if (tk instanceof SunToolkit) {
- Component originalSource = AWTAccessor.getKeyEventAccessor()
- .getOriginalSource(ev);
- skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
- ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
- }
-
- if (menu != null && !skip) {
- MenuElement[] path = new MenuElement[2];
- path[0] = mbar;
- path[1] = menu;
- msm.setSelectedPath(path);
- } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
- WindowsLookAndFeel.setMnemonicHidden(true);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- }
- } else {
- if((msm.getSelectedPath())[0] instanceof ComboPopup) {
- WindowsLookAndFeel.setMnemonicHidden(true);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- }
- }
-
- }
-
- public boolean postProcessKeyEvent(KeyEvent ev) {
- if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
- // mnemonic combination, it's consumed, but we need
- // set altKeyPressed to false, otherwise after selection
- // component by mnemonic combination a menu will be open
- altKeyPressed = false;
- return false;
- }
- if (ev.getKeyCode() == KeyEvent.VK_ALT) {
- root = SwingUtilities.getRootPane(ev.getComponent());
- winAncestor = (root == null ? null :
- SwingUtilities.getWindowAncestor(root));
-
- if (ev.getID() == KeyEvent.KEY_PRESSED) {
- if (!altKeyPressed) {
- altPressed(ev);
- }
- altKeyPressed = true;
- return true;
- } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
- if (altKeyPressed) {
- altReleased(ev);
- } else {
- MenuSelectionManager msm =
- MenuSelectionManager.defaultManager();
- MenuElement[] path = msm.getSelectedPath();
- if (path.length <= 0) {
- WindowsLookAndFeel.setMnemonicHidden(true);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- }
- }
- altKeyPressed = false;
- }
- root = null;
- winAncestor = null;
- } else {
- if (WindowsLookAndFeel.isMnemonicHidden() && ev.isAltDown()) {
- WindowsLookAndFeel.setMnemonicHidden(false);
- WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
- }
- altKeyPressed = false;
- }
- return false;
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,503 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-import java.lang.ref.*;
-import java.util.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.ComponentUI;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsScrollBarUI extends BasicScrollBarUI {
- private Grid thumbGrid;
- private Grid highlightGrid;
- private Dimension horizontalThumbSize;
- private Dimension verticalThumbSize;
-
- /**
- * Creates a UI for a JScrollBar.
- *
- * @param c the text field
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsScrollBarUI();
- }
-
- protected void installDefaults() {
- super.installDefaults();
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- scrollbar.setBorder(null);
- horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
- verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
- } else {
- horizontalThumbSize = null;
- verticalThumbSize = null;
- }
- }
-
- private static Dimension getSize(Component component, XPStyle xp, Part part) {
- Skin skin = xp.getSkin(component, part);
- return new Dimension(skin.getWidth(), skin.getHeight());
- }
-
- @Override
- protected Dimension getMinimumThumbSize() {
- if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
- return super.getMinimumThumbSize();
- }
- return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
- ? horizontalThumbSize
- : verticalThumbSize;
- }
-
- public void uninstallUI(JComponent c) {
- super.uninstallUI(c);
- thumbGrid = highlightGrid = null;
- }
-
- protected void configureScrollBarColors() {
- super.configureScrollBarColors();
- Color color = UIManager.getColor("ScrollBar.trackForeground");
- if (color != null && trackColor != null) {
- thumbGrid = Grid.getGrid(color, trackColor);
- }
-
- color = UIManager.getColor("ScrollBar.trackHighlightForeground");
- if (color != null && trackHighlightColor != null) {
- highlightGrid = Grid.getGrid(color, trackHighlightColor);
- }
- }
-
- protected JButton createDecreaseButton(int orientation) {
- return new WindowsArrowButton(orientation,
- UIManager.getColor("ScrollBar.thumb"),
- UIManager.getColor("ScrollBar.thumbShadow"),
- UIManager.getColor("ScrollBar.thumbDarkShadow"),
- UIManager.getColor("ScrollBar.thumbHighlight"));
- }
-
- protected JButton createIncreaseButton(int orientation) {
- return new WindowsArrowButton(orientation,
- UIManager.getColor("ScrollBar.thumb"),
- UIManager.getColor("ScrollBar.thumbShadow"),
- UIManager.getColor("ScrollBar.thumbDarkShadow"),
- UIManager.getColor("ScrollBar.thumbHighlight"));
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- @Override
- protected ArrowButtonListener createArrowButtonListener(){
- // we need to repaint the entire scrollbar because state change for each
- // button causes a state change for the thumb and other button on Vista
- if(XPStyle.isVista()) {
- return new ArrowButtonListener() {
- public void mouseEntered(MouseEvent evt) {
- repaint();
- super.mouseEntered(evt);
- }
- public void mouseExited(MouseEvent evt) {
- repaint();
- super.mouseExited(evt);
- }
- private void repaint() {
- scrollbar.repaint();
- }
- };
- } else {
- return super.createArrowButtonListener();
- }
- }
-
- protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds){
- boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- JScrollBar sb = (JScrollBar)c;
- State state = State.NORMAL;
- // Pending: Implement rollover (hot) and pressed
- if (!sb.isEnabled()) {
- state = State.DISABLED;
- }
- Part part = v ? Part.SBP_LOWERTRACKVERT : Part.SBP_LOWERTRACKHORZ;
- xp.getSkin(sb, part).paintSkin(g, trackBounds, state);
- } else if (thumbGrid == null) {
- super.paintTrack(g, c, trackBounds);
- }
- else {
- thumbGrid.paint(g, trackBounds.x, trackBounds.y, trackBounds.width,
- trackBounds.height);
- if (trackHighlight == DECREASE_HIGHLIGHT) {
- paintDecreaseHighlight(g);
- }
- else if (trackHighlight == INCREASE_HIGHLIGHT) {
- paintIncreaseHighlight(g);
- }
- }
- }
-
- protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
- boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- JScrollBar sb = (JScrollBar)c;
- State state = State.NORMAL;
- if (!sb.isEnabled()) {
- state = State.DISABLED;
- } else if (isDragging) {
- state = State.PRESSED;
- } else if (isThumbRollover()) {
- state = State.HOT;
- } else if (XPStyle.isVista()) {
- if ((incrButton != null && incrButton.getModel().isRollover()) ||
- (decrButton != null && decrButton.getModel().isRollover())) {
- state = State.HOVER;
- }
- }
- // Paint thumb
- Part thumbPart = v ? Part.SBP_THUMBBTNVERT : Part.SBP_THUMBBTNHORZ;
- xp.getSkin(sb, thumbPart).paintSkin(g, thumbBounds, state);
- // Paint gripper
- Part gripperPart = v ? Part.SBP_GRIPPERVERT : Part.SBP_GRIPPERHORZ;
- Skin skin = xp.getSkin(sb, gripperPart);
- Insets gripperInsets = xp.getMargin(c, thumbPart, null, Prop.CONTENTMARGINS);
- if (gripperInsets == null ||
- (v && (thumbBounds.height - gripperInsets.top -
- gripperInsets.bottom >= skin.getHeight())) ||
- (!v && (thumbBounds.width - gripperInsets.left -
- gripperInsets.right >= skin.getWidth()))) {
- skin.paintSkin(g,
- thumbBounds.x + (thumbBounds.width - skin.getWidth()) / 2,
- thumbBounds.y + (thumbBounds.height - skin.getHeight()) / 2,
- skin.getWidth(), skin.getHeight(), state);
- }
- } else {
- super.paintThumb(g, c, thumbBounds);
- }
- }
-
-
- protected void paintDecreaseHighlight(Graphics g) {
- if (highlightGrid == null) {
- super.paintDecreaseHighlight(g);
- }
- else {
- Insets insets = scrollbar.getInsets();
- Rectangle thumbR = getThumbBounds();
- int x, y, w, h;
-
- if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
- x = insets.left;
- y = decrButton.getY() + decrButton.getHeight();
- w = scrollbar.getWidth() - (insets.left + insets.right);
- h = thumbR.y - y;
- }
- else {
- x = decrButton.getX() + decrButton.getHeight();
- y = insets.top;
- w = thumbR.x - x;
- h = scrollbar.getHeight() - (insets.top + insets.bottom);
- }
- highlightGrid.paint(g, x, y, w, h);
- }
- }
-
-
- protected void paintIncreaseHighlight(Graphics g) {
- if (highlightGrid == null) {
- super.paintDecreaseHighlight(g);
- }
- else {
- Insets insets = scrollbar.getInsets();
- Rectangle thumbR = getThumbBounds();
- int x, y, w, h;
-
- if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
- x = insets.left;
- y = thumbR.y + thumbR.height;
- w = scrollbar.getWidth() - (insets.left + insets.right);
- h = incrButton.getY() - y;
- }
- else {
- x = thumbR.x + thumbR.width;
- y = insets.top;
- w = incrButton.getX() - x;
- h = scrollbar.getHeight() - (insets.top + insets.bottom);
- }
- highlightGrid.paint(g, x, y, w, h);
- }
- }
-
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- @Override
- protected void setThumbRollover(boolean active) {
- boolean old = isThumbRollover();
- super.setThumbRollover(active);
- // we need to repaint the entire scrollbar because state change for thumb
- // causes state change for incr and decr buttons on Vista
- if(XPStyle.isVista() && active != old) {
- scrollbar.repaint();
- }
- }
-
- /**
- * WindowsArrowButton is used for the buttons to position the
- * document up/down. It differs from BasicArrowButton in that the
- * preferred size is always a square.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class WindowsArrowButton extends BasicArrowButton {
-
- public WindowsArrowButton(int direction, Color background, Color shadow,
- Color darkShadow, Color highlight) {
- super(direction, background, shadow, darkShadow, highlight);
- }
-
- public WindowsArrowButton(int direction) {
- super(direction);
- }
-
- public void paint(Graphics g) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- ButtonModel model = getModel();
- Skin skin = xp.getSkin(this, Part.SBP_ARROWBTN);
- State state = null;
-
- boolean jointRollover = XPStyle.isVista() && (isThumbRollover() ||
- (this == incrButton && decrButton.getModel().isRollover()) ||
- (this == decrButton && incrButton.getModel().isRollover()));
-
- // normal, rollover, pressed, disabled
- if (model.isArmed() && model.isPressed()) {
- switch (direction) {
- case NORTH: state = State.UPPRESSED; break;
- case SOUTH: state = State.DOWNPRESSED; break;
- case WEST: state = State.LEFTPRESSED; break;
- case EAST: state = State.RIGHTPRESSED; break;
- }
- } else if (!model.isEnabled()) {
- switch (direction) {
- case NORTH: state = State.UPDISABLED; break;
- case SOUTH: state = State.DOWNDISABLED; break;
- case WEST: state = State.LEFTDISABLED; break;
- case EAST: state = State.RIGHTDISABLED; break;
- }
- } else if (model.isRollover() || model.isPressed()) {
- switch (direction) {
- case NORTH: state = State.UPHOT; break;
- case SOUTH: state = State.DOWNHOT; break;
- case WEST: state = State.LEFTHOT; break;
- case EAST: state = State.RIGHTHOT; break;
- }
- } else if (jointRollover) {
- switch (direction) {
- case NORTH: state = State.UPHOVER; break;
- case SOUTH: state = State.DOWNHOVER; break;
- case WEST: state = State.LEFTHOVER; break;
- case EAST: state = State.RIGHTHOVER; break;
- }
- } else {
- switch (direction) {
- case NORTH: state = State.UPNORMAL; break;
- case SOUTH: state = State.DOWNNORMAL; break;
- case WEST: state = State.LEFTNORMAL; break;
- case EAST: state = State.RIGHTNORMAL; break;
- }
- }
-
- skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
- } else {
- super.paint(g);
- }
- }
-
- public Dimension getPreferredSize() {
- int size = 16;
- if (scrollbar != null) {
- switch (scrollbar.getOrientation()) {
- case JScrollBar.VERTICAL:
- size = scrollbar.getWidth();
- break;
- case JScrollBar.HORIZONTAL:
- size = scrollbar.getHeight();
- break;
- }
- size = Math.max(size, 5);
- }
- return new Dimension(size, size);
- }
- }
-
-
- /**
- * This should be pulled out into its own class if more classes need to
- * use it.
- * <p>
- * Grid is used to draw the track for windows scrollbars. Grids
- * are cached in a HashMap, with the key being the rgb components
- * of the foreground/background colors. Further the Grid is held through
- * a WeakRef so that it can be freed when no longer needed. As the
- * Grid is rather expensive to draw, it is drawn in a BufferedImage.
- */
- private static class Grid {
- private static final int BUFFER_SIZE = 64;
- private static HashMap<String, WeakReference<Grid>> map;
-
- private BufferedImage image;
-
- static {
- map = new HashMap<String, WeakReference<Grid>>();
- }
-
- public static Grid getGrid(Color fg, Color bg) {
- String key = fg.getRGB() + " " + bg.getRGB();
- WeakReference<Grid> ref = map.get(key);
- Grid grid = (ref == null) ? null : ref.get();
- if (grid == null) {
- grid = new Grid(fg, bg);
- map.put(key, new WeakReference<Grid>(grid));
- }
- return grid;
- }
-
- public Grid(Color fg, Color bg) {
- int cmap[] = { fg.getRGB(), bg.getRGB() };
- IndexColorModel icm = new IndexColorModel(8, 2, cmap, 0, false, -1,
- DataBuffer.TYPE_BYTE);
- image = new BufferedImage(BUFFER_SIZE, BUFFER_SIZE,
- BufferedImage.TYPE_BYTE_INDEXED, icm);
- Graphics g = image.getGraphics();
- try {
- g.setClip(0, 0, BUFFER_SIZE, BUFFER_SIZE);
- paintGrid(g, fg, bg);
- }
- finally {
- g.dispose();
- }
- }
-
- /**
- * Paints the grid into the specified Graphics at the specified
- * location.
- */
- public void paint(Graphics g, int x, int y, int w, int h) {
- Rectangle clipRect = g.getClipBounds();
- int minX = Math.max(x, clipRect.x);
- int minY = Math.max(y, clipRect.y);
- int maxX = Math.min(clipRect.x + clipRect.width, x + w);
- int maxY = Math.min(clipRect.y + clipRect.height, y + h);
-
- if (maxX <= minX || maxY <= minY) {
- return;
- }
- int xOffset = (minX - x) % 2;
- for (int xCounter = minX; xCounter < maxX;
- xCounter += BUFFER_SIZE) {
- int yOffset = (minY - y) % 2;
- int width = Math.min(BUFFER_SIZE - xOffset,
- maxX - xCounter);
-
- for (int yCounter = minY; yCounter < maxY;
- yCounter += BUFFER_SIZE) {
- int height = Math.min(BUFFER_SIZE - yOffset,
- maxY - yCounter);
-
- g.drawImage(image, xCounter, yCounter,
- xCounter + width, yCounter + height,
- xOffset, yOffset,
- xOffset + width, yOffset + height, null);
- if (yOffset != 0) {
- yCounter -= yOffset;
- yOffset = 0;
- }
- }
- if (xOffset != 0) {
- xCounter -= xOffset;
- xOffset = 0;
- }
- }
- }
-
- /**
- * Actually renders the grid into the Graphics <code>g</code>.
- */
- private void paintGrid(Graphics g, Color fg, Color bg) {
- Rectangle clipRect = g.getClipBounds();
- g.setColor(bg);
- g.fillRect(clipRect.x, clipRect.y, clipRect.width,
- clipRect.height);
- g.setColor(fg);
- g.translate(clipRect.x, clipRect.y);
- int width = clipRect.width;
- int height = clipRect.height;
- int xCounter = clipRect.x % 2;
- for (int end = width - height; xCounter < end; xCounter += 2) {
- g.drawLine(xCounter, 0, xCounter + height, height);
- }
- for (int end = width; xCounter < end; xCounter += 2) {
- g.drawLine(xCounter, 0, width, width - xCounter);
- }
-
- int yCounter = ((clipRect.x % 2) == 0) ? 2 : 1;
- for (int end = height - width; yCounter < end; yCounter += 2) {
- g.drawLine(0, yCounter, width, yCounter + width);
- }
- for (int end = height; yCounter < end; yCounter += 2) {
- g.drawLine(0, yCounter, height - yCounter, height);
- }
- g.translate(-clipRect.x, -clipRect.y);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsScrollPaneUI extends BasicScrollPaneUI
-{}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-
-/**
- * Windows Separator.
- */
-public class WindowsSeparatorUI extends BasicSeparatorUI { }
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.MouseEvent;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsSliderUI extends BasicSliderUI
-{
- private boolean rollover = false;
- private boolean pressed = false;
-
- public WindowsSliderUI(JSlider b){
- super(b);
- }
-
- public static ComponentUI createUI(JComponent b) {
- return new WindowsSliderUI((JSlider)b);
- }
-
-
- /**
- * Overrides to return a private track listener subclass which handles
- * the HOT, PRESSED, and FOCUSED states.
- * @since 1.6
- */
- protected TrackListener createTrackListener(JSlider slider) {
- return new WindowsTrackListener();
- }
-
- private class WindowsTrackListener extends TrackListener {
-
- public void mouseMoved(MouseEvent e) {
- updateRollover(thumbRect.contains(e.getX(), e.getY()));
- super.mouseMoved(e);
- }
-
- public void mouseEntered(MouseEvent e) {
- updateRollover(thumbRect.contains(e.getX(), e.getY()));
- super.mouseEntered(e);
- }
-
- public void mouseExited(MouseEvent e) {
- updateRollover(false);
- super.mouseExited(e);
- }
-
- public void mousePressed(MouseEvent e) {
- updatePressed(thumbRect.contains(e.getX(), e.getY()));
- super.mousePressed(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- updatePressed(false);
- super.mouseReleased(e);
- }
-
- public void updatePressed(boolean newPressed) {
- // You can't press a disabled slider
- if (!slider.isEnabled()) {
- return;
- }
- if (pressed != newPressed) {
- pressed = newPressed;
- slider.repaint(thumbRect);
- }
- }
-
- public void updateRollover(boolean newRollover) {
- // You can't have a rollover on a disabled slider
- if (!slider.isEnabled()) {
- return;
- }
- if (rollover != newRollover) {
- rollover = newRollover;
- slider.repaint(thumbRect);
- }
- }
-
- }
-
-
- public void paintTrack(Graphics g) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
- Part part = vertical ? Part.TKP_TRACKVERT : Part.TKP_TRACK;
- Skin skin = xp.getSkin(slider, part);
-
- if (vertical) {
- int x = (trackRect.width - skin.getWidth()) / 2;
- skin.paintSkin(g, trackRect.x + x, trackRect.y,
- skin.getWidth(), trackRect.height, null);
- } else {
- int y = (trackRect.height - skin.getHeight()) / 2;
- skin.paintSkin(g, trackRect.x, trackRect.y + y,
- trackRect.width, skin.getHeight(), null);
- }
- } else {
- super.paintTrack(g);
- }
- }
-
-
- protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
- }
- super.paintMinorTickForHorizSlider(g, tickBounds, x);
- }
-
- protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
- }
- super.paintMajorTickForHorizSlider(g, tickBounds, x);
- }
-
- protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
- }
- super.paintMinorTickForVertSlider(g, tickBounds, y);
- }
-
- protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
- }
- super.paintMajorTickForVertSlider(g, tickBounds, y);
- }
-
-
- public void paintThumb(Graphics g) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Part part = getXPThumbPart();
- State state = State.NORMAL;
-
- if (slider.hasFocus()) {
- state = State.FOCUSED;
- }
- if (rollover) {
- state = State.HOT;
- }
- if (pressed) {
- state = State.PRESSED;
- }
- if(!slider.isEnabled()) {
- state = State.DISABLED;
- }
-
- xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
- } else {
- super.paintThumb(g);
- }
- }
-
- protected Dimension getThumbSize() {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Dimension size = new Dimension();
- Skin s = xp.getSkin(slider, getXPThumbPart());
- size.width = s.getWidth();
- size.height = s.getHeight();
- return size;
- } else {
- return super.getThumbSize();
- }
- }
-
- private Part getXPThumbPart() {
- Part part;
- boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
- boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
- Boolean paintThumbArrowShape =
- (Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
- if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
- paintThumbArrowShape == Boolean.FALSE) {
- part = vertical ? Part.TKP_THUMBVERT
- : Part.TKP_THUMB;
- } else {
- part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
- : Part.TKP_THUMBBOTTOM;
- }
- return part;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.*;
-import javax.swing.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.Part;
-import static com.sun.java.swing.plaf.windows.TMSchema.State;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-public class WindowsSpinnerUI extends BasicSpinnerUI {
- public static ComponentUI createUI(JComponent c) {
- return new WindowsSpinnerUI();
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- public void paint(Graphics g, JComponent c) {
- if (XPStyle.getXP() != null) {
- paintXPBackground(g, c);
- }
- super.paint(g,c);
- }
-
- private State getXPState(JComponent c) {
- State state = State.NORMAL;
- if (!c.isEnabled()) {
- state = State.DISABLED;
- }
- return state;
- }
-
- private void paintXPBackground(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (xp == null) {
- return;
- }
- Skin skin = xp.getSkin(c, Part.EP_EDIT);
- State state = getXPState(c);
- skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
- }
-
- protected Component createPreviousButton() {
- if (XPStyle.getXP() != null) {
- JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_DOWN);
- Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
- xpButton.setPreferredSize(size);
- xpButton.setRequestFocusEnabled(false);
- installPreviousButtonListeners(xpButton);
- return xpButton;
- }
- return super.createPreviousButton();
- }
-
- protected Component createNextButton() {
- if (XPStyle.getXP() != null) {
- JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_UP);
- Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
- xpButton.setPreferredSize(size);
- xpButton.setRequestFocusEnabled(false);
- installNextButtonListeners(xpButton);
- return xpButton;
- }
- return super.createNextButton();
- }
-
- private UIResource getUIResource(Object[] listeners) {
- for (int counter = 0; counter < listeners.length; counter++) {
- if (listeners[counter] instanceof UIResource) {
- return (UIResource)listeners[counter];
- }
- }
- return null;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.JSplitPane;
-import javax.swing.UIManager;
-import javax.swing.plaf.basic.BasicSplitPaneUI;
-import javax.swing.plaf.basic.BasicSplitPaneDivider;
-
-
-/**
- * Divider used for Windows split pane.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Jeff Dinkins
- */
-@SuppressWarnings("serial") // Superclass is not serializable across versions
-public class WindowsSplitPaneDivider extends BasicSplitPaneDivider
-{
-
- /**
- * Creates a new Windows SplitPaneDivider
- */
- public WindowsSplitPaneDivider(BasicSplitPaneUI ui) {
- super(ui);
- }
-
- /**
- * Paints the divider.
- */
- public void paint(Graphics g) {
- Color bgColor = (splitPane.hasFocus()) ?
- UIManager.getColor("SplitPane.shadow") :
- getBackground();
- Dimension size = getSize();
-
- if(bgColor != null) {
- g.setColor(bgColor);
- g.fillRect(0, 0, size.width, size.height);
- }
- super.paint(g);
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-
-import javax.swing.plaf.basic.BasicSplitPaneUI;
-import javax.swing.plaf.basic.BasicSplitPaneDivider;
-import javax.swing.plaf.*;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsSplitPaneUI extends BasicSplitPaneUI
-{
-
- public WindowsSplitPaneUI() {
- super();
- }
-
- /**
- * Creates a new WindowsSplitPaneUI instance
- */
- public static ComponentUI createUI(JComponent x) {
- return new WindowsSplitPaneUI();
- }
-
- /**
- * Creates the default divider.
- */
- public BasicSplitPaneDivider createDefaultDivider() {
- return new WindowsSplitPaneDivider(this);
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.*;
-import javax.swing.*;
-import java.util.Set;
-import java.util.HashSet;
-import java.awt.event.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
- /**
- * Keys to use for forward focus traversal when the JComponent is
- * managing focus.
- */
- private static Set<KeyStroke> managingFocusForwardTraversalKeys;
-
- /**
- * Keys to use for backward focus traversal when the JComponent is
- * managing focus.
- */
- private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
-
- private boolean contentOpaque = true;
-
- @SuppressWarnings("deprecation")
- protected void installDefaults() {
- super.installDefaults();
- contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
-
- // focus forward traversal key
- if (managingFocusForwardTraversalKeys==null) {
- managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
- managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
- }
- tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
- // focus backward traversal key
- if (managingFocusBackwardTraversalKeys==null) {
- managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
- managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
- }
- tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
- }
-
- protected void uninstallDefaults() {
- // sets the focus forward and backward traversal keys to null
- // to restore the defaults
- tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
- tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
- super.uninstallDefaults();
- }
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsTabbedPaneUI();
- }
-
- protected void setRolloverTab(int index) {
- // Rollover is only supported on XP
- if (XPStyle.getXP() != null) {
- int oldRolloverTab = getRolloverTab();
- super.setRolloverTab(index);
- Rectangle r1 = null;
- Rectangle r2 = null;
- if ( (oldRolloverTab >= 0) && (oldRolloverTab < tabPane.getTabCount()) ) {
- r1 = getTabBounds(tabPane, oldRolloverTab);
- }
- if (index >= 0) {
- r2 = getTabBounds(tabPane, index);
- }
- if (r1 != null) {
- if (r2 != null) {
- tabPane.repaint(r1.union(r2));
- } else {
- tabPane.repaint(r1);
- }
- } else if (r2 != null) {
- tabPane.repaint(r2);
- }
- }
- }
-
- protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null && (contentOpaque || tabPane.isOpaque())) {
- Skin skin = xp.getSkin(tabPane, Part.TABP_PANE);
- if (skin != null) {
- Insets insets = tabPane.getInsets();
- // Note: don't call getTabAreaInsets(), because it causes rotation.
- // Make sure "TabbedPane.tabsOverlapBorder" is set to true in WindowsLookAndFeel
- Insets tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
- int x = insets.left;
- int y = insets.top;
- int w = tabPane.getWidth() - insets.right - insets.left;
- int h = tabPane.getHeight() - insets.top - insets.bottom;
-
- // Expand area by tabAreaInsets.bottom to allow tabs to overlap onto the border.
- if (tabPlacement == LEFT || tabPlacement == RIGHT) {
- int tabWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
- if (tabPlacement == LEFT) {
- x += (tabWidth - tabAreaInsets.bottom);
- }
- w -= (tabWidth - tabAreaInsets.bottom);
- } else {
- int tabHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
- if (tabPlacement == TOP) {
- y += (tabHeight - tabAreaInsets.bottom);
- }
- h -= (tabHeight - tabAreaInsets.bottom);
- }
-
- paintRotatedSkin(g, skin, tabPlacement, x, y, w, h, null);
- return;
- }
- }
- super.paintContentBorder(g, tabPlacement, selectedIndex);
- }
-
- protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex,
- int x, int y, int w, int h, boolean isSelected ) {
- if (XPStyle.getXP() == null) {
- super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
- }
- }
-
- protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
- int x, int y, int w, int h, boolean isSelected ) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Part part;
-
- int tabCount = tabPane.getTabCount();
- int tabRun = getRunForTab(tabCount, tabIndex);
- if (tabRuns[tabRun] == tabIndex) {
- part = Part.TABP_TABITEMLEFTEDGE;
- } else if (tabCount > 1 && lastTabInRun(tabCount, tabRun) == tabIndex) {
- part = Part.TABP_TABITEMRIGHTEDGE;
- if (isSelected) {
- // Align with right edge
- if (tabPlacement == TOP || tabPlacement == BOTTOM) {
- w++;
- } else {
- h++;
- }
- }
- } else {
- part = Part.TABP_TABITEM;
- }
-
- State state = State.NORMAL;
- if (isSelected) {
- state = State.SELECTED;
- } else if (tabIndex == getRolloverTab()) {
- state = State.HOT;
- }
-
- paintRotatedSkin(g, xp.getSkin(tabPane, part), tabPlacement, x, y, w, h, state);
- } else {
- super.paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
- }
- }
-
- private void paintRotatedSkin(Graphics g, Skin skin, int tabPlacement,
- int x, int y, int w, int h, State state) {
- Graphics2D g2d = (Graphics2D)g.create();
- g2d.translate(x, y);
- switch (tabPlacement) {
- case RIGHT: g2d.translate(w, 0);
- g2d.rotate(Math.toRadians(90.0));
- skin.paintSkin(g2d, 0, 0, h, w, state);
- break;
-
- case LEFT: g2d.scale(-1.0, 1.0);
- g2d.rotate(Math.toRadians(90.0));
- skin.paintSkin(g2d, 0, 0, h, w, state);
- break;
-
- case BOTTOM: g2d.translate(0, h);
- g2d.scale(-1.0, 1.0);
- g2d.rotate(Math.toRadians(180.0));
- skin.paintSkin(g2d, 0, 0, w, h, state);
- break;
-
- case TOP:
- default: skin.paintSkin(g2d, 0, 0, w, h, state);
- }
- g2d.dispose();
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.table.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.*;
-import sun.swing.table.*;
-import sun.swing.SwingUtilities2;
-
-
-public class WindowsTableHeaderUI extends BasicTableHeaderUI {
- private TableCellRenderer originalHeaderRenderer;
-
- public static ComponentUI createUI(JComponent h) {
- return new WindowsTableHeaderUI();
- }
-
- public void installUI(JComponent c) {
- super.installUI(c);
-
- if (XPStyle.getXP() != null) {
- originalHeaderRenderer = header.getDefaultRenderer();
- if (originalHeaderRenderer instanceof UIResource) {
- header.setDefaultRenderer(new XPDefaultRenderer());
- }
- }
- }
-
- public void uninstallUI(JComponent c) {
- if (header.getDefaultRenderer() instanceof XPDefaultRenderer) {
- header.setDefaultRenderer(originalHeaderRenderer);
- }
- super.uninstallUI(c);
- }
-
- @Override
- protected void rolloverColumnUpdated(int oldColumn, int newColumn) {
- if (XPStyle.getXP() != null) {
- header.repaint(header.getHeaderRect(oldColumn));
- header.repaint(header.getHeaderRect(newColumn));
- }
- }
-
- @SuppressWarnings("serial") // JDK-implementation class
- private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer {
- Skin skin;
- boolean isSelected, hasFocus, hasRollover;
- int column;
-
- XPDefaultRenderer() {
- setHorizontalAlignment(LEADING);
- }
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus,
- int row, int column) {
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, column);
- this.isSelected = isSelected;
- this.hasFocus = hasFocus;
- this.column = column;
- this.hasRollover = (column == getRolloverColumn());
- if (skin == null) {
- XPStyle xp = XPStyle.getXP();
- skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null;
- }
- Insets margins = (skin != null) ? skin.getContentMargin() : null;
- Border border = null;
- int contentTop = 0;
- int contentLeft = 0;
- int contentBottom = 0;
- int contentRight = 0;
- if (margins != null) {
- contentTop = margins.top;
- contentLeft = margins.left;
- contentBottom = margins.bottom;
- contentRight = margins.right;
- }
- /* idk:
- * Both on Vista and XP there is some offset to the
- * HP_HEADERITEM content. It does not seem to come from
- * Prop.CONTENTMARGINS. Do not know where it is defined.
- * using some hardcoded values.
- */
- contentLeft += 5;
- contentBottom += 4;
- contentRight += 5;
-
- /* On Vista sortIcon is painted above the header's text.
- * We use border to paint it.
- */
- Icon sortIcon;
- if (WindowsLookAndFeel.isOnVista()
- && ((sortIcon = getIcon()) instanceof javax.swing.plaf.UIResource
- || sortIcon == null)) {
- contentTop += 1;
- setIcon(null);
- sortIcon = null;
- SortOrder sortOrder =
- getColumnSortOrder(table, column);
- if (sortOrder != null) {
- switch (sortOrder) {
- case ASCENDING:
- sortIcon =
- UIManager.getIcon("Table.ascendingSortIcon");
- break;
- case DESCENDING:
- sortIcon =
- UIManager.getIcon("Table.descendingSortIcon");
- break;
- }
- }
- if (sortIcon != null) {
- contentBottom = sortIcon.getIconHeight();
- border = new IconBorder(sortIcon, contentTop, contentLeft,
- contentBottom, contentRight);
- } else {
- sortIcon =
- UIManager.getIcon("Table.ascendingSortIcon");
- int sortIconHeight =
- (sortIcon != null) ? sortIcon.getIconHeight() : 0;
- if (sortIconHeight != 0) {
- contentBottom = sortIconHeight;
- }
- border =
- new EmptyBorder(
- sortIconHeight + contentTop, contentLeft,
- contentBottom, contentRight);
- }
- } else {
- contentTop += 3;
- border = new EmptyBorder(contentTop, contentLeft,
- contentBottom, contentRight);
- }
- setBorder(border);
- return this;
- }
-
- public void paint(Graphics g) {
- Dimension size = getSize();
- State state = State.NORMAL;
- TableColumn draggedColumn = header.getDraggedColumn();
- if (draggedColumn != null &&
- column == SwingUtilities2.convertColumnIndexToView(
- header.getColumnModel(), draggedColumn.getModelIndex())) {
- state = State.PRESSED;
- } else if (isSelected || hasFocus || hasRollover) {
- state = State.HOT;
- }
- /* on Vista there are more states for sorted columns */
- if (WindowsLookAndFeel.isOnVista()) {
- SortOrder sortOrder = getColumnSortOrder(header.getTable(), column);
- if (sortOrder != null) {
- switch(sortOrder) {
- case ASCENDING:
- case DESCENDING:
- switch (state) {
- case NORMAL:
- state = State.SORTEDNORMAL;
- break;
- case PRESSED:
- state = State.SORTEDPRESSED;
- break;
- case HOT:
- state = State.SORTEDHOT;
- break;
- default:
- /* do nothing */
- }
- break;
- default :
- /* do nothing */
- }
- }
- }
- skin.paintSkin(g, 0, 0, size.width-1, size.height-1, state);
- super.paint(g);
- }
- }
-
- /**
- * A border with an Icon at the middle of the top side.
- * Outer insets can be provided for this border.
- */
- private static class IconBorder implements Border, UIResource{
- private final Icon icon;
- private final int top;
- private final int left;
- private final int bottom;
- private final int right;
- /**
- * Creates this border;
- * @param icon - icon to paint for this border
- * @param top, left, bottom, right - outer insets for this border
- */
- public IconBorder(Icon icon, int top, int left,
- int bottom, int right) {
- this.icon = icon;
- this.top = top;
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- }
- public Insets getBorderInsets(Component c) {
- return new Insets(icon.getIconHeight() + top, left, bottom, right);
- }
- public boolean isBorderOpaque() {
- return false;
- }
- public void paintBorder(Component c, Graphics g, int x, int y,
- int width, int height) {
- icon.paintIcon(c, g,
- x + left + (width - left - right - icon.getIconWidth()) / 2,
- y + top);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.text.Caret;
-
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsTextAreaUI extends BasicTextAreaUI {
- /**
- * Creates the object to use for a caret. By default an
- * instance of WindowsCaret is created. This method
- * can be redefined to provide something else that implements
- * the InputPosition interface or a subclass of DefaultCaret.
- *
- * @return the caret object
- */
- protected Caret createCaret() {
- return new WindowsTextUI.WindowsCaret();
- }
-
- /**
- * Creates a UI for a JTextField.
- *
- * @param c the text field
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsTextAreaUI();
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.beans.PropertyChangeEvent;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.BasicTextFieldUI;
-import javax.swing.text.*;
-import javax.swing.*;
-import javax.swing.plaf.UIResource;
-import sun.swing.DefaultLookup;
-
-
-
-/**
- * Provides the Windows look and feel for a text field. This
- * is basically the following customizations to the default
- * look-and-feel.
- * <ul>
- * <li>The border is beveled (using the standard control color).
- * <li>The background is white by default.
- * <li>The highlight color is a dark color, blue by default.
- * <li>The foreground color is high contrast in the selected
- * area, white by default. The unselected foreground is black.
- * <li>The cursor blinks at about 1/2 second intervals.
- * <li>The entire value is selected when focus is gained.
- * <li>Shift-left-arrow and shift-right-arrow extend selection
- * <li>Ctrl-left-arrow and ctrl-right-arrow act like home and
- * end respectively.
- * </ul>
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Timothy Prinzing
- */
-public class WindowsTextFieldUI extends BasicTextFieldUI
-{
- /**
- * Creates a UI for a JTextField.
- *
- * @param c the text field
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsTextFieldUI();
- }
-
- /**
- * Paints a background for the view. This will only be
- * called if isOpaque() on the associated component is
- * true. The default is to paint the background color
- * of the component.
- *
- * @param g the graphics context
- */
- protected void paintBackground(Graphics g) {
- super.paintBackground(g);
- }
-
- /**
- * Creates the caret for a field.
- *
- * @return the caret
- */
- protected Caret createCaret() {
- return new WindowsFieldCaret();
- }
-
- /**
- * WindowsFieldCaret has different scrolling behavior than
- * DefaultCaret.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- static class WindowsFieldCaret extends DefaultCaret implements UIResource {
-
- public WindowsFieldCaret() {
- super();
- }
-
- /**
- * Adjusts the visibility of the caret according to
- * the windows feel which seems to be to move the
- * caret out into the field by about a quarter of
- * a field length if not visible.
- */
- protected void adjustVisibility(Rectangle r) {
- SwingUtilities.invokeLater(new SafeScroller(r));
- }
-
- /**
- * Gets the painter for the Highlighter.
- *
- * @return the painter
- */
- protected Highlighter.HighlightPainter getSelectionPainter() {
- return WindowsTextUI.WindowsPainter;
- }
-
-
- private class SafeScroller implements Runnable {
- SafeScroller(Rectangle r) {
- this.r = r;
- }
-
- @SuppressWarnings("deprecation")
- public void run() {
- JTextField field = (JTextField) getComponent();
- if (field != null) {
- TextUI ui = field.getUI();
- int dot = getDot();
- // PENDING: We need to expose the bias in DefaultCaret.
- Position.Bias bias = Position.Bias.Forward;
- Rectangle startRect = null;
- try {
- startRect = ui.modelToView(field, dot, bias);
- } catch (BadLocationException ble) {}
-
- Insets i = field.getInsets();
- BoundedRangeModel vis = field.getHorizontalVisibility();
- int x = r.x + vis.getValue() - i.left;
- int quarterSpan = vis.getExtent() / 4;
- if (r.x < i.left) {
- vis.setValue(x - quarterSpan);
- } else if (r.x + r.width > i.left + vis.getExtent()) {
- vis.setValue(x - (3 * quarterSpan));
- }
- // If we scroll, our visual location will have changed,
- // but we won't have updated our internal location as
- // the model hasn't changed. This checks for the change,
- // and if necessary, resets the internal location.
- if (startRect != null) {
- try {
- Rectangle endRect;
- endRect = ui.modelToView(field, dot, bias);
- if (endRect != null && !endRect.equals(startRect)){
- damage(endRect);
- }
- } catch (BadLocationException ble) {}
- }
- }
- }
-
- private Rectangle r;
- }
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.text.Caret;
-
-
-/**
- * Windows rendition of the component.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public class WindowsTextPaneUI extends BasicTextPaneUI
-{
- /**
- * Creates a UI for a JTextPane.
- *
- * @param c the styled text component
- * @return the UI
- */
- public static ComponentUI createUI(JComponent c) {
- return new WindowsTextPaneUI();
- }
-
- /**
- * Creates the object to use for a caret. By default an
- * instance of WindowsCaret is created. This method
- * can be redefined to provide something else that implements
- * the InputPosition interface or a subclass of DefaultCaret.
- *
- * @return the caret object
- */
- protected Caret createCaret() {
- return new WindowsTextUI.WindowsCaret();
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.TextUI;
-import javax.swing.plaf.UIResource;
-import javax.swing.text.*;
-
-/**
- * Windows text rendering.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
-public abstract class WindowsTextUI extends BasicTextUI {
- /**
- * Creates the object to use for a caret. By default an
- * instance of WindowsCaret is created. This method
- * can be redefined to provide something else that implements
- * the InputPosition interface or a subclass of DefaultCaret.
- *
- * @return the caret object
- */
- protected Caret createCaret() {
- return new WindowsCaret();
- }
-
- /* public */
- static LayeredHighlighter.LayerPainter WindowsPainter = new WindowsHighlightPainter(null);
-
- /* public */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- static class WindowsCaret extends DefaultCaret
- implements UIResource {
- /**
- * Gets the painter for the Highlighter.
- *
- * @return the painter
- */
- protected Highlighter.HighlightPainter getSelectionPainter() {
- return WindowsTextUI.WindowsPainter;
- }
- }
-
- /* public */
- static class WindowsHighlightPainter extends
- DefaultHighlighter.DefaultHighlightPainter {
- WindowsHighlightPainter(Color c) {
- super(c);
- }
-
- // --- HighlightPainter methods ---------------------------------------
-
- /**
- * Paints a highlight.
- *
- * @param g the graphics context
- * @param offs0 the starting model offset >= 0
- * @param offs1 the ending model offset >= offs1
- * @param bounds the bounding box for the highlight
- * @param c the editor
- */
- @SuppressWarnings("deprecation")
- public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
- Rectangle alloc = bounds.getBounds();
- try {
- // --- determine locations ---
- TextUI mapper = c.getUI();
- Rectangle p0 = mapper.modelToView(c, offs0);
- Rectangle p1 = mapper.modelToView(c, offs1);
-
- // --- render ---
- Color color = getColor();
-
- if (color == null) {
- g.setColor(c.getSelectionColor());
- }
- else {
- g.setColor(color);
- }
- boolean firstIsDot = false;
- boolean secondIsDot = false;
- if (c.isEditable()) {
- int dot = c.getCaretPosition();
- firstIsDot = (offs0 == dot);
- secondIsDot = (offs1 == dot);
- }
- if (p0.y == p1.y) {
- // same line, render a rectangle
- Rectangle r = p0.union(p1);
- if (r.width > 0) {
- if (firstIsDot) {
- r.x++;
- r.width--;
- }
- else if (secondIsDot) {
- r.width--;
- }
- }
- g.fillRect(r.x, r.y, r.width, r.height);
- } else {
- // different lines
- int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
- if (firstIsDot && p0ToMarginWidth > 0) {
- p0.x++;
- p0ToMarginWidth--;
- }
- g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
- if ((p0.y + p0.height) != p1.y) {
- g.fillRect(alloc.x, p0.y + p0.height, alloc.width,
- p1.y - (p0.y + p0.height));
- }
- if (secondIsDot && p1.x > alloc.x) {
- p1.x--;
- }
- g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
- }
- } catch (BadLocationException e) {
- // can't render
- }
- }
-
- // --- LayerPainter methods ----------------------------
- /**
- * Paints a portion of a highlight.
- *
- * @param g the graphics context
- * @param offs0 the starting model offset >= 0
- * @param offs1 the ending model offset >= offs1
- * @param bounds the bounding box of the view, which is not
- * necessarily the region to paint.
- * @param c the editor
- * @param view View painting for
- * @return region drawing occurred in
- */
- public Shape paintLayer(Graphics g, int offs0, int offs1,
- Shape bounds, JTextComponent c, View view) {
- Color color = getColor();
-
- if (color == null) {
- g.setColor(c.getSelectionColor());
- }
- else {
- g.setColor(color);
- }
- boolean firstIsDot = false;
- boolean secondIsDot = false;
- if (c.isEditable()) {
- int dot = c.getCaretPosition();
- firstIsDot = (offs0 == dot);
- secondIsDot = (offs1 == dot);
- }
- if (offs0 == view.getStartOffset() &&
- offs1 == view.getEndOffset()) {
- // Contained in view, can just use bounds.
- Rectangle alloc;
- if (bounds instanceof Rectangle) {
- alloc = (Rectangle)bounds;
- }
- else {
- alloc = bounds.getBounds();
- }
- if (firstIsDot && alloc.width > 0) {
- g.fillRect(alloc.x + 1, alloc.y, alloc.width - 1,
- alloc.height);
- }
- else if (secondIsDot && alloc.width > 0) {
- g.fillRect(alloc.x, alloc.y, alloc.width - 1,
- alloc.height);
- }
- else {
- g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
- }
- return alloc;
- }
- else {
- // Should only render part of View.
- try {
- // --- determine locations ---
- Shape shape = view.modelToView(offs0, Position.Bias.Forward,
- offs1,Position.Bias.Backward,
- bounds);
- Rectangle r = (shape instanceof Rectangle) ?
- (Rectangle)shape : shape.getBounds();
- if (firstIsDot && r.width > 0) {
- g.fillRect(r.x + 1, r.y, r.width - 1, r.height);
- }
- else if (secondIsDot && r.width > 0) {
- g.fillRect(r.x, r.y, r.width - 1, r.height);
- }
- else {
- g.fillRect(r.x, r.y, r.width, r.height);
- }
- return r;
- } catch (BadLocationException e) {
- // can't render
- }
- }
- // Only if exception
- return null;
- }
-
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import sun.awt.AppContext;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.border.*;
-import javax.swing.plaf.*;
-import javax.swing.*;
-
-import java.awt.*;
-import java.beans.PropertyChangeEvent;
-
-
-
-/**
- * A Windows toggle button.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Jeff Dinkins
- */
-public class WindowsToggleButtonUI extends BasicToggleButtonUI
-{
- protected int dashedRectGapX;
- protected int dashedRectGapY;
- protected int dashedRectGapWidth;
- protected int dashedRectGapHeight;
-
- protected Color focusColor;
-
- private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object();
-
- private boolean defaults_initialized = false;
-
- public static ComponentUI createUI(JComponent b) {
- AppContext appContext = AppContext.getAppContext();
- WindowsToggleButtonUI windowsToggleButtonUI =
- (WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
- if (windowsToggleButtonUI == null) {
- windowsToggleButtonUI = new WindowsToggleButtonUI();
- appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
- }
- return windowsToggleButtonUI;
- }
-
-
- // ********************************
- // Defaults
- // ********************************
- protected void installDefaults(AbstractButton b) {
- super.installDefaults(b);
- if(!defaults_initialized) {
- String pp = getPropertyPrefix();
- dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
- dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
- dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
- dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
- focusColor = UIManager.getColor(pp + "focus");
- defaults_initialized = true;
- }
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- b.setBorder(xp.getBorder(b, WindowsButtonUI.getXPButtonType(b)));
- LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
- LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
- }
- }
-
- protected void uninstallDefaults(AbstractButton b) {
- super.uninstallDefaults(b);
- defaults_initialized = false;
- }
-
-
- protected Color getFocusColor() {
- return focusColor;
- }
-
-
- // ********************************
- // Paint Methods
- // ********************************
-
- private transient Color cachedSelectedColor = null;
- private transient Color cachedBackgroundColor = null;
- private transient Color cachedHighlightColor = null;
-
- protected void paintButtonPressed(Graphics g, AbstractButton b) {
- if (XPStyle.getXP() == null && b.isContentAreaFilled()) {
- Color oldColor = g.getColor();
- Color c1 = b.getBackground();
- Color c2 = UIManager.getColor("ToggleButton.highlight");
- if (c1 != cachedBackgroundColor || c2 != cachedHighlightColor) {
- int r1 = c1.getRed(), r2 = c2.getRed();
- int g1 = c1.getGreen(), g2 = c2.getGreen();
- int b1 = c1.getBlue(), b2 = c2.getBlue();
- cachedSelectedColor = new Color(
- Math.min(r1, r2) + Math.abs(r1 - r2) / 2,
- Math.min(g1, g2) + Math.abs(g1 - g2) / 2,
- Math.min(b1, b2) + Math.abs(b1 - b2) / 2
- );
- cachedBackgroundColor = c1;
- cachedHighlightColor = c2;
- }
- g.setColor(cachedSelectedColor);
- g.fillRect(0, 0, b.getWidth(), b.getHeight());
- g.setColor(oldColor);
- }
- }
-
- public void paint(Graphics g, JComponent c) {
- if (XPStyle.getXP() != null) {
- WindowsButtonUI.paintXPButtonBackground(g, c);
- }
- super.paint(g, c);
- }
-
-
- /**
- * Overridden method to render the text without the mnemonic
- */
- protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
- WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
- }
-
- protected void paintFocus(Graphics g, AbstractButton b,
- Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
- g.setColor(getFocusColor());
- BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
- b.getWidth() - dashedRectGapWidth,
- b.getHeight() - dashedRectGapHeight);
- }
-
- // ********************************
- // Layout Methods
- // ********************************
- public Dimension getPreferredSize(JComponent c) {
- Dimension d = super.getPreferredSize(c);
-
- /* Ensure that the width and height of the button is odd,
- * to allow for the focus line if focus is painted
- */
- AbstractButton b = (AbstractButton)c;
- if (d != null && b.isFocusPainted()) {
- if(d.width % 2 == 0) { d.width += 1; }
- if(d.height % 2 == 0) { d.height += 1; }
- }
- return d;
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.Part;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * Draws Windows toolbar separators.
- *
- * @author Mark Davidson
- */
-public class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI {
-
- public static ComponentUI createUI( JComponent c ) {
- return new WindowsToolBarSeparatorUI();
- }
-
- public Dimension getPreferredSize(JComponent c) {
- Dimension size = ((JToolBar.Separator)c).getSeparatorSize();
-
- if (size != null) {
- size = size.getSize();
- } else {
- size = new Dimension(6, 6);
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
- Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
- Skin skin = xp.getSkin(c, part);
- size.width = skin.getWidth();
- size.height = skin.getHeight();
- }
-
- if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
- size.height = 0;
- } else {
- size.width = 0;
- }
- }
- return size;
- }
-
- public Dimension getMaximumSize(JComponent c) {
- Dimension pref = getPreferredSize(c);
- if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
- return new Dimension(pref.width, Short.MAX_VALUE);
- } else {
- return new Dimension(Short.MAX_VALUE, pref.height);
- }
- }
-
- public void paint( Graphics g, JComponent c ) {
- boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
- Dimension size = c.getSize();
-
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
- Skin skin = xp.getSkin(c, part);
-
- int dx = vertical ? (size.width - skin.getWidth()) / 2 : 0;
- int dy = vertical ? 0 : (size.height - skin.getHeight()) / 2;
- int dw = vertical ? skin.getWidth() : size.width;
- int dh = vertical ? size.height : skin.getHeight();
- skin.paintSkin(g, dx, dy, dw, dh, null);
- } else {
-
- Color temp = g.getColor();
-
- UIDefaults table = UIManager.getLookAndFeelDefaults();
-
- Color shadow = table.getColor("ToolBar.shadow");
- Color highlight = table.getColor("ToolBar.highlight");
-
- if (vertical) {
- int x = (size.width / 2) - 1;
- g.setColor(shadow);
- g.drawLine(x, 2, x, size.height - 2);
-
- g.setColor(highlight);
- g.drawLine(x + 1, 2, x + 1, size.height - 2);
- } else {
- int y = (size.height / 2) - 1;
- g.setColor(shadow);
- g.drawLine(2, y, size.width - 2, y);
- g.setColor(highlight);
- g.drawLine(2, y + 1, size.width - 2, y + 1);
- }
- g.setColor(temp);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-
-import javax.swing.AbstractButton;
-import javax.swing.JComponent;
-import javax.swing.JToggleButton;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
-
-import javax.swing.border.Border;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-
-import javax.swing.plaf.*;
-
-import javax.swing.plaf.basic.BasicBorders;
-import javax.swing.plaf.basic.BasicToolBarUI;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.Part;
-
-
-public class WindowsToolBarUI extends BasicToolBarUI {
-
- public static ComponentUI createUI(JComponent c) {
- return new WindowsToolBarUI();
- }
-
- protected void installDefaults() {
- if (XPStyle.getXP() != null) {
- setRolloverBorders(true);
- }
- super.installDefaults();
- }
-
- protected Border createRolloverBorder() {
- if (XPStyle.getXP() != null) {
- return new EmptyBorder(3, 3, 3, 3);
- } else {
- return super.createRolloverBorder();
- }
- }
-
- protected Border createNonRolloverBorder() {
- if (XPStyle.getXP() != null) {
- return new EmptyBorder(3, 3, 3, 3);
- } else {
- return super.createNonRolloverBorder();
- }
- }
-
- public void paint(Graphics g, JComponent c) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- xp.getSkin(c, Part.TP_TOOLBAR).paintSkin(g, 0, 0,
- c.getWidth(), c.getHeight(), null, true);
- } else {
- super.paint(g, c);
- }
- }
-
- /**
- * {@inheritDoc}
- * @since 1.6
- */
- protected Border getRolloverBorder(AbstractButton b) {
- XPStyle xp = XPStyle.getXP();
- if (xp != null) {
- return xp.getBorder(b, WindowsButtonUI.getXPButtonType(b));
- } else {
- return super.getRolloverBorder(b);
- }
- }
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import java.io.*;
-import java.util.*;
-
-import javax.swing.plaf.basic.*;
-import javax.swing.*;
-import javax.swing.plaf.*;
-
-import javax.swing.tree.*;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
-
-
-/**
- * A Windows tree.
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- *
- * @author Scott Violet
- */
-public class WindowsTreeUI extends BasicTreeUI {
-
- public static ComponentUI createUI( JComponent c )
- {
- return new WindowsTreeUI();
- }
-
-
- /**
- * Ensures that the rows identified by beginRow through endRow are
- * visible.
- */
- protected void ensureRowsAreVisible(int beginRow, int endRow) {
- if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) {
- Rectangle visRect = tree.getVisibleRect();
- if(beginRow == endRow) {
- Rectangle scrollBounds = getPathBounds(tree, getPathForRow
- (tree, beginRow));
-
- if(scrollBounds != null) {
- scrollBounds.x = visRect.x;
- scrollBounds.width = visRect.width;
- tree.scrollRectToVisible(scrollBounds);
- }
- }
- else {
- Rectangle beginRect = getPathBounds(tree, getPathForRow
- (tree, beginRow));
- if (beginRect != null) {
- Rectangle testRect = beginRect;
- int beginY = beginRect.y;
- int maxY = beginY + visRect.height;
-
- for(int counter = beginRow + 1; counter <= endRow; counter++) {
- testRect = getPathBounds(tree,
- getPathForRow(tree, counter));
- if(testRect != null && (testRect.y + testRect.height) > maxY) {
- counter = endRow;
- }
- }
-
- if (testRect == null) {
- return;
- }
-
- tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
- testRect.y + testRect.height-
- beginY));
- }
- }
- }
- }
-
- protected static final int HALF_SIZE = 4;
- protected static final int SIZE = 9;
-
- /**
- * Returns the default cell renderer that is used to do the
- * stamping of each node.
- */
- protected TreeCellRenderer createDefaultCellRenderer() {
- return new WindowsTreeCellRenderer();
- }
-
- /**
- * The minus sign button icon
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
- @SuppressWarnings("serial") // Same-version serialization only
- public static class ExpandedIcon implements Icon, Serializable {
-
- public static Icon createExpandedIcon() {
- return new ExpandedIcon();
- }
-
- Skin getSkin(Component c) {
- XPStyle xp = XPStyle.getXP();
- return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- Skin skin = getSkin(c);
- if (skin != null) {
- skin.paintSkin(g, x, y, State.OPENED);
- return;
- }
-
- Color backgroundColor = c.getBackground();
-
- if(backgroundColor != null)
- g.setColor(backgroundColor);
- else
- g.setColor(Color.white);
- g.fillRect(x, y, SIZE-1, SIZE-1);
- g.setColor(Color.gray);
- g.drawRect(x, y, SIZE-1, SIZE-1);
- g.setColor(Color.black);
- g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
- }
-
- public int getIconWidth() {
- Skin skin = getSkin(null);
- return (skin != null) ? skin.getWidth() : SIZE;
- }
-
- public int getIconHeight() {
- Skin skin = getSkin(null);
- return (skin != null) ? skin.getHeight() : SIZE;
- }
- }
-
- /**
- * The plus sign button icon
- * <p>
- * <strong>Warning:</strong>
- * Serialized objects of this class will not be compatible with
- * future Swing releases. The current serialization support is appropriate
- * for short term storage or RMI between applications running the same
- * version of Swing. A future release of Swing will provide support for
- * long term persistence.
- */
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public static class CollapsedIcon extends ExpandedIcon {
- public static Icon createCollapsedIcon() {
- return new CollapsedIcon();
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- Skin skin = getSkin(c);
- if (skin != null) {
- skin.paintSkin(g, x, y, State.CLOSED);
- } else {
- super.paintIcon(c, g, x, y);
- g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
- }
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
-
- /**
- * Configures the renderer based on the passed in components.
- * The value is set from messaging the tree with
- * <code>convertValueToText</code>, which ultimately invokes
- * <code>toString</code> on <code>value</code>.
- * The foreground color is set based on the selection and the icon
- * is set based on on leaf and expanded.
- */
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean sel,
- boolean expanded,
- boolean leaf, int row,
- boolean hasFocus) {
- super.getTreeCellRendererComponent(tree, value, sel,
- expanded, leaf, row,
- hasFocus);
- // Windows displays the open icon when the tree item selected.
- if (!tree.isEnabled()) {
- setEnabled(false);
- if (leaf) {
- setDisabledIcon(getLeafIcon());
- } else if (sel) {
- setDisabledIcon(getOpenIcon());
- } else {
- setDisabledIcon(getClosedIcon());
- }
- }
- else {
- setEnabled(true);
- if (leaf) {
- setIcon(getLeafIcon());
- } else if (sel) {
- setIcon(getOpenIcon());
- } else {
- setIcon(getClosedIcon());
- }
- }
- return this;
- }
-
- }
-
-}
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,774 +0,0 @@
-/*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * <p>These classes are designed to be used while the
- * corresponding <code>LookAndFeel</code> class has been installed
- * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
- * Using them while a different <code>LookAndFeel</code> is installed
- * may produce unexpected results, including exceptions.
- * Additionally, changing the <code>LookAndFeel</code>
- * maintained by the <code>UIManager</code> without updating the
- * corresponding <code>ComponentUI</code> of any
- * <code>JComponent</code>s may also produce unexpected results,
- * such as the wrong colors showing up, and is generally not
- * encouraged.
- *
- */
-
-package com.sun.java.swing.plaf.windows;
-
-import java.awt.*;
-import java.awt.image.*;
-import java.security.AccessController;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.plaf.*;
-import javax.swing.text.JTextComponent;
-
-import sun.awt.image.SunWritableRaster;
-import sun.awt.windows.ThemeReader;
-import sun.security.action.GetPropertyAction;
-import sun.swing.CachedPainter;
-
-import static com.sun.java.swing.plaf.windows.TMSchema.*;
-
-
-/**
- * Implements Windows XP Styles for the Windows Look and Feel.
- *
- * @author Leif Samuelsson
- */
-class XPStyle {
- // Singleton instance of this class
- private static XPStyle xp;
-
- // Singleton instance of SkinPainter
- private static SkinPainter skinPainter = new SkinPainter();
-
- private static Boolean themeActive = null;
-
- private HashMap<String, Border> borderMap;
- private HashMap<String, Color> colorMap;
-
- private boolean flatMenus;
-
- static {
- invalidateStyle();
- }
-
- /** Static method for clearing the hashmap and loading the
- * current XP style and theme
- */
- static synchronized void invalidateStyle() {
- xp = null;
- themeActive = null;
- skinPainter.flush();
- }
-
- /** Get the singleton instance of this class
- *
- * @return the singleton instance of this class or null if XP styles
- * are not active or if this is not Windows XP
- */
- static synchronized XPStyle getXP() {
- if (themeActive == null) {
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- themeActive =
- (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
- if (themeActive == null) {
- themeActive = Boolean.FALSE;
- }
- if (themeActive.booleanValue()) {
- GetPropertyAction propertyAction =
- new GetPropertyAction("swing.noxp");
- if (AccessController.doPrivileged(propertyAction) == null &&
- ThemeReader.isThemed() &&
- !(UIManager.getLookAndFeel()
- instanceof WindowsClassicLookAndFeel)) {
-
- xp = new XPStyle();
- }
- }
- }
- return ThemeReader.isXPStyleEnabled() ? xp : null;
- }
-
- static boolean isVista() {
- XPStyle xp = XPStyle.getXP();
- return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
- }
-
- /** Get a named <code>String</code> value from the current style
- *
- * @param part a <code>Part</code>
- * @param state a <code>String</code>
- * @param prop a <code>String</code>
- * @return a <code>String</code> or null if key is not found
- * in the current style
- *
- * This is currently only used by WindowsInternalFrameTitlePane for painting
- * title foregound and can be removed when no longer needed
- */
- String getString(Component c, Part part, State state, Prop prop) {
- return getTypeEnumName(c, part, state, prop);
- }
-
- TypeEnum getTypeEnum(Component c, Part part, State state, Prop prop) {
- int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- return TypeEnum.getTypeEnum(prop, enumValue);
- }
-
- private static String getTypeEnumName(Component c, Part part, State state, Prop prop) {
- int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- if (enumValue == -1) {
- return null;
- }
- return TypeEnum.getTypeEnum(prop, enumValue).getName();
- }
-
-
-
-
- /** Get a named <code>int</code> value from the current style
- *
- * @param part a <code>Part</code>
- * @return an <code>int</code> or null if key is not found
- * in the current style
- */
- int getInt(Component c, Part part, State state, Prop prop, int fallback) {
- return ThemeReader.getInt(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- }
-
- /** Get a named <code>Dimension</code> value from the current style
- *
- * @return a <code>Dimension</code> or null if key is not found
- * in the current style
- *
- * This is currently only used by WindowsProgressBarUI and the value
- * should probably be cached there instead of here.
- */
- Dimension getDimension(Component c, Part part, State state, Prop prop) {
- Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- return (d != null) ? d : new Dimension();
- }
-
- /** Get a named <code>Point</code> (e.g. a location or an offset) value
- * from the current style
- *
- * @return a <code>Point</code> or null if key is not found
- * in the current style
- *
- * This is currently only used by WindowsInternalFrameTitlePane for painting
- * title foregound and can be removed when no longer needed
- */
- Point getPoint(Component c, Part part, State state, Prop prop) {
- Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- return (d != null) ? new Point(d.width, d.height) : new Point();
- }
-
- /** Get a named <code>Insets</code> value from the current style
- *
- * @return an <code>Insets</code> object or null if key is not found
- * in the current style
- *
- * This is currently only used to create borders and by
- * WindowsInternalFrameTitlePane for painting title foregound.
- * The return value is already cached in those places.
- */
- Insets getMargin(Component c, Part part, State state, Prop prop) {
- Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- return (insets != null) ? insets : new Insets(0, 0, 0, 0);
- }
-
-
- /** Get a named <code>Color</code> value from the current style
- *
- * @return a <code>Color</code> or null if key is not found
- * in the current style
- */
- synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
- String key = skin.toString() + "." + prop.name();
- Part part = skin.part;
- Color color = colorMap.get(key);
- if (color == null) {
- color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
- State.getValue(part, skin.state),
- prop.getValue());
- if (color != null) {
- color = new ColorUIResource(color);
- colorMap.put(key, color);
- }
- }
- return (color != null) ? color : fallback;
- }
-
- Color getColor(Component c, Part part, State state, Prop prop, Color fallback) {
- return getColor(new Skin(c, part, state), prop, fallback);
- }
-
-
-
- /** Get a named <code>Border</code> value from the current style
- *
- * @param part a <code>Part</code>
- * @return a <code>Border</code> or null if key is not found
- * in the current style or if the style for the particular
- * part is not defined as "borderfill".
- */
- synchronized Border getBorder(Component c, Part part) {
- if (part == Part.MENU) {
- // Special case because XP has no skin for menus
- if (flatMenus) {
- // TODO: The classic border uses this color, but we should
- // create a new UI property called "PopupMenu.borderColor"
- // instead.
- return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"),
- 1);
- } else {
- return null; // Will cause L&F to use classic border
- }
- }
- Skin skin = new Skin(c, part, null);
- Border border = borderMap.get(skin.string);
- if (border == null) {
- String bgType = getTypeEnumName(c, part, null, Prop.BGTYPE);
- if ("borderfill".equalsIgnoreCase(bgType)) {
- int thickness = getInt(c, part, null, Prop.BORDERSIZE, 1);
- Color color = getColor(skin, Prop.BORDERCOLOR, Color.black);
- border = new XPFillBorder(color, thickness);
- if (part == Part.CP_COMBOBOX) {
- border = new XPStatefulFillBorder(color, thickness, part, Prop.BORDERCOLOR);
- }
- } else if ("imagefile".equalsIgnoreCase(bgType)) {
- Insets m = getMargin(c, part, null, Prop.SIZINGMARGINS);
- if (m != null) {
- if (getBoolean(c, part, null, Prop.BORDERONLY)) {
- border = new XPImageBorder(c, part);
- } else if (part == Part.CP_COMBOBOX) {
- border = new EmptyBorder(1, 1, 1, 1);
- } else {
- if(part == Part.TP_BUTTON) {
- border = new XPEmptyBorder(new Insets(3,3,3,3));
- } else {
- border = new XPEmptyBorder(m);
- }
- }
- }
- }
- if (border != null) {
- borderMap.put(skin.string, border);
- }
- }
- return border;
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPFillBorder extends LineBorder implements UIResource {
- XPFillBorder(Color color, int thickness) {
- super(color, thickness);
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- Insets margin = null;
- //
- // Ideally we'd have an interface defined for classes which
- // support margins (to avoid this hackery), but we've
- // decided against it for simplicity
- //
- if (c instanceof AbstractButton) {
- margin = ((AbstractButton)c).getMargin();
- } else if (c instanceof JToolBar) {
- margin = ((JToolBar)c).getMargin();
- } else if (c instanceof JTextComponent) {
- margin = ((JTextComponent)c).getMargin();
- }
- insets.top = (margin != null? margin.top : 0) + thickness;
- insets.left = (margin != null? margin.left : 0) + thickness;
- insets.bottom = (margin != null? margin.bottom : 0) + thickness;
- insets.right = (margin != null? margin.right : 0) + thickness;
-
- return insets;
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPStatefulFillBorder extends XPFillBorder {
- private final Part part;
- private final Prop prop;
- XPStatefulFillBorder(Color color, int thickness, Part part, Prop prop) {
- super(color, thickness);
- this.part = part;
- this.prop = prop;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- State state = State.NORMAL;
- // special casing for comboboxes.
- // there may be more special cases in the future
- if(c instanceof JComboBox) {
- JComboBox<?> cb = (JComboBox)c;
- // note. in the future this should be replaced with a call
- // to BasicLookAndFeel.getUIOfType()
- if(cb.getUI() instanceof WindowsComboBoxUI) {
- WindowsComboBoxUI wcb = (WindowsComboBoxUI)cb.getUI();
- state = wcb.getXPComboBoxState(cb);
- }
- }
- lineColor = getColor(c, part, state, prop, Color.black);
- super.paintBorder(c, g, x, y, width, height);
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPImageBorder extends AbstractBorder implements UIResource {
- Skin skin;
-
- XPImageBorder(Component c, Part part) {
- this.skin = getSkin(c, part);
- }
-
- public void paintBorder(Component c, Graphics g,
- int x, int y, int width, int height) {
- skin.paintSkin(g, x, y, width, height, null);
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- Insets margin = null;
- Insets borderInsets = skin.getContentMargin();
- if(borderInsets == null) {
- borderInsets = new Insets(0, 0, 0, 0);
- }
- //
- // Ideally we'd have an interface defined for classes which
- // support margins (to avoid this hackery), but we've
- // decided against it for simplicity
- //
- if (c instanceof AbstractButton) {
- margin = ((AbstractButton)c).getMargin();
- } else if (c instanceof JToolBar) {
- margin = ((JToolBar)c).getMargin();
- } else if (c instanceof JTextComponent) {
- margin = ((JTextComponent)c).getMargin();
- }
- insets.top = (margin != null? margin.top : 0) + borderInsets.top;
- insets.left = (margin != null? margin.left : 0) + borderInsets.left;
- insets.bottom = (margin != null? margin.bottom : 0) + borderInsets.bottom;
- insets.right = (margin != null? margin.right : 0) + borderInsets.right;
-
- return insets;
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- private class XPEmptyBorder extends EmptyBorder implements UIResource {
- XPEmptyBorder(Insets m) {
- super(m.top+2, m.left+2, m.bottom+2, m.right+2);
- }
-
- public Insets getBorderInsets(Component c, Insets insets) {
- insets = super.getBorderInsets(c, insets);
-
- Insets margin = null;
- if (c instanceof AbstractButton) {
- Insets m = ((AbstractButton)c).getMargin();
- // if this is a toolbar button then ignore getMargin()
- // and subtract the padding added by the constructor
- if(c.getParent() instanceof JToolBar
- && ! (c instanceof JRadioButton)
- && ! (c instanceof JCheckBox)
- && m instanceof InsetsUIResource) {
- insets.top -= 2;
- insets.left -= 2;
- insets.bottom -= 2;
- insets.right -= 2;
- } else {
- margin = m;
- }
- } else if (c instanceof JToolBar) {
- margin = ((JToolBar)c).getMargin();
- } else if (c instanceof JTextComponent) {
- margin = ((JTextComponent)c).getMargin();
- }
- if (margin != null) {
- insets.top = margin.top + 2;
- insets.left = margin.left + 2;
- insets.bottom = margin.bottom + 2;
- insets.right = margin.right + 2;
- }
- return insets;
- }
- }
- boolean isSkinDefined(Component c, Part part) {
- return (part.getValue() == 0)
- || ThemeReader.isThemePartDefined(
- part.getControlName(c), part.getValue(), 0);
- }
-
-
- /** Get a <code>Skin</code> object from the current style
- * for a named part (component type)
- *
- * @param part a <code>Part</code>
- * @return a <code>Skin</code> object
- */
- synchronized Skin getSkin(Component c, Part part) {
- assert isSkinDefined(c, part) : "part " + part + " is not defined";
- return new Skin(c, part, null);
- }
-
-
- long getThemeTransitionDuration(Component c, Part part, State stateFrom,
- State stateTo, Prop prop) {
- return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
- part.getValue(),
- State.getValue(part, stateFrom),
- State.getValue(part, stateTo),
- (prop != null) ? prop.getValue() : 0);
- }
-
-
- /** A class which encapsulates attributes for a given part
- * (component type) and which provides methods for painting backgrounds
- * and glyphs
- */
- static class Skin {
- final Component component;
- final Part part;
- final State state;
-
- private final String string;
- private Dimension size = null;
- private boolean switchStates = false;
-
- Skin(Component component, Part part) {
- this(component, part, null);
- }
-
- Skin(Part part, State state) {
- this(null, part, state);
- }
-
- Skin(Component component, Part part, State state) {
- this.component = component;
- this.part = part;
- this.state = state;
-
- String str = part.getControlName(component) +"." + part.name();
- if (state != null) {
- str += "("+state.name()+")";
- }
- string = str;
- }
-
- Insets getContentMargin() {
- /* idk: it seems margins are the same for all 'big enough'
- * bounding rectangles.
- */
- int boundingWidth = 100;
- int boundingHeight = 100;
-
- Insets insets = ThemeReader.getThemeBackgroundContentMargins(
- part.getControlName(null), part.getValue(),
- 0, boundingWidth, boundingHeight);
- return (insets != null) ? insets : new Insets(0, 0, 0, 0);
- }
-
- boolean haveToSwitchStates() {
- return switchStates;
- }
-
- void switchStates(boolean b) {
- switchStates = b;
- }
-
- private int getWidth(State state) {
- if (size == null) {
- size = getPartSize(part, state);
- }
- return (size != null) ? size.width : 0;
- }
-
- int getWidth() {
- return getWidth((state != null) ? state : State.NORMAL);
- }
-
- private int getHeight(State state) {
- if (size == null) {
- size = getPartSize(part, state);
- }
- return (size != null) ? size.height : 0;
- }
-
- int getHeight() {
- return getHeight((state != null) ? state : State.NORMAL);
- }
-
- public String toString() {
- return string;
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof Skin && ((Skin)obj).string.equals(string));
- }
-
- public int hashCode() {
- return string.hashCode();
- }
-
- /** Paint a skin at x, y.
- *
- * @param g the graphics context to use for painting
- * @param dx the destination <i>x</i> coordinate
- * @param dy the destination <i>y</i> coordinate
- * @param state which state to paint
- */
- void paintSkin(Graphics g, int dx, int dy, State state) {
- if (state == null) {
- state = this.state;
- }
- paintSkin(g, dx, dy, getWidth(state), getHeight(state), state);
- }
-
- /** Paint a skin in an area defined by a rectangle.
- *
- * @param g the graphics context to use for painting
- * @param r a <code>Rectangle</code> defining the area to fill,
- * may cause the image to be stretched or tiled
- * @param state which state to paint
- */
- void paintSkin(Graphics g, Rectangle r, State state) {
- paintSkin(g, r.x, r.y, r.width, r.height, state);
- }
-
- /** Paint a skin at a defined position and size
- * This method supports animation.
- *
- * @param g the graphics context to use for painting
- * @param dx the destination <i>x</i> coordinate
- * @param dy the destination <i>y</i> coordinate
- * @param dw the width of the area to fill, may cause
- * the image to be stretched or tiled
- * @param dh the height of the area to fill, may cause
- * the image to be stretched or tiled
- * @param state which state to paint
- */
- void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
- if (XPStyle.getXP() == null) {
- return;
- }
- if (ThemeReader.isGetThemeTransitionDurationDefined()
- && component instanceof JComponent
- && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
- component) == null) {
- AnimationController.paintSkin((JComponent) component, this,
- g, dx, dy, dw, dh, state);
- } else {
- paintSkinRaw(g, dx, dy, dw, dh, state);
- }
- }
-
- /** Paint a skin at a defined position and size. This method
- * does not trigger animation. It is needed for the animation
- * support.
- *
- * @param g the graphics context to use for painting
- * @param dx the destination <i>x</i> coordinate.
- * @param dy the destination <i>y</i> coordinate.
- * @param dw the width of the area to fill, may cause
- * the image to be stretched or tiled
- * @param dh the height of the area to fill, may cause
- * the image to be stretched or tiled
- * @param state which state to paint
- */
- void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) {
- if (XPStyle.getXP() == null) {
- return;
- }
- skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
- }
-
- /** Paint a skin at a defined position and size
- *
- * @param g the graphics context to use for painting
- * @param dx the destination <i>x</i> coordinate
- * @param dy the destination <i>y</i> coordinate
- * @param dw the width of the area to fill, may cause
- * the image to be stretched or tiled
- * @param dh the height of the area to fill, may cause
- * the image to be stretched or tiled
- * @param state which state to paint
- * @param borderFill should test if the component uses a border fill
- and skip painting if it is
- */
- void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
- boolean borderFill) {
- if (XPStyle.getXP() == null) {
- return;
- }
- if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
- state, Prop.BGTYPE))) {
- return;
- }
- skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
- }
- }
-
- private static class SkinPainter extends CachedPainter {
- SkinPainter() {
- super(30);
- flush();
- }
-
- public void flush() {
- super.flush();
- }
-
- protected void paintToImage(Component c, Image image, Graphics g,
- int w, int h, Object[] args) {
- Skin skin = (Skin)args[0];
- Part part = skin.part;
- State state = (State)args[1];
- if (state == null) {
- state = skin.state;
- }
- if (c == null) {
- c = skin.component;
- }
- BufferedImage bi = (BufferedImage)image;
- w = bi.getWidth();
- h = bi.getHeight();
-
- WritableRaster raster = bi.getRaster();
- DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
- // Note that stealData() requires a markDirty() afterwards
- // since we modify the data in it.
- ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
- part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- 0, 0, w, h, w);
- SunWritableRaster.markDirty(dbi);
- }
-
- protected Image createImage(Component c, int w, int h,
- GraphicsConfiguration config, Object[] args) {
- return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- }
- }
-
- @SuppressWarnings("serial") // Superclass is not serializable across versions
- static class GlyphButton extends JButton {
- protected Skin skin;
-
- public GlyphButton(Component parent, Part part) {
- XPStyle xp = getXP();
- skin = xp != null ? xp.getSkin(parent, part) : null;
- setBorder(null);
- setContentAreaFilled(false);
- setMinimumSize(new Dimension(5, 5));
- setPreferredSize(new Dimension(16, 16));
- setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
- }
-
- @SuppressWarnings("deprecation")
- public boolean isFocusTraversable() {
- return false;
- }
-
- protected State getState() {
- State state = State.NORMAL;
- if (!isEnabled()) {
- state = State.DISABLED;
- } else if (getModel().isPressed()) {
- state = State.PRESSED;
- } else if (getModel().isRollover()) {
- state = State.HOT;
- }
- return state;
- }
-
- public void paintComponent(Graphics g) {
- if (XPStyle.getXP() == null || skin == null) {
- return;
- }
- Dimension d = getSize();
- skin.paintSkin(g, 0, 0, d.width, d.height, getState());
- }
-
- public void setPart(Component parent, Part part) {
- XPStyle xp = getXP();
- skin = xp != null ? xp.getSkin(parent, part) : null;
- revalidate();
- repaint();
- }
-
- protected void paintBorder(Graphics g) {
- }
-
-
- }
-
- // Private constructor
- private XPStyle() {
- flatMenus = getSysBoolean(Prop.FLATMENUS);
-
- colorMap = new HashMap<String, Color>();
- borderMap = new HashMap<String, Border>();
- // Note: All further access to the maps must be synchronized
- }
-
-
- private boolean getBoolean(Component c, Part part, State state, Prop prop) {
- return ThemeReader.getBoolean(part.getControlName(c), part.getValue(),
- State.getValue(part, state),
- prop.getValue());
- }
-
-
-
- static Dimension getPartSize(Part part, State state) {
- return ThemeReader.getPartSize(part.getControlName(null), part.getValue(),
- State.getValue(part, state));
- }
-
- private static boolean getSysBoolean(Prop prop) {
- // We can use any widget name here, I guess.
- return ThemeReader.getSysBoolean("window", prop.getValue());
- }
-}
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Computer.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/DetailsView.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Directory.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Error.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/File.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/FloppyDrive.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/HardDrive.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/HomeFolder.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Inform.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/JavaCup32.png has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/ListView.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/NewFolder.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Question.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeClosed.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeLeaf.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeOpen.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/UpFolder.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Warn.gif has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/image-delayed.png has changed
Binary file src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/image-failed.png has changed
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Look &in:
-FileChooser.saveInLabel.textAndMnemonic=Save in:
-FileChooser.fileNameLabel.textAndMnemonic=File &name:
-FileChooser.folderNameLabel.textAndMnemonic=Folder &name:
-FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &type:
-FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
-FileChooser.upFolderAccessibleName=Up
-FileChooser.homeFolderToolTip.textAndMnemonic=Home
-FileChooser.homeFolderAccessibleName=Home
-FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
-FileChooser.newFolderAccessibleName=New Folder
-FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
-FileChooser.listViewButtonToolTip.textAndMnemonic=List
-FileChooser.listViewButtonAccessibleName=List
-FileChooser.listViewActionLabel.textAndMnemonic=List
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
-FileChooser.detailsViewButtonAccessibleName=Details
-FileChooser.viewMenuButtonToolTipText = View Menu
-FileChooser.viewMenuButtonAccessibleName = View Menu
-FileChooser.detailsViewActionLabel.textAndMnemonic=Details
-FileChooser.refreshActionLabel.textAndMnemonic=Refresh
-FileChooser.viewMenuLabel.textAndMnemonic=View
-FileChooser.fileNameHeader.textAndMnemonic=Name
-FileChooser.fileSizeHeader.textAndMnemonic=Size
-FileChooser.fileTypeHeader.textAndMnemonic=Type
-FileChooser.fileDateHeader.textAndMnemonic=Modified
-FileChooser.fileAttrHeader.textAndMnemonic=Attributes
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_de.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Suchen &in:
-FileChooser.saveInLabel.textAndMnemonic=Speichern in:
-FileChooser.fileNameLabel.textAndMnemonic=&Dateiname:
-FileChooser.folderNameLabel.textAndMnemonic=Ordner&name:
-FileChooser.filesOfTypeLabel.textAndMnemonic=Datei&typ:
-FileChooser.upFolderToolTip.textAndMnemonic=Eine Ebene h\u00F6her
-FileChooser.upFolderAccessibleName=Nach oben
-FileChooser.homeFolderToolTip.textAndMnemonic=Home
-FileChooser.homeFolderAccessibleName=Home
-FileChooser.newFolderToolTip.textAndMnemonic=Neuen Ordner erstellen
-FileChooser.newFolderAccessibleName=Neuer Ordner
-FileChooser.newFolderActionLabel.textAndMnemonic=Neuer Ordner
-FileChooser.listViewButtonToolTip.textAndMnemonic=Liste
-FileChooser.listViewButtonAccessibleName=Liste
-FileChooser.listViewActionLabel.textAndMnemonic=Liste
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
-FileChooser.detailsViewButtonAccessibleName=Details
-FileChooser.viewMenuButtonToolTipText = Ansichtsmen\u00FC
-FileChooser.viewMenuButtonAccessibleName = Ansichtsmen\u00FC
-FileChooser.detailsViewActionLabel.textAndMnemonic=Details
-FileChooser.refreshActionLabel.textAndMnemonic=Aktualisieren
-FileChooser.viewMenuLabel.textAndMnemonic=Ansicht
-FileChooser.fileNameHeader.textAndMnemonic=Name
-FileChooser.fileSizeHeader.textAndMnemonic=Gr\u00F6\u00DFe
-FileChooser.fileTypeHeader.textAndMnemonic=Typ
-FileChooser.fileDateHeader.textAndMnemonic=Ge\u00E4ndert
-FileChooser.fileAttrHeader.textAndMnemonic=Attribute
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_es.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=&Buscar en:
-FileChooser.saveInLabel.textAndMnemonic=Guardar en:
-FileChooser.fileNameLabel.textAndMnemonic=&Nombre de archivo:
-FileChooser.folderNameLabel.textAndMnemonic=&Nombre de carpeta:
-FileChooser.filesOfTypeLabel.textAndMnemonic=Archivos de &tipo:
-FileChooser.upFolderToolTip.textAndMnemonic=Subir un Nivel
-FileChooser.upFolderAccessibleName=Arriba
-FileChooser.homeFolderToolTip.textAndMnemonic=Inicio
-FileChooser.homeFolderAccessibleName=Inicio
-FileChooser.newFolderToolTip.textAndMnemonic=Crear Nueva Carpeta
-FileChooser.newFolderAccessibleName=Nueva Carpeta
-FileChooser.newFolderActionLabel.textAndMnemonic=Nueva Carpeta
-FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
-FileChooser.listViewButtonAccessibleName=Lista
-FileChooser.listViewActionLabel.textAndMnemonic=Lista
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detalles
-FileChooser.detailsViewButtonAccessibleName=Detalles
-FileChooser.viewMenuButtonToolTipText = Men\u00FA Ver
-FileChooser.viewMenuButtonAccessibleName = Men\u00FA Ver
-FileChooser.detailsViewActionLabel.textAndMnemonic=Detalles
-FileChooser.refreshActionLabel.textAndMnemonic=Refrescar
-FileChooser.viewMenuLabel.textAndMnemonic=Ver
-FileChooser.fileNameHeader.textAndMnemonic=Nombre
-FileChooser.fileSizeHeader.textAndMnemonic=Tama\u00F1o
-FileChooser.fileTypeHeader.textAndMnemonic=Tipo
-FileChooser.fileDateHeader.textAndMnemonic=Modificado
-FileChooser.fileAttrHeader.textAndMnemonic=Atributos
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_fr.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Rechercher &dans :
-FileChooser.saveInLabel.textAndMnemonic=Enregistrer dans :
-FileChooser.fileNameLabel.textAndMnemonic=&Nom du fichier :
-FileChooser.folderNameLabel.textAndMnemonic=&Nom du dossier :
-FileChooser.filesOfTypeLabel.textAndMnemonic=&Type de fichier :
-FileChooser.upFolderToolTip.textAndMnemonic=Remonte d'un niveau.
-FileChooser.upFolderAccessibleName=Monter
-FileChooser.homeFolderToolTip.textAndMnemonic=R\u00E9pertoire de base
-FileChooser.homeFolderAccessibleName=R\u00E9pertoire de base
-FileChooser.newFolderToolTip.textAndMnemonic=Cr\u00E9e un dossier.
-FileChooser.newFolderAccessibleName=Nouveau dossier
-FileChooser.newFolderActionLabel.textAndMnemonic=Nouveau dossier
-FileChooser.listViewButtonToolTip.textAndMnemonic=Liste
-FileChooser.listViewButtonAccessibleName=Liste
-FileChooser.listViewActionLabel.textAndMnemonic=Liste
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=D\u00E9tails
-FileChooser.detailsViewButtonAccessibleName=D\u00E9tails
-FileChooser.viewMenuButtonToolTipText = Menu Affichage
-FileChooser.viewMenuButtonAccessibleName = Menu Affichage
-FileChooser.detailsViewActionLabel.textAndMnemonic=D\u00E9tails
-FileChooser.refreshActionLabel.textAndMnemonic=Actualiser
-FileChooser.viewMenuLabel.textAndMnemonic=Affichage
-FileChooser.fileNameHeader.textAndMnemonic=Nom
-FileChooser.fileSizeHeader.textAndMnemonic=Taille
-FileChooser.fileTypeHeader.textAndMnemonic=Type
-FileChooser.fileDateHeader.textAndMnemonic=Modifi\u00E9
-FileChooser.fileAttrHeader.textAndMnemonic=Attributs
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_it.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Cerca &in:
-FileChooser.saveInLabel.textAndMnemonic=Salva in:
-FileChooser.fileNameLabel.textAndMnemonic=&Nome file:
-FileChooser.folderNameLabel.textAndMnemonic=&Nome cartella:
-FileChooser.filesOfTypeLabel.textAndMnemonic=&Tipo file:
-FileChooser.upFolderToolTip.textAndMnemonic=Cartella superiore
-FileChooser.upFolderAccessibleName=Superiore
-FileChooser.homeFolderToolTip.textAndMnemonic=Home
-FileChooser.homeFolderAccessibleName=Home
-FileChooser.newFolderToolTip.textAndMnemonic=Crea nuova cartella
-FileChooser.newFolderAccessibleName=Nuova cartella
-FileChooser.newFolderActionLabel.textAndMnemonic=Nuova cartella
-FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
-FileChooser.listViewButtonAccessibleName=Lista
-FileChooser.listViewActionLabel.textAndMnemonic=Lista
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Dettagli
-FileChooser.detailsViewButtonAccessibleName=Dettagli
-FileChooser.viewMenuButtonToolTipText = Visualizza menu
-FileChooser.viewMenuButtonAccessibleName = Visualizza menu
-FileChooser.detailsViewActionLabel.textAndMnemonic=Dettagli
-FileChooser.refreshActionLabel.textAndMnemonic=Aggiorna
-FileChooser.viewMenuLabel.textAndMnemonic=Visualizza
-FileChooser.fileNameHeader.textAndMnemonic=Nome
-FileChooser.fileSizeHeader.textAndMnemonic=Dimensioni
-FileChooser.fileTypeHeader.textAndMnemonic=Tipo
-FileChooser.fileDateHeader.textAndMnemonic=Modificato
-FileChooser.fileAttrHeader.textAndMnemonic=Attributi
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ja.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240(&I):
-FileChooser.saveInLabel.textAndMnemonic=\u4FDD\u5B58:
-FileChooser.fileNameLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u540D(&N):
-FileChooser.folderNameLabel.textAndMnemonic=\u30D5\u30A9\u30EB\u30C0\u540D(&N):
-FileChooser.filesOfTypeLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u30BF\u30A4\u30D7(&T):
-FileChooser.upFolderToolTip.textAndMnemonic=1\u30EC\u30D9\u30EB\u4E0A\u3078
-FileChooser.upFolderAccessibleName=\u4E0A\u3078
-FileChooser.homeFolderToolTip.textAndMnemonic=\u30DB\u30FC\u30E0
-FileChooser.homeFolderAccessibleName=\u30DB\u30FC\u30E0
-FileChooser.newFolderToolTip.textAndMnemonic=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0\u306E\u4F5C\u6210
-FileChooser.newFolderAccessibleName=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0
-FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0
-FileChooser.listViewButtonToolTip.textAndMnemonic=\u30EA\u30B9\u30C8
-FileChooser.listViewButtonAccessibleName=\u30EA\u30B9\u30C8
-FileChooser.listViewActionLabel.textAndMnemonic=\u30EA\u30B9\u30C8
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8A73\u7D30
-FileChooser.detailsViewButtonAccessibleName=\u8A73\u7D30
-FileChooser.viewMenuButtonToolTipText = \u8868\u793A\u30E1\u30CB\u30E5\u30FC
-FileChooser.viewMenuButtonAccessibleName = \u8868\u793A\u30E1\u30CB\u30E5\u30FC
-FileChooser.detailsViewActionLabel.textAndMnemonic=\u8A73\u7D30
-FileChooser.refreshActionLabel.textAndMnemonic=\u30EA\u30D5\u30EC\u30C3\u30B7\u30E5
-FileChooser.viewMenuLabel.textAndMnemonic=\u8868\u793A
-FileChooser.fileNameHeader.textAndMnemonic=\u540D\u524D
-FileChooser.fileSizeHeader.textAndMnemonic=\u30B5\u30A4\u30BA
-FileChooser.fileTypeHeader.textAndMnemonic=\u30BF\u30A4\u30D7
-FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6B63\u65E5
-FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=\uCC3E\uB294 \uC704\uCE58(&I):
-FileChooser.saveInLabel.textAndMnemonic=\uC800\uC7A5 \uC704\uCE58:
-FileChooser.fileNameLabel.textAndMnemonic=\uD30C\uC77C \uC774\uB984(&N):
-FileChooser.folderNameLabel.textAndMnemonic=\uD3F4\uB354 \uC774\uB984(&N):
-FileChooser.filesOfTypeLabel.textAndMnemonic=\uD30C\uC77C \uC720\uD615(&T):
-FileChooser.upFolderToolTip.textAndMnemonic=\uD55C \uB808\uBCA8 \uC704\uB85C
-FileChooser.upFolderAccessibleName=\uC704\uB85C
-FileChooser.homeFolderToolTip.textAndMnemonic=\uD648
-FileChooser.homeFolderAccessibleName=\uD648
-FileChooser.newFolderToolTip.textAndMnemonic=\uC0C8 \uD3F4\uB354 \uC0DD\uC131
-FileChooser.newFolderAccessibleName=\uC0C8 \uD3F4\uB354
-FileChooser.newFolderActionLabel.textAndMnemonic=\uC0C8 \uD3F4\uB354
-FileChooser.listViewButtonToolTip.textAndMnemonic=\uBAA9\uB85D
-FileChooser.listViewButtonAccessibleName=\uBAA9\uB85D
-FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
-FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274
-FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274
-FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
-FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
-FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
-FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
-FileChooser.fileTypeHeader.textAndMnemonic=\uC720\uD615
-FileChooser.fileDateHeader.textAndMnemonic=\uC218\uC815 \uB0A0\uC9DC
-FileChooser.fileAttrHeader.textAndMnemonic=\uC18D\uC131
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_pt_BR.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Pesquisar &em:
-FileChooser.saveInLabel.textAndMnemonic=Salvar em:
-FileChooser.fileNameLabel.textAndMnemonic=&Nome do arquivo:
-FileChooser.folderNameLabel.textAndMnemonic=&Nome da pasta:
-FileChooser.filesOfTypeLabel.textAndMnemonic=Arquivos do &tipo:
-FileChooser.upFolderToolTip.textAndMnemonic=Um N\u00EDvel Acima
-FileChooser.upFolderAccessibleName=Acima
-FileChooser.homeFolderToolTip.textAndMnemonic=In\u00EDcio
-FileChooser.homeFolderAccessibleName=In\u00EDcio
-FileChooser.newFolderToolTip.textAndMnemonic=Criar Nova Pasta
-FileChooser.newFolderAccessibleName=Nova Pasta
-FileChooser.newFolderActionLabel.textAndMnemonic=Nova Pasta
-FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
-FileChooser.listViewButtonAccessibleName=Lista
-FileChooser.listViewActionLabel.textAndMnemonic=Lista
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detalhes
-FileChooser.detailsViewButtonAccessibleName=Detalhes
-FileChooser.viewMenuButtonToolTipText = Exibir Menu
-FileChooser.viewMenuButtonAccessibleName = Exibir Menu
-FileChooser.detailsViewActionLabel.textAndMnemonic=Detalhes
-FileChooser.refreshActionLabel.textAndMnemonic=Atualizar
-FileChooser.viewMenuLabel.textAndMnemonic=Exibir
-FileChooser.fileNameHeader.textAndMnemonic=Nome
-FileChooser.fileSizeHeader.textAndMnemonic=Tamanho
-FileChooser.fileTypeHeader.textAndMnemonic=Tipo
-FileChooser.fileDateHeader.textAndMnemonic=Modificado
-FileChooser.fileAttrHeader.textAndMnemonic=Atributos
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_sv.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=Leta &i:
-FileChooser.saveInLabel.textAndMnemonic=Spara i:
-FileChooser.fileNameLabel.textAndMnemonic=Fil&namn:
-FileChooser.folderNameLabel.textAndMnemonic=Mapp&namn:
-FileChooser.filesOfTypeLabel.textAndMnemonic=Filer av &typen:
-FileChooser.upFolderToolTip.textAndMnemonic=Upp en niv\u00E5
-FileChooser.upFolderAccessibleName=Upp
-FileChooser.homeFolderToolTip.textAndMnemonic=Hem
-FileChooser.homeFolderAccessibleName=Hem
-FileChooser.newFolderToolTip.textAndMnemonic=Skapa ny mapp
-FileChooser.newFolderAccessibleName=Ny mapp
-FileChooser.newFolderActionLabel.textAndMnemonic=Ny mapp
-FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
-FileChooser.listViewButtonAccessibleName=Lista
-FileChooser.listViewActionLabel.textAndMnemonic=Lista
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detaljer
-FileChooser.detailsViewButtonAccessibleName=Detaljer
-FileChooser.viewMenuButtonToolTipText = Menyn Visa
-FileChooser.viewMenuButtonAccessibleName = Menyn Visa
-FileChooser.detailsViewActionLabel.textAndMnemonic=Detaljer
-FileChooser.refreshActionLabel.textAndMnemonic=F\u00F6rnya
-FileChooser.viewMenuLabel.textAndMnemonic=Vy
-FileChooser.fileNameHeader.textAndMnemonic=Namn
-FileChooser.fileSizeHeader.textAndMnemonic=Storlek
-FileChooser.fileTypeHeader.textAndMnemonic=Typ
-FileChooser.fileDateHeader.textAndMnemonic=\u00C4ndrad
-FileChooser.fileAttrHeader.textAndMnemonic=Attribut
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_CN.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=\u67E5\u627E(&I):
-FileChooser.saveInLabel.textAndMnemonic=\u4FDD\u5B58:
-FileChooser.fileNameLabel.textAndMnemonic=\u6587\u4EF6\u540D(&N):
-FileChooser.folderNameLabel.textAndMnemonic=\u6587\u4EF6\u5939\u540D(&N):
-FileChooser.filesOfTypeLabel.textAndMnemonic=\u6587\u4EF6\u7C7B\u578B(&T):
-FileChooser.upFolderToolTip.textAndMnemonic=\u5411\u4E0A\u4E00\u7EA7
-FileChooser.upFolderAccessibleName=\u5411\u4E0A
-FileChooser.homeFolderToolTip.textAndMnemonic=\u4E3B\u76EE\u5F55
-FileChooser.homeFolderAccessibleName=\u4E3B\u76EE\u5F55
-FileChooser.newFolderToolTip.textAndMnemonic=\u521B\u5EFA\u65B0\u6587\u4EF6\u5939
-FileChooser.newFolderAccessibleName=\u65B0\u5EFA\u6587\u4EF6\u5939
-FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u5EFA\u6587\u4EF6\u5939
-FileChooser.listViewButtonToolTip.textAndMnemonic=\u5217\u8868
-FileChooser.listViewButtonAccessibleName=\u5217\u8868
-FileChooser.listViewActionLabel.textAndMnemonic=\u5217\u8868
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8BE6\u7EC6\u4FE1\u606F
-FileChooser.detailsViewButtonAccessibleName=\u8BE6\u7EC6\u4FE1\u606F
-FileChooser.viewMenuButtonToolTipText = \u67E5\u770B\u83DC\u5355
-FileChooser.viewMenuButtonAccessibleName = \u67E5\u770B\u83DC\u5355
-FileChooser.detailsViewActionLabel.textAndMnemonic=\u8BE6\u7EC6\u4FE1\u606F
-FileChooser.refreshActionLabel.textAndMnemonic=\u5237\u65B0
-FileChooser.viewMenuLabel.textAndMnemonic=\u89C6\u56FE
-FileChooser.fileNameHeader.textAndMnemonic=\u540D\u79F0
-FileChooser.fileSizeHeader.textAndMnemonic=\u5927\u5C0F
-FileChooser.fileTypeHeader.textAndMnemonic=\u7C7B\u578B
-FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F
-FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_TW.properties Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# This properties file is used to create a PropertyResourceBundle
-# It contains Locale specific strings used be the Windows Look and Feel.
-# Currently, the following components need this for support:
-#
-# FileChooser
-#
-# When this file is read in, the strings are put into the
-# defaults table. This is an implementation detail of the current
-# workings of Swing. DO NOT DEPEND ON THIS.
-# This may change in future versions of Swing as we improve localization
-# support.
-#
-# Refer to the note in basic.properties for a description as to what
-# the mnemonics correspond to and how to calculate them.
-#
-# @author Steve Wilson
-
-
-############ FILE CHOOSER STRINGS #############
-
-FileChooser.lookInLabel.textAndMnemonic=\u67E5\u8A62(&I):
-FileChooser.saveInLabel.textAndMnemonic=\u5132\u5B58\u65BC:
-FileChooser.fileNameLabel.textAndMnemonic=\u6A94\u6848\u540D\u7A31(&N):
-FileChooser.folderNameLabel.textAndMnemonic=\u8CC7\u6599\u593E\u540D\u7A31(&N):
-FileChooser.filesOfTypeLabel.textAndMnemonic=\u6A94\u6848\u985E\u578B(&T):
-FileChooser.upFolderToolTip.textAndMnemonic=\u5F80\u4E0A\u4E00\u5C64
-FileChooser.upFolderAccessibleName=\u5F80\u4E0A
-FileChooser.homeFolderToolTip.textAndMnemonic=\u4E3B\u76EE\u9304
-FileChooser.homeFolderAccessibleName=\u4E3B\u76EE\u9304
-FileChooser.newFolderToolTip.textAndMnemonic=\u5EFA\u7ACB\u65B0\u8CC7\u6599\u593E
-FileChooser.newFolderAccessibleName=\u65B0\u8CC7\u6599\u593E
-FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u8CC7\u6599\u593E
-FileChooser.listViewButtonToolTip.textAndMnemonic=\u6E05\u55AE
-FileChooser.listViewButtonAccessibleName=\u6E05\u55AE
-FileChooser.listViewActionLabel.textAndMnemonic=\u6E05\u55AE
-FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8A73\u7D30\u8CC7\u8A0A
-FileChooser.detailsViewButtonAccessibleName=\u8A73\u7D30\u8CC7\u8A0A
-FileChooser.viewMenuButtonToolTipText = \u6AA2\u8996\u529F\u80FD\u8868
-FileChooser.viewMenuButtonAccessibleName = \u6AA2\u8996\u529F\u80FD\u8868
-FileChooser.detailsViewActionLabel.textAndMnemonic=\u8A73\u7D30\u8CC7\u8A0A
-FileChooser.refreshActionLabel.textAndMnemonic=\u91CD\u65B0\u6574\u7406
-FileChooser.viewMenuLabel.textAndMnemonic=\u6AA2\u8996
-FileChooser.fileNameHeader.textAndMnemonic=\u540D\u7A31
-FileChooser.fileSizeHeader.textAndMnemonic=\u5927\u5C0F
-FileChooser.fileTypeHeader.textAndMnemonic=\u985E\u578B
-FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F
-FileChooser.fileAttrHeader.textAndMnemonic=\u5C6C\u6027
--- a/src/java.desktop/share/classes/module-info.java Mon Dec 04 10:12:46 2017 -0800
+++ b/src/java.desktop/share/classes/module-info.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -112,8 +112,6 @@
opens javax.swing.plaf.basic to
jdk.jconsole;
- opens com.sun.java.swing.plaf.windows to
- jdk.jconsole;
uses java.awt.im.spi.InputMethodDescriptor;
uses javax.accessibility.AccessibilityProvider;
--- a/src/java.desktop/share/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.swing.plaf.windows;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.io.Serializable;
-import javax.swing.Icon;
-import javax.swing.UIManager;
-import javax.swing.plaf.UIResource;
-
-/**
- * Classic sort icons.
- *
- */
-@SuppressWarnings("serial") // JDK-implementation class
-public class ClassicSortArrowIcon implements Icon, UIResource, Serializable{
- private static final int X_OFFSET = 9;
- private boolean ascending;
-
- public ClassicSortArrowIcon(boolean ascending) {
- this.ascending = ascending;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- x += X_OFFSET;
- if (ascending) {
- g.setColor(UIManager.getColor("Table.sortIconHighlight"));
- drawSide(g, x + 3, y, -1);
-
- g.setColor(UIManager.getColor("Table.sortIconLight"));
- drawSide(g, x + 4, y, 1);
-
- g.fillRect(x + 1, y + 6, 6, 1);
- }
- else {
- g.setColor(UIManager.getColor("Table.sortIconHighlight"));
- drawSide(g, x + 3, y + 6, -1);
- g.fillRect(x + 1, y, 6, 1);
-
- g.setColor(UIManager.getColor("Table.sortIconLight"));
- drawSide(g, x + 4, y + 6, 1);
- }
- }
-
- private void drawSide(Graphics g, int x, int y, int xIncrement) {
- int yIncrement = 2;
- if (ascending) {
- g.fillRect(x, y, 1, 2);
- y++;
- }
- else {
- g.fillRect(x, --y, 1, 2);
- yIncrement = -2;
- y -= 2;
- }
- x += xIncrement;
- for (int i = 0; i < 2; i++) {
- g.fillRect(x, y, 1, 3);
- x += xIncrement;
- y += yIncrement;
- }
- if (!ascending) {
- y++;
- }
- g.fillRect(x, y, 1, 2);
- }
-
- public int getIconWidth() {
- return X_OFFSET + 8;
- }
- public int getIconHeight() {
- return 9;
- }
-}
--- a/src/java.desktop/unix/classes/sun/awt/windows/ThemeReader.java Mon Dec 04 10:12:46 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt.windows;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.Point;
-
-
-/**
- * This is a stubbed out placeholder class, intended to allow building
- * WindowsLookAndFeel on Unix. This class is never actually called on
- * Unix, and will be deleted when WindowsLookAndFeel is no longer built
- * on Unix.
- *
- * @author Leif Samuelsson
- */
-public final class ThemeReader {
-
- public static boolean isThemed() {
- return false;
- }
-
- public static boolean isXPStyleEnabled() {
- return false;
- }
-
- public static void paintBackground(int[] buffer, String widget,
- int part, int state, int x, int y, int w, int h, int stride) {
- }
-
- public static Insets getThemeMargins(String widget, int part, int state, int marginType) {
- return null;
- }
-
- public static boolean isThemePartDefined(String widget, int part, int state) {
- return false;
- }
-
- public static Color getColor(String widget, int part, int state, int property) {
- return null;
- }
-
- public static int getInt(String widget, int part, int state, int property) {
- return 0;
- }
-
- public static int getEnum(String widget, int part, int state, int property) {
- return 0;
- }
-
- public static boolean getBoolean(String widget, int part, int state, int property) {
- return false;
- }
-
- public static boolean getSysBoolean(String widget, int property) {
- return false;
- }
-
- public static Point getPoint(String widget, int part, int state, int property) {
- return null;
- }
-
- public static Dimension getPosition(String widget, int part, int state, int property) {
- return null;
- }
-
- public static Dimension getPartSize(String widget, int part, int state) {
- return null;
- }
-
- public static long getThemeTransitionDuration(String widget, int part,
- int stateFrom, int stateTo, int propId) {
- return 0;
- }
-
- public static boolean isGetThemeTransitionDurationDefined() {
- return false;
- }
-
- public static Insets getThemeBackgroundContentMargins(String widget,
- int part, int state, int boundingWidth, int boundingHeight) {
- return null;
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.security.AccessController;
+import sun.security.action.GetBooleanAction;
+
+import java.util.*;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeEvent;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.Prop;
+import com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+import sun.awt.AppContext;
+
+/**
+ * A class to help mimic Vista theme animations. The only kind of
+ * animation it handles for now is 'transition' animation (this seems
+ * to be the only animation which Vista theme can do). This is when
+ * one picture fadein over another one in some period of time.
+ * According to
+ * https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=86852&SiteID=4
+ * The animations are all linear.
+ *
+ * This class has a number of responsibilities.
+ * <ul>
+ * <li> It trigger rapaint for the UI components involved in the animation
+ * <li> It tracks the animation state for every UI component involved in the
+ * animation and paints {@code Skin} in new {@code State} over the
+ * {@code Skin} in last {@code State} using
+ * {@code AlphaComposite.SrcOver.derive(alpha)} where {code alpha}
+ * depends on the state of animation
+ * </ul>
+ *
+ * @author Igor Kushnirskiy
+ */
+class AnimationController implements ActionListener, PropertyChangeListener {
+
+ private static final boolean VISTA_ANIMATION_DISABLED =
+ AccessController.doPrivileged(new GetBooleanAction("swing.disablevistaanimation"));
+
+
+ private static final Object ANIMATION_CONTROLLER_KEY =
+ new StringBuilder("ANIMATION_CONTROLLER_KEY");
+
+ private final Map<JComponent, Map<Part, AnimationState>> animationStateMap =
+ new WeakHashMap<JComponent, Map<Part, AnimationState>>();
+
+ //this timer is used to cause repaint on animated components
+ //30 repaints per second should give smooth animation affect
+ private final javax.swing.Timer timer =
+ new javax.swing.Timer(1000/30, this);
+
+ private static synchronized AnimationController getAnimationController() {
+ AppContext appContext = AppContext.getAppContext();
+ Object obj = appContext.get(ANIMATION_CONTROLLER_KEY);
+ if (obj == null) {
+ obj = new AnimationController();
+ appContext.put(ANIMATION_CONTROLLER_KEY, obj);
+ }
+ return (AnimationController) obj;
+ }
+
+ private AnimationController() {
+ timer.setRepeats(true);
+ timer.setCoalesce(true);
+ //we need to dispose the controller on l&f change
+ UIManager.addPropertyChangeListener(this);
+ }
+
+ private static void triggerAnimation(JComponent c,
+ Part part, State newState) {
+ if (c instanceof javax.swing.JTabbedPane
+ || part == Part.TP_BUTTON) {
+ //idk: we can not handle tabs animation because
+ //the same (component,part) is used to handle all the tabs
+ //and we can not track the states
+ //Vista theme might have transition duration for toolbar buttons
+ //but native application does not seem to animate them
+ return;
+ }
+ AnimationController controller =
+ AnimationController.getAnimationController();
+ State oldState = controller.getState(c, part);
+ if (oldState != newState) {
+ controller.putState(c, part, newState);
+ if (newState == State.DEFAULTED) {
+ // it seems for DEFAULTED button state Vista does animation from
+ // HOT
+ oldState = State.HOT;
+ }
+ if (oldState != null) {
+ long duration;
+ if (newState == State.DEFAULTED) {
+ //Only button might have DEFAULTED state
+ //idk: do not know how to get the value from Vista
+ //one second seems plausible value
+ duration = 1000;
+ } else {
+ XPStyle xp = XPStyle.getXP();
+ duration = (xp != null)
+ ? xp.getThemeTransitionDuration(
+ c, part,
+ normalizeState(oldState),
+ normalizeState(newState),
+ Prop.TRANSITIONDURATIONS)
+ : 1000;
+ }
+ controller.startAnimation(c, part, oldState, newState, duration);
+ }
+ }
+ }
+
+ // for scrollbar up, down, left and right button pictures are
+ // defined by states. It seems that theme has duration defined
+ // only for up button states thus we doing this translation here.
+ private static State normalizeState(State state) {
+ State rv;
+ switch (state) {
+ case DOWNPRESSED:
+ /* falls through */
+ case LEFTPRESSED:
+ /* falls through */
+ case RIGHTPRESSED:
+ rv = UPPRESSED;
+ break;
+
+ case DOWNDISABLED:
+ /* falls through */
+ case LEFTDISABLED:
+ /* falls through */
+ case RIGHTDISABLED:
+ rv = UPDISABLED;
+ break;
+
+ case DOWNHOT:
+ /* falls through */
+ case LEFTHOT:
+ /* falls through */
+ case RIGHTHOT:
+ rv = UPHOT;
+ break;
+
+ case DOWNNORMAL:
+ /* falls through */
+ case LEFTNORMAL:
+ /* falls through */
+ case RIGHTNORMAL:
+ rv = UPNORMAL;
+ break;
+
+ default :
+ rv = state;
+ break;
+ }
+ return rv;
+ }
+
+ private synchronized State getState(JComponent component, Part part) {
+ State rv = null;
+ Object tmpObject =
+ component.getClientProperty(PartUIClientPropertyKey.getKey(part));
+ if (tmpObject instanceof State) {
+ rv = (State) tmpObject;
+ }
+ return rv;
+ }
+
+ private synchronized void putState(JComponent component, Part part,
+ State state) {
+ component.putClientProperty(PartUIClientPropertyKey.getKey(part),
+ state);
+ }
+
+ private synchronized void startAnimation(JComponent component,
+ Part part,
+ State startState,
+ State endState,
+ long millis) {
+ boolean isForwardAndReverse = false;
+ if (endState == State.DEFAULTED) {
+ isForwardAndReverse = true;
+ }
+ Map<Part, AnimationState> map = animationStateMap.get(component);
+ if (millis <= 0) {
+ if (map != null) {
+ map.remove(part);
+ if (map.size() == 0) {
+ animationStateMap.remove(component);
+ }
+ }
+ return;
+ }
+ if (map == null) {
+ map = new EnumMap<Part, AnimationState>(Part.class);
+ animationStateMap.put(component, map);
+ }
+ map.put(part,
+ new AnimationState(startState, millis, isForwardAndReverse));
+ if (! timer.isRunning()) {
+ timer.start();
+ }
+ }
+
+ static void paintSkin(JComponent component, Skin skin,
+ Graphics g, int dx, int dy, int dw, int dh, State state) {
+ if (VISTA_ANIMATION_DISABLED) {
+ skin.paintSkinRaw(g, dx, dy, dw, dh, state);
+ return;
+ }
+ triggerAnimation(component, skin.part, state);
+ AnimationController controller = getAnimationController();
+ synchronized (controller) {
+ AnimationState animationState = null;
+ Map<Part, AnimationState> map =
+ controller.animationStateMap.get(component);
+ if (map != null) {
+ animationState = map.get(skin.part);
+ }
+ if (animationState != null) {
+ animationState.paintSkin(skin, g, dx, dy, dw, dh, state);
+ } else {
+ skin.paintSkinRaw(g, dx, dy, dw, dh, state);
+ }
+ }
+ }
+
+ public synchronized void propertyChange(PropertyChangeEvent e) {
+ if ("lookAndFeel" == e.getPropertyName()
+ && ! (e.getNewValue() instanceof WindowsLookAndFeel) ) {
+ dispose();
+ }
+ }
+
+ public synchronized void actionPerformed(ActionEvent e) {
+ java.util.List<JComponent> componentsToRemove = null;
+ java.util.List<Part> partsToRemove = null;
+ for (JComponent component : animationStateMap.keySet()) {
+ component.repaint();
+ if (partsToRemove != null) {
+ partsToRemove.clear();
+ }
+ Map<Part, AnimationState> map = animationStateMap.get(component);
+ if (! component.isShowing()
+ || map == null
+ || map.size() == 0) {
+ if (componentsToRemove == null) {
+ componentsToRemove = new ArrayList<JComponent>();
+ }
+ componentsToRemove.add(component);
+ continue;
+ }
+ for (Part part : map.keySet()) {
+ if (map.get(part).isDone()) {
+ if (partsToRemove == null) {
+ partsToRemove = new ArrayList<Part>();
+ }
+ partsToRemove.add(part);
+ }
+ }
+ if (partsToRemove != null) {
+ if (partsToRemove.size() == map.size()) {
+ //animation is done for the component
+ if (componentsToRemove == null) {
+ componentsToRemove = new ArrayList<JComponent>();
+ }
+ componentsToRemove.add(component);
+ } else {
+ for (Part part : partsToRemove) {
+ map.remove(part);
+ }
+ }
+ }
+ }
+ if (componentsToRemove != null) {
+ for (JComponent component : componentsToRemove) {
+ animationStateMap.remove(component);
+ }
+ }
+ if (animationStateMap.size() == 0) {
+ timer.stop();
+ }
+ }
+
+ private synchronized void dispose() {
+ timer.stop();
+ UIManager.removePropertyChangeListener(this);
+ synchronized (AnimationController.class) {
+ AppContext.getAppContext()
+ .put(ANIMATION_CONTROLLER_KEY, null);
+ }
+ }
+
+ private static class AnimationState {
+ private final State startState;
+
+ //animation duration in nanoseconds
+ private final long duration;
+
+ //animatin start time in nanoseconds
+ private long startTime;
+
+ //direction the alpha value is changing
+ //forward - from 0 to 1
+ //!forward - from 1 to 0
+ private boolean isForward = true;
+
+ //if isForwardAndReverse the animation continually goes
+ //forward and reverse. alpha value is changing from 0 to 1 then
+ //from 1 to 0 and so forth
+ private boolean isForwardAndReverse;
+
+ private float progress;
+
+ AnimationState(final State startState,
+ final long milliseconds,
+ boolean isForwardAndReverse) {
+ assert startState != null && milliseconds > 0;
+ assert SwingUtilities.isEventDispatchThread();
+
+ this.startState = startState;
+ this.duration = milliseconds * 1000000;
+ this.startTime = System.nanoTime();
+ this.isForwardAndReverse = isForwardAndReverse;
+ progress = 0f;
+ }
+ private void updateProgress() {
+ assert SwingUtilities.isEventDispatchThread();
+
+ if (isDone()) {
+ return;
+ }
+ long currentTime = System.nanoTime();
+
+ progress = ((float) (currentTime - startTime))
+ / duration;
+ progress = Math.max(progress, 0); //in case time was reset
+ if (progress >= 1) {
+ progress = 1;
+ if (isForwardAndReverse) {
+ startTime = currentTime;
+ progress = 0;
+ isForward = ! isForward;
+ }
+ }
+ }
+ void paintSkin(Skin skin, Graphics _g,
+ int dx, int dy, int dw, int dh, State state) {
+ assert SwingUtilities.isEventDispatchThread();
+
+ updateProgress();
+ if (! isDone()) {
+ Graphics2D g = (Graphics2D) _g.create();
+ if (skin.haveToSwitchStates()) {
+ skin.paintSkinRaw(g, dx, dy, dw, dh, state);
+ g.setComposite(AlphaComposite.SrcOver.derive(1 - progress));
+ skin.paintSkinRaw(g, dx, dy, dw, dh, startState);
+ } else {
+ skin.paintSkinRaw(g, dx, dy, dw, dh, startState);
+ float alpha;
+ if (isForward) {
+ alpha = progress;
+ } else {
+ alpha = 1 - progress;
+ }
+ g.setComposite(AlphaComposite.SrcOver.derive(alpha));
+ skin.paintSkinRaw(g, dx, dy, dw, dh, state);
+ }
+ g.dispose();
+ } else {
+ skin.paintSkinRaw(_g, dx, dy, dw, dh, state);
+ skin.switchStates(false);
+ }
+ }
+ boolean isDone() {
+ assert SwingUtilities.isEventDispatchThread();
+
+ return progress >= 1;
+ }
+ }
+
+ private static class PartUIClientPropertyKey
+ implements UIClientPropertyKey {
+
+ private static final Map<Part, PartUIClientPropertyKey> map =
+ new EnumMap<Part, PartUIClientPropertyKey>(Part.class);
+
+ static synchronized PartUIClientPropertyKey getKey(Part part) {
+ PartUIClientPropertyKey rv = map.get(part);
+ if (rv == null) {
+ rv = new PartUIClientPropertyKey(part);
+ map.put(part, rv);
+ }
+ return rv;
+ }
+
+ private final Part part;
+ private PartUIClientPropertyKey(Part part) {
+ this.part = part;
+ }
+ public String toString() {
+ return part.toString();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,577 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * <p>These classes are designed to be used while the
+ * corresponding <code>LookAndFeel</code> class has been installed
+ * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
+ * Using them while a different <code>LookAndFeel</code> is installed
+ * may produce unexpected results, including exceptions.
+ * Additionally, changing the <code>LookAndFeel</code>
+ * maintained by the <code>UIManager</code> without updating the
+ * corresponding <code>ComponentUI</code> of any
+ * <code>JComponent</code>s may also produce unexpected results,
+ * such as the wrong colors showing up, and is generally not
+ * encouraged.
+ *
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.util.*;
+
+import javax.swing.*;
+
+import sun.awt.windows.ThemeReader;
+
+/**
+ * Implements Windows Parts and their States and Properties for the Windows Look and Feel.
+ *
+ * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp
+ * See tmschema.h (or vssym32.h & vsstyle.h for MS Vista)
+ *
+ * @author Leif Samuelsson
+ */
+class TMSchema {
+
+ /**
+ * An enumeration of the various Windows controls (also known as
+ * components, or top-level parts)
+ */
+ public static enum Control {
+ BUTTON,
+ COMBOBOX,
+ EDIT,
+ HEADER,
+ LISTBOX,
+ LISTVIEW,
+ MENU,
+ PROGRESS,
+ REBAR,
+ SCROLLBAR,
+ SPIN,
+ TAB,
+ TOOLBAR,
+ TRACKBAR,
+ TREEVIEW,
+ WINDOW
+ }
+
+
+ /**
+ * An enumeration of the Windows compoent parts
+ */
+ public static enum Part {
+ MENU (Control.MENU, 0), // Special case, not in native
+ MP_BARBACKGROUND (Control.MENU, 7),
+ MP_BARITEM (Control.MENU, 8),
+ MP_POPUPBACKGROUND (Control.MENU, 9),
+ MP_POPUPBORDERS (Control.MENU, 10),
+ MP_POPUPCHECK (Control.MENU, 11),
+ MP_POPUPCHECKBACKGROUND (Control.MENU, 12),
+ MP_POPUPGUTTER (Control.MENU, 13),
+ MP_POPUPITEM (Control.MENU, 14),
+ MP_POPUPSEPARATOR (Control.MENU, 15),
+ MP_POPUPSUBMENU (Control.MENU, 16),
+
+ BP_PUSHBUTTON (Control.BUTTON, 1),
+ BP_RADIOBUTTON(Control.BUTTON, 2),
+ BP_CHECKBOX (Control.BUTTON, 3),
+ BP_GROUPBOX (Control.BUTTON, 4),
+
+ CP_COMBOBOX (Control.COMBOBOX, 0),
+ CP_DROPDOWNBUTTON(Control.COMBOBOX, 1),
+ CP_BACKGROUND (Control.COMBOBOX, 2),
+ CP_TRANSPARENTBACKGROUND (Control.COMBOBOX, 3),
+ CP_BORDER (Control.COMBOBOX, 4),
+ CP_READONLY (Control.COMBOBOX, 5),
+ CP_DROPDOWNBUTTONRIGHT (Control.COMBOBOX, 6),
+ CP_DROPDOWNBUTTONLEFT (Control.COMBOBOX, 7),
+ CP_CUEBANNER (Control.COMBOBOX, 8),
+
+
+ EP_EDIT (Control.EDIT, 0),
+ EP_EDITTEXT(Control.EDIT, 1),
+
+ HP_HEADERITEM(Control.HEADER, 1),
+ HP_HEADERSORTARROW(Control.HEADER, 4),
+
+ LBP_LISTBOX(Control.LISTBOX, 0),
+
+ LBCP_BORDER_HSCROLL (Control.LISTBOX, 1),
+ LBCP_BORDER_HVSCROLL (Control.LISTBOX, 2),
+ LBCP_BORDER_NOSCROLL (Control.LISTBOX, 3),
+ LBCP_BORDER_VSCROLL (Control.LISTBOX, 4),
+ LBCP_ITEM (Control.LISTBOX, 5),
+
+ LVP_LISTVIEW(Control.LISTVIEW, 0),
+
+ PP_PROGRESS (Control.PROGRESS, 0),
+ PP_BAR (Control.PROGRESS, 1),
+ PP_BARVERT (Control.PROGRESS, 2),
+ PP_CHUNK (Control.PROGRESS, 3),
+ PP_CHUNKVERT(Control.PROGRESS, 4),
+
+ RP_GRIPPER (Control.REBAR, 1),
+ RP_GRIPPERVERT(Control.REBAR, 2),
+
+ SBP_SCROLLBAR (Control.SCROLLBAR, 0),
+ SBP_ARROWBTN (Control.SCROLLBAR, 1),
+ SBP_THUMBBTNHORZ (Control.SCROLLBAR, 2),
+ SBP_THUMBBTNVERT (Control.SCROLLBAR, 3),
+ SBP_LOWERTRACKHORZ(Control.SCROLLBAR, 4),
+ SBP_UPPERTRACKHORZ(Control.SCROLLBAR, 5),
+ SBP_LOWERTRACKVERT(Control.SCROLLBAR, 6),
+ SBP_UPPERTRACKVERT(Control.SCROLLBAR, 7),
+ SBP_GRIPPERHORZ (Control.SCROLLBAR, 8),
+ SBP_GRIPPERVERT (Control.SCROLLBAR, 9),
+ SBP_SIZEBOX (Control.SCROLLBAR, 10),
+
+ SPNP_UP (Control.SPIN, 1),
+ SPNP_DOWN(Control.SPIN, 2),
+
+ TABP_TABITEM (Control.TAB, 1),
+ TABP_TABITEMLEFTEDGE (Control.TAB, 2),
+ TABP_TABITEMRIGHTEDGE(Control.TAB, 3),
+ TABP_PANE (Control.TAB, 9),
+
+ TP_TOOLBAR (Control.TOOLBAR, 0),
+ TP_BUTTON (Control.TOOLBAR, 1),
+ TP_SEPARATOR (Control.TOOLBAR, 5),
+ TP_SEPARATORVERT (Control.TOOLBAR, 6),
+
+ TKP_TRACK (Control.TRACKBAR, 1),
+ TKP_TRACKVERT (Control.TRACKBAR, 2),
+ TKP_THUMB (Control.TRACKBAR, 3),
+ TKP_THUMBBOTTOM(Control.TRACKBAR, 4),
+ TKP_THUMBTOP (Control.TRACKBAR, 5),
+ TKP_THUMBVERT (Control.TRACKBAR, 6),
+ TKP_THUMBLEFT (Control.TRACKBAR, 7),
+ TKP_THUMBRIGHT (Control.TRACKBAR, 8),
+ TKP_TICS (Control.TRACKBAR, 9),
+ TKP_TICSVERT (Control.TRACKBAR, 10),
+
+ TVP_TREEVIEW(Control.TREEVIEW, 0),
+ TVP_GLYPH (Control.TREEVIEW, 2),
+
+ WP_WINDOW (Control.WINDOW, 0),
+ WP_CAPTION (Control.WINDOW, 1),
+ WP_MINCAPTION (Control.WINDOW, 3),
+ WP_MAXCAPTION (Control.WINDOW, 5),
+ WP_FRAMELEFT (Control.WINDOW, 7),
+ WP_FRAMERIGHT (Control.WINDOW, 8),
+ WP_FRAMEBOTTOM (Control.WINDOW, 9),
+ WP_SYSBUTTON (Control.WINDOW, 13),
+ WP_MDISYSBUTTON (Control.WINDOW, 14),
+ WP_MINBUTTON (Control.WINDOW, 15),
+ WP_MDIMINBUTTON (Control.WINDOW, 16),
+ WP_MAXBUTTON (Control.WINDOW, 17),
+ WP_CLOSEBUTTON (Control.WINDOW, 18),
+ WP_MDICLOSEBUTTON (Control.WINDOW, 20),
+ WP_RESTOREBUTTON (Control.WINDOW, 21),
+ WP_MDIRESTOREBUTTON(Control.WINDOW, 22);
+
+ private final Control control;
+ private final int value;
+
+ private Part(Control control, int value) {
+ this.control = control;
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public String getControlName(Component component) {
+ String str = "";
+ if (component instanceof JComponent) {
+ JComponent c = (JComponent)component;
+ String subAppName = (String)c.getClientProperty("XPStyle.subAppName");
+ if (subAppName != null) {
+ str = subAppName + "::";
+ }
+ }
+ return str + control.toString();
+ }
+
+ public String toString() {
+ return control.toString()+"."+name();
+ }
+ }
+
+
+ /**
+ * An enumeration of the possible component states
+ */
+ public static enum State {
+ ACTIVE,
+ ASSIST,
+ BITMAP,
+ CHECKED,
+ CHECKEDDISABLED,
+ CHECKEDHOT,
+ CHECKEDNORMAL,
+ CHECKEDPRESSED,
+ CHECKMARKNORMAL,
+ CHECKMARKDISABLED,
+ BULLETNORMAL,
+ BULLETDISABLED,
+ CLOSED,
+ DEFAULTED,
+ DISABLED,
+ DISABLEDHOT,
+ DISABLEDPUSHED,
+ DOWNDISABLED,
+ DOWNHOT,
+ DOWNNORMAL,
+ DOWNPRESSED,
+ FOCUSED,
+ HOT,
+ HOTCHECKED,
+ ICONHOT,
+ ICONNORMAL,
+ ICONPRESSED,
+ ICONSORTEDHOT,
+ ICONSORTEDNORMAL,
+ ICONSORTEDPRESSED,
+ INACTIVE,
+ INACTIVENORMAL, // See note 1
+ INACTIVEHOT, // See note 1
+ INACTIVEPUSHED, // See note 1
+ INACTIVEDISABLED, // See note 1
+ LEFTDISABLED,
+ LEFTHOT,
+ LEFTNORMAL,
+ LEFTPRESSED,
+ MIXEDDISABLED,
+ MIXEDHOT,
+ MIXEDNORMAL,
+ MIXEDPRESSED,
+ NORMAL,
+ PRESSED,
+ OPENED,
+ PUSHED,
+ READONLY,
+ RIGHTDISABLED,
+ RIGHTHOT,
+ RIGHTNORMAL,
+ RIGHTPRESSED,
+ SELECTED,
+ UNCHECKEDDISABLED,
+ UNCHECKEDHOT,
+ UNCHECKEDNORMAL,
+ UNCHECKEDPRESSED,
+ UPDISABLED,
+ UPHOT,
+ UPNORMAL,
+ UPPRESSED,
+ HOVER,
+ UPHOVER,
+ DOWNHOVER,
+ LEFTHOVER,
+ RIGHTHOVER,
+ SORTEDDOWN,
+ SORTEDHOT,
+ SORTEDNORMAL,
+ SORTEDPRESSED,
+ SORTEDUP;
+
+
+ /**
+ * A map of allowed states for each Part
+ */
+ private static EnumMap<Part, State[]> stateMap;
+
+ private static synchronized void initStates() {
+ stateMap = new EnumMap<Part, State[]>(Part.class);
+
+ stateMap.put(Part.EP_EDITTEXT,
+ new State[] {
+ NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
+ });
+
+ stateMap.put(Part.BP_PUSHBUTTON,
+ new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED });
+
+ stateMap.put(Part.BP_RADIOBUTTON,
+ new State[] {
+ UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
+ CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED
+ });
+
+ stateMap.put(Part.BP_CHECKBOX,
+ new State[] {
+ UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
+ CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED,
+ MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
+ });
+
+ State[] comboBoxStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
+ stateMap.put(Part.CP_COMBOBOX, comboBoxStates);
+ stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
+ stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
+ stateMap.put(Part.CP_TRANSPARENTBACKGROUND, comboBoxStates);
+ stateMap.put(Part.CP_BORDER, comboBoxStates);
+ stateMap.put(Part.CP_READONLY, comboBoxStates);
+ stateMap.put(Part.CP_DROPDOWNBUTTONRIGHT, comboBoxStates);
+ stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates);
+ stateMap.put(Part.CP_CUEBANNER, comboBoxStates);
+
+ stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, HOT, PRESSED,
+ SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
+ ICONNORMAL, ICONHOT, ICONPRESSED,
+ ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
+
+ stateMap.put(Part.HP_HEADERSORTARROW,
+ new State[] {SORTEDDOWN, SORTEDUP});
+
+ State[] listBoxStates = new State[] { NORMAL, PRESSED, HOT, DISABLED};
+ stateMap.put(Part.LBCP_BORDER_HSCROLL, listBoxStates);
+ stateMap.put(Part.LBCP_BORDER_HVSCROLL, listBoxStates);
+ stateMap.put(Part.LBCP_BORDER_NOSCROLL, listBoxStates);
+ stateMap.put(Part.LBCP_BORDER_VSCROLL, listBoxStates);
+
+ State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER };
+ stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
+ stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates);
+ stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates);
+ stateMap.put(Part.SBP_GRIPPERVERT, scrollBarStates);
+ stateMap.put(Part.SBP_GRIPPERHORZ, scrollBarStates);
+
+ stateMap.put(Part.SBP_ARROWBTN,
+ new State[] {
+ UPNORMAL, UPHOT, UPPRESSED, UPDISABLED,
+ DOWNNORMAL, DOWNHOT, DOWNPRESSED, DOWNDISABLED,
+ LEFTNORMAL, LEFTHOT, LEFTPRESSED, LEFTDISABLED,
+ RIGHTNORMAL, RIGHTHOT, RIGHTPRESSED, RIGHTDISABLED,
+ UPHOVER, DOWNHOVER, LEFTHOVER, RIGHTHOVER
+ });
+
+
+ State[] spinnerStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
+ stateMap.put(Part.SPNP_UP, spinnerStates);
+ stateMap.put(Part.SPNP_DOWN, spinnerStates);
+
+ stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED });
+
+ State[] frameButtonStates = new State[] {
+ NORMAL, HOT, PUSHED, DISABLED, // See note 1
+ INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED,
+ };
+ // Note 1: The INACTIVE frame button states apply when the frame
+ // is inactive. They are not defined in tmschema.h
+
+ // Fix for 6316538: Vista has five frame button states
+ if (ThemeReader.getInt(Control.WINDOW.toString(),
+ Part.WP_CLOSEBUTTON.getValue(), 1,
+ Prop.IMAGECOUNT.getValue()) == 10) {
+ frameButtonStates = new State[] {
+ NORMAL, HOT, PUSHED, DISABLED, null,
+ INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
+ };
+ }
+
+ stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
+ stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
+ stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
+ stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates);
+
+ // States for Slider (trackbar)
+ stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
+ stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL });
+
+ State[] sliderThumbStates =
+ new State[] { NORMAL, HOT, PRESSED, FOCUSED, DISABLED };
+ stateMap.put(Part.TKP_THUMB, sliderThumbStates);
+ stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates);
+ stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates);
+ stateMap.put(Part.TKP_THUMBVERT, sliderThumbStates);
+ stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates);
+
+ // States for Tabs
+ State[] tabStates = new State[] { NORMAL, HOT, SELECTED, DISABLED, FOCUSED };
+ stateMap.put(Part.TABP_TABITEM, tabStates);
+ stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates);
+ stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates);
+
+
+ stateMap.put(Part.TP_BUTTON,
+ new State[] {
+ NORMAL, HOT, PRESSED, DISABLED, CHECKED, HOTCHECKED
+ });
+
+ State[] frameStates = new State[] { ACTIVE, INACTIVE };
+ stateMap.put(Part.WP_WINDOW, frameStates);
+ stateMap.put(Part.WP_FRAMELEFT, frameStates);
+ stateMap.put(Part.WP_FRAMERIGHT, frameStates);
+ stateMap.put(Part.WP_FRAMEBOTTOM, frameStates);
+
+ State[] captionStates = new State[] { ACTIVE, INACTIVE, DISABLED };
+ stateMap.put(Part.WP_CAPTION, captionStates);
+ stateMap.put(Part.WP_MINCAPTION, captionStates);
+ stateMap.put(Part.WP_MAXCAPTION, captionStates);
+
+ stateMap.put(Part.MP_BARBACKGROUND,
+ new State[] { ACTIVE, INACTIVE });
+ stateMap.put(Part.MP_BARITEM,
+ new State[] { NORMAL, HOT, PUSHED,
+ DISABLED, DISABLEDHOT, DISABLEDPUSHED });
+ stateMap.put(Part.MP_POPUPCHECK,
+ new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
+ BULLETNORMAL, BULLETDISABLED });
+ stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
+ new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
+ stateMap.put(Part.MP_POPUPITEM,
+ new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT });
+ stateMap.put(Part.MP_POPUPSUBMENU,
+ new State[] { NORMAL, DISABLED });
+
+ }
+
+
+ public static synchronized int getValue(Part part, State state) {
+ if (stateMap == null) {
+ initStates();
+ }
+
+ Enum<?>[] states = stateMap.get(part);
+ if (states != null) {
+ for (int i = 0; i < states.length; i++) {
+ if (state == states[i]) {
+ return i + 1;
+ }
+ }
+ }
+
+ if (state == null || state == State.NORMAL) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ }
+
+
+ /**
+ * An enumeration of the possible component attributes and the
+ * corresponding value type
+ */
+ public static enum Prop {
+ COLOR(Color.class, 204),
+ SIZE(Dimension.class, 207),
+
+ FLATMENUS(Boolean.class, 1001),
+
+ BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
+
+ IMAGECOUNT(Integer.class, 2401), // the number of state images in an imagefile
+ BORDERSIZE(Integer.class, 2403), // the size of the border line for bgtype=BorderFill
+
+ PROGRESSCHUNKSIZE(Integer.class, 2411), // size of progress control chunks
+ PROGRESSSPACESIZE(Integer.class, 2412), // size of progress control spaces
+
+ TEXTSHADOWOFFSET(Point.class, 3402), // where char shadows are drawn, relative to orig. chars
+
+ NORMALSIZE(Dimension.class, 3409), // size of dest rect that exactly source
+
+
+ SIZINGMARGINS ( Insets.class, 3601), // margins used for 9-grid sizing
+ CONTENTMARGINS(Insets.class, 3602), // margins that define where content can be placed
+ CAPTIONMARGINS(Insets.class, 3603), // margins that define where caption text can be placed
+
+ BORDERCOLOR(Color.class, 3801), // color of borders for BorderFill
+ FILLCOLOR ( Color.class, 3802), // color of bg fill
+ TEXTCOLOR ( Color.class, 3803), // color text is drawn in
+
+ TEXTSHADOWCOLOR(Color.class, 3818), // color of text shadow
+
+ BGTYPE(Integer.class, 4001), // basic drawing type for each part
+
+ TEXTSHADOWTYPE(Integer.class, 4010), // type of shadow to draw with text
+
+ TRANSITIONDURATIONS(Integer.class, 6000);
+
+ private final Class<?> type;
+ private final int value;
+
+ private Prop(Class<?> type, int value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public String toString() {
+ return name()+"["+type.getName()+"] = "+value;
+ }
+ }
+
+
+ /**
+ * An enumeration of attribute values for some Props
+ */
+ public static enum TypeEnum {
+ BT_IMAGEFILE (Prop.BGTYPE, "imagefile", 0),
+ BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1),
+
+ TST_NONE(Prop.TEXTSHADOWTYPE, "none", 0),
+ TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1),
+ TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2);
+
+
+ private TypeEnum(Prop prop, String enumName, int value) {
+ this.prop = prop;
+ this.enumName = enumName;
+ this.value = value;
+ }
+
+ private final Prop prop;
+ private final String enumName;
+ private final int value;
+
+ public String toString() {
+ return prop+"="+enumName+"="+value;
+ }
+
+ String getName() {
+ return enumName;
+ }
+
+
+ static TypeEnum getTypeEnum(Prop prop, int enumval) {
+ for (TypeEnum e : TypeEnum.values()) {
+ if (e.prop == prop && e.value == enumval) {
+ return e;
+ }
+ }
+ return null;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+import java.awt.Component;
+import java.awt.Insets;
+import java.awt.Color;
+import java.awt.Graphics;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+/**
+ * Factory object that can vend Borders appropriate for the Windows 95 {@literal L & F}.
+ * @author Rich Schiavi
+ */
+
+public class WindowsBorders {
+
+ /**
+ * Returns a border instance for a Windows Progress Bar
+ * @since 1.4
+ */
+ public static Border getProgressBarBorder() {
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+ Border progressBarBorder = new BorderUIResource.CompoundBorderUIResource(
+ new WindowsBorders.ProgressBarBorder(
+ table.getColor("ProgressBar.shadow"),
+ table.getColor("ProgressBar.highlight")),
+ new EmptyBorder(1,1,1,1)
+ );
+ return progressBarBorder;
+ }
+
+ /**
+ * Returns a border instance for a Windows ToolBar
+ *
+ * @return a border used for the toolbar
+ * @since 1.4
+ */
+ public static Border getToolBarBorder() {
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+ Border toolBarBorder = new WindowsBorders.ToolBarBorder(
+ table.getColor("ToolBar.shadow"),
+ table.getColor("ToolBar.highlight"));
+ return toolBarBorder;
+ }
+
+ /**
+ * Returns an new instance of a border used to indicate which cell item
+ * has focus.
+ *
+ * @return a border to indicate which cell item has focus
+ * @since 1.4
+ */
+ public static Border getFocusCellHighlightBorder() {
+ return new ComplementDashedBorder();
+ }
+
+ public static Border getTableHeaderBorder() {
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+ Border tableHeaderBorder = new BorderUIResource.CompoundBorderUIResource(
+ new BasicBorders.ButtonBorder(
+ table.getColor("Table.shadow"),
+ table.getColor("Table.darkShadow"),
+ table.getColor("Table.light"),
+ table.getColor("Table.highlight")),
+ new BasicBorders.MarginBorder());
+ return tableHeaderBorder;
+ }
+
+ public static Border getInternalFrameBorder() {
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+ Border internalFrameBorder = new
+ BorderUIResource.CompoundBorderUIResource(
+ BorderFactory.createBevelBorder(BevelBorder.RAISED,
+ table.getColor("InternalFrame.borderColor"),
+ table.getColor("InternalFrame.borderHighlight"),
+ table.getColor("InternalFrame.borderDarkShadow"),
+ table.getColor("InternalFrame.borderShadow")),
+ new WindowsBorders.InternalFrameLineBorder(
+ table.getColor("InternalFrame.activeBorderColor"),
+ table.getColor("InternalFrame.inactiveBorderColor"),
+ table.getInt("InternalFrame.borderWidth")));
+
+ return internalFrameBorder;
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public static class ProgressBarBorder extends AbstractBorder implements UIResource {
+ protected Color shadow;
+ protected Color highlight;
+
+ public ProgressBarBorder(Color shadow, Color highlight) {
+ this.highlight = highlight;
+ this.shadow = shadow;
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y,
+ int width, int height) {
+ g.setColor(shadow);
+ g.drawLine(x,y, width-1,y); // draw top
+ g.drawLine(x,y, x,height-1); // draw left
+ g.setColor(highlight);
+ g.drawLine(x,height-1, width-1,height-1); // draw bottom
+ g.drawLine(width-1,y, width-1,height-1); // draw right
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ insets.set(1,1,1,1);
+ return insets;
+ }
+ }
+
+ /**
+ * A border for the ToolBar. If the ToolBar is floatable then the handle grip is drawn
+ *
+ * @since 1.4
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
+ protected Color shadow;
+ protected Color highlight;
+
+ public ToolBarBorder(Color shadow, Color highlight) {
+ this.highlight = highlight;
+ this.shadow = shadow;
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y,
+ int width, int height) {
+ if (!(c instanceof JToolBar)) {
+ return;
+ }
+ g.translate(x, y);
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Border xpBorder = xp.getBorder(c, Part.TP_TOOLBAR);
+ if (xpBorder != null) {
+ xpBorder.paintBorder(c, g, 0, 0, width, height);
+ }
+ }
+ if (((JToolBar)c).isFloatable()) {
+ boolean vertical = ((JToolBar)c).getOrientation() == VERTICAL;
+
+ if (xp != null) {
+ Part part = vertical ? Part.RP_GRIPPERVERT : Part.RP_GRIPPER;
+ Skin skin = xp.getSkin(c, part);
+ int dx, dy, dw, dh;
+ if (vertical) {
+ dx = 0;
+ dy = 2;
+ dw = width - 1;
+ dh = skin.getHeight();
+ } else {
+ dw = skin.getWidth();
+ dh = height - 1;
+ dx = c.getComponentOrientation().isLeftToRight() ? 2 : (width-dw-2);
+ dy = 0;
+ }
+ skin.paintSkin(g, dx, dy, dw, dh, State.NORMAL);
+
+ } else {
+
+ if (!vertical) {
+ if (c.getComponentOrientation().isLeftToRight()) {
+ g.setColor(shadow);
+ g.drawLine(4, 3, 4, height - 4);
+ g.drawLine(4, height - 4, 2, height - 4);
+
+ g.setColor(highlight);
+ g.drawLine(2, 3, 3, 3);
+ g.drawLine(2, 3, 2, height - 5);
+ } else {
+ g.setColor(shadow);
+ g.drawLine(width - 3, 3, width - 3, height - 4);
+ g.drawLine(width - 4, height - 4, width - 4, height - 4);
+
+ g.setColor(highlight);
+ g.drawLine(width - 5, 3, width - 4, 3);
+ g.drawLine(width - 5, 3, width - 5, height - 5);
+ }
+ } else { // Vertical
+ g.setColor(shadow);
+ g.drawLine(3, 4, width - 4, 4);
+ g.drawLine(width - 4, 2, width - 4, 4);
+
+ g.setColor(highlight);
+ g.drawLine(3, 2, width - 4, 2);
+ g.drawLine(3, 2, 3, 3);
+ }
+ }
+ }
+
+ g.translate(-x, -y);
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ insets.set(1,1,1,1);
+ if (!(c instanceof JToolBar)) {
+ return insets;
+ }
+ if (((JToolBar)c).isFloatable()) {
+ int gripInset = (XPStyle.getXP() != null) ? 12 : 9;
+ if (((JToolBar)c).getOrientation() == HORIZONTAL) {
+ if (c.getComponentOrientation().isLeftToRight()) {
+ insets.left = gripInset;
+ } else {
+ insets.right = gripInset;
+ }
+ } else {
+ insets.top = gripInset;
+ }
+ }
+ return insets;
+ }
+ }
+
+ /**
+ * This class is an implementation of a dashed border.
+ * @since 1.4
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public static class DashedBorder extends LineBorder implements UIResource {
+ public DashedBorder(Color color) {
+ super(color);
+ }
+
+ public DashedBorder(Color color, int thickness) {
+ super(color, thickness);
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ Color oldColor = g.getColor();
+ int i;
+
+ g.setColor(lineColor);
+ for(i = 0; i < thickness; i++) {
+ BasicGraphicsUtils.drawDashedRect(g, x+i, y+i, width-i-i, height-i-i);
+ }
+ g.setColor(oldColor);
+ }
+ }
+
+ /**
+ * A dashed border that paints itself in the complementary color
+ * of the component's background color.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ static class ComplementDashedBorder extends LineBorder implements UIResource {
+ private Color origColor;
+ private Color paintColor;
+
+ public ComplementDashedBorder() {
+ super(null);
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ Color color = c.getBackground();
+
+ if (origColor != color) {
+ origColor = color;
+ paintColor = new Color(~origColor.getRGB());
+ }
+
+ g.setColor(paintColor);
+ BasicGraphicsUtils.drawDashedRect(g, x, y, width, height);
+ }
+ }
+
+ /**
+ * This class is an implementation of the InternalFrameLine border.
+ * @since 1.4
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public static class InternalFrameLineBorder extends LineBorder implements
+ UIResource {
+ protected Color activeColor;
+ protected Color inactiveColor;
+
+ public InternalFrameLineBorder(Color activeBorderColor,
+ Color inactiveBorderColor,
+ int thickness) {
+ super(activeBorderColor, thickness);
+ activeColor = activeBorderColor;
+ inactiveColor = inactiveBorderColor;
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y,
+ int width, int height) {
+
+ JInternalFrame jif = null;
+ if (c instanceof JInternalFrame) {
+ jif = (JInternalFrame)c;
+ } else if (c instanceof JInternalFrame.JDesktopIcon) {
+ jif = ((JInternalFrame.JDesktopIcon)c).getInternalFrame();
+ } else {
+ return;
+ }
+
+ if (jif.isSelected()) {
+ // Set the line color so the line border gets the correct
+ // color.
+ lineColor = activeColor;
+ super.paintBorder(c, g, x, y, width, height);
+ } else {
+ lineColor = inactiveColor;
+ super.paintBorder(c, g, x, y, width, height);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonListener.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package com.sun.java.swing.plaf.windows;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.*;
+
+/**
+ * Button Listener
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Rich Schiavi
+ */
+public class WindowsButtonListener extends BasicButtonListener {
+ public WindowsButtonListener(AbstractButton b) {
+ super(b);
+ }
+ /*
+ This class is currently not used, but exists in case customers
+ were subclassing it.
+ */
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.border.*;
+import javax.swing.plaf.*;
+import javax.swing.*;
+
+import java.awt.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.TMSchema.Part.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+import sun.awt.AppContext;
+
+
+/**
+ * Windows button.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Jeff Dinkins
+ *
+ */
+public class WindowsButtonUI extends BasicButtonUI
+{
+ protected int dashedRectGapX;
+ protected int dashedRectGapY;
+ protected int dashedRectGapWidth;
+ protected int dashedRectGapHeight;
+
+ protected Color focusColor;
+
+ private boolean defaults_initialized = false;
+
+ private static final Object WINDOWS_BUTTON_UI_KEY = new Object();
+
+ // ********************************
+ // Create PLAF
+ // ********************************
+ public static ComponentUI createUI(JComponent c) {
+ AppContext appContext = AppContext.getAppContext();
+ WindowsButtonUI windowsButtonUI =
+ (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
+ if (windowsButtonUI == null) {
+ windowsButtonUI = new WindowsButtonUI();
+ appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
+ }
+ return windowsButtonUI;
+ }
+
+
+ // ********************************
+ // Defaults
+ // ********************************
+ protected void installDefaults(AbstractButton b) {
+ super.installDefaults(b);
+ if(!defaults_initialized) {
+ String pp = getPropertyPrefix();
+ dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
+ dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
+ dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
+ dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
+ focusColor = UIManager.getColor(pp + "focus");
+ defaults_initialized = true;
+ }
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ b.setBorder(xp.getBorder(b, getXPButtonType(b)));
+ LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
+ }
+ }
+
+ protected void uninstallDefaults(AbstractButton b) {
+ super.uninstallDefaults(b);
+ defaults_initialized = false;
+ }
+
+ protected Color getFocusColor() {
+ return focusColor;
+ }
+
+ // ********************************
+ // Paint Methods
+ // ********************************
+
+ /**
+ * Overridden method to render the text without the mnemonic
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
+ WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
+ }
+
+ protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
+
+ // focus painted same color as text on Basic??
+ int width = b.getWidth();
+ int height = b.getHeight();
+ g.setColor(getFocusColor());
+ BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
+ width - dashedRectGapWidth, height - dashedRectGapHeight);
+ }
+
+ protected void paintButtonPressed(Graphics g, AbstractButton b){
+ setTextShiftOffset();
+ }
+
+ // ********************************
+ // Layout Methods
+ // ********************************
+ public Dimension getPreferredSize(JComponent c) {
+ Dimension d = super.getPreferredSize(c);
+
+ /* Ensure that the width and height of the button is odd,
+ * to allow for the focus line if focus is painted
+ */
+ AbstractButton b = (AbstractButton)c;
+ if (d != null && b.isFocusPainted()) {
+ if(d.width % 2 == 0) { d.width += 1; }
+ if(d.height % 2 == 0) { d.height += 1; }
+ }
+ return d;
+ }
+
+
+ /* These rectangles/insets are allocated once for all
+ * ButtonUI.paint() calls. Re-using rectangles rather than
+ * allocating them in each paint call substantially reduced the time
+ * it took paint to run. Obviously, this method can't be re-entered.
+ */
+ private Rectangle viewRect = new Rectangle();
+
+ public void paint(Graphics g, JComponent c) {
+ if (XPStyle.getXP() != null) {
+ WindowsButtonUI.paintXPButtonBackground(g, c);
+ }
+ super.paint(g, c);
+ }
+
+ static Part getXPButtonType(AbstractButton b) {
+ if(b instanceof JCheckBox) {
+ return Part.BP_CHECKBOX;
+ }
+ if(b instanceof JRadioButton) {
+ return Part.BP_RADIOBUTTON;
+ }
+ boolean toolbar = (b.getParent() instanceof JToolBar);
+ return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON;
+ }
+
+ static State getXPButtonState(AbstractButton b) {
+ Part part = getXPButtonType(b);
+ ButtonModel model = b.getModel();
+ State state = State.NORMAL;
+ switch (part) {
+ case BP_RADIOBUTTON:
+ /* falls through */
+ case BP_CHECKBOX:
+ if (! model.isEnabled()) {
+ state = (model.isSelected()) ? State.CHECKEDDISABLED
+ : State.UNCHECKEDDISABLED;
+ } else if (model.isPressed() && model.isArmed()) {
+ state = (model.isSelected()) ? State.CHECKEDPRESSED
+ : State.UNCHECKEDPRESSED;
+ } else if (model.isRollover()) {
+ state = (model.isSelected()) ? State.CHECKEDHOT
+ : State.UNCHECKEDHOT;
+ } else {
+ state = (model.isSelected()) ? State.CHECKEDNORMAL
+ : State.UNCHECKEDNORMAL;
+ }
+ break;
+ case BP_PUSHBUTTON:
+ /* falls through */
+ case TP_BUTTON:
+ boolean toolbar = (b.getParent() instanceof JToolBar);
+ if (toolbar) {
+ if (model.isArmed() && model.isPressed()) {
+ state = State.PRESSED;
+ } else if (!model.isEnabled()) {
+ state = State.DISABLED;
+ } else if (model.isSelected() && model.isRollover()) {
+ state = State.HOTCHECKED;
+ } else if (model.isSelected()) {
+ state = State.CHECKED;
+ } else if (model.isRollover()) {
+ state = State.HOT;
+ } else if (b.hasFocus()) {
+ state = State.HOT;
+ }
+ } else {
+ if ((model.isArmed() && model.isPressed())
+ || model.isSelected()) {
+ state = State.PRESSED;
+ } else if (!model.isEnabled()) {
+ state = State.DISABLED;
+ } else if (model.isRollover() || model.isPressed()) {
+ state = State.HOT;
+ } else if (b instanceof JButton
+ && ((JButton)b).isDefaultButton()) {
+ state = State.DEFAULTED;
+ } else if (b.hasFocus()) {
+ state = State.HOT;
+ }
+ }
+ break;
+ default :
+ state = State.NORMAL;
+ }
+
+ return state;
+ }
+
+ static void paintXPButtonBackground(Graphics g, JComponent c) {
+ AbstractButton b = (AbstractButton)c;
+
+ XPStyle xp = XPStyle.getXP();
+
+ Part part = getXPButtonType(b);
+
+ if (b.isContentAreaFilled() && b.getBorder() != null
+ && b.isBorderPainted() && xp != null) {
+
+ Skin skin = xp.getSkin(b, part);
+
+ State state = getXPButtonState(b);
+ Dimension d = c.getSize();
+ int dx = 0;
+ int dy = 0;
+ int dw = d.width;
+ int dh = d.height;
+
+ Border border = c.getBorder();
+ Insets insets;
+ if (border != null) {
+ // Note: The border may be compound, containing an outer
+ // opaque border (supplied by the application), plus an
+ // inner transparent margin border. We want to size the
+ // background to fill the transparent part, but stay
+ // inside the opaque part.
+ insets = WindowsButtonUI.getOpaqueInsets(border, c);
+ } else {
+ insets = c.getInsets();
+ }
+ if (insets != null) {
+ dx += insets.left;
+ dy += insets.top;
+ dw -= (insets.left + insets.right);
+ dh -= (insets.top + insets.bottom);
+ }
+ skin.paintSkin(g, dx, dy, dw, dh, state);
+ }
+ }
+
+ /**
+ * returns - b.getBorderInsets(c) if border is opaque
+ * - null if border is completely non-opaque
+ * - somewhere inbetween if border is compound and
+ * outside border is opaque and inside isn't
+ */
+ private static Insets getOpaqueInsets(Border b, Component c) {
+ if (b == null) {
+ return null;
+ }
+ if (b.isBorderOpaque()) {
+ return b.getBorderInsets(c);
+ } else if (b instanceof CompoundBorder) {
+ CompoundBorder cb = (CompoundBorder)b;
+ Insets iOut = getOpaqueInsets(cb.getOutsideBorder(), c);
+ if (iOut != null && iOut.equals(cb.getOutsideBorder().getBorderInsets(c))) {
+ // Outside border is opaque, keep looking
+ Insets iIn = getOpaqueInsets(cb.getInsideBorder(), c);
+ if (iIn == null) {
+ // Inside is non-opaque, use outside insets
+ return iOut;
+ } else {
+ // Found non-opaque somewhere in the inside (which is
+ // also compound).
+ return new Insets(iOut.top + iIn.top, iOut.left + iIn.left,
+ iOut.bottom + iIn.bottom, iOut.right + iIn.right);
+ }
+ } else {
+ // Outside is either all non-opaque or has non-opaque
+ // border inside another compound border
+ return iOut;
+ }
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+
+
+/**
+ * Windows check box menu item.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
+
+ final WindowsMenuItemUIAccessor accessor =
+ new WindowsMenuItemUIAccessor() {
+
+ public JMenuItem getMenuItem() {
+ return menuItem;
+ }
+
+ public State getState(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getState(this, menuItem);
+ }
+
+ public Part getPart(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getPart(this, menuItem);
+ }
+ };
+ public static ComponentUI createUI(JComponent b) {
+ return new WindowsCheckBoxMenuItemUI();
+ }
+
+ @Override
+ protected void paintBackground(Graphics g, JMenuItem menuItem,
+ Color bgColor) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
+ return;
+ }
+ super.paintBackground(g, menuItem, bgColor);
+ }
+ /**
+ * Method which renders the text of the current menu item.
+ *
+ * @param g Graphics context
+ * @param menuItem Current menu item to render
+ * @param textRect Bounding rectangle to render the text.
+ * @param text String to render
+ * @since 1.4
+ */
+ protected void paintText(Graphics g, JMenuItem menuItem,
+ Rectangle textRect, String text) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintText(accessor, g, menuItem,
+ textRect, text);
+ return;
+ }
+ ButtonModel model = menuItem.getModel();
+ Color oldColor = g.getColor();
+
+ if(model.isEnabled() && model.isArmed()) {
+ g.setColor(selectionForeground); // Uses protected field.
+ }
+
+ WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
+
+ g.setColor(oldColor);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.awt.AppContext;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+import java.awt.*;
+
+/**
+ * Windows check box.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Jeff Dinkins
+ */
+public class WindowsCheckBoxUI extends WindowsRadioButtonUI
+{
+ // NOTE: MetalCheckBoxUI inherts from MetalRadioButtonUI instead
+ // of BasicCheckBoxUI because we want to pick up all the
+ // painting changes made in MetalRadioButtonUI.
+
+ private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object();
+
+ private static final String propertyPrefix = "CheckBox" + ".";
+
+ private boolean defaults_initialized = false;
+
+ // ********************************
+ // Create PLAF
+ // ********************************
+ public static ComponentUI createUI(JComponent c) {
+ AppContext appContext = AppContext.getAppContext();
+ WindowsCheckBoxUI windowsCheckBoxUI =
+ (WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY);
+ if (windowsCheckBoxUI == null) {
+ windowsCheckBoxUI = new WindowsCheckBoxUI();
+ appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI);
+ }
+ return windowsCheckBoxUI;
+ }
+
+
+ public String getPropertyPrefix() {
+ return propertyPrefix;
+ }
+
+ // ********************************
+ // Defaults
+ // ********************************
+ public void installDefaults(AbstractButton b) {
+ super.installDefaults(b);
+ if(!defaults_initialized) {
+ icon = UIManager.getIcon(getPropertyPrefix() + "icon");
+ defaults_initialized = true;
+ }
+ }
+
+ public void uninstallDefaults(AbstractButton b) {
+ super.uninstallDefaults(b);
+ defaults_initialized = false;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+/**
+ * Implements the Windows95/98/ME/NT/2000 Look and Feel.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // Superclass is not serializable across versions
+public class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
+ public String getName() {
+ return "Windows Classic";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,665 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeEvent;
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.*;
+import javax.swing.border.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.Part;
+import static com.sun.java.swing.plaf.windows.TMSchema.State;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+import sun.swing.DefaultLookup;
+import sun.swing.StringUIClientPropertyKey;
+
+import com.sun.java.swing.plaf.windows.WindowsBorders.DashedBorder;
+
+/**
+ * Windows combo box.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Tom Santos
+ * @author Igor Kushnirskiy
+ */
+
+public class WindowsComboBoxUI extends BasicComboBoxUI {
+
+ private static final MouseListener rolloverListener =
+ new MouseAdapter() {
+ private void handleRollover(MouseEvent e, boolean isRollover) {
+ JComboBox<?> comboBox = getComboBox(e);
+ WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
+ if (comboBox == null || comboBoxUI == null) {
+ return;
+ }
+ if (! comboBox.isEditable()) {
+ //mouse over editable ComboBox does not switch rollover
+ //for the arrow button
+ ButtonModel m = null;
+ if (comboBoxUI.arrowButton != null) {
+ m = comboBoxUI.arrowButton.getModel();
+ }
+ if (m != null ) {
+ m.setRollover(isRollover);
+ }
+ }
+ comboBoxUI.isRollover = isRollover;
+ comboBox.repaint();
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ handleRollover(e, true);
+ }
+
+ public void mouseExited(MouseEvent e) {
+ handleRollover(e, false);
+ }
+
+ private JComboBox<?> getComboBox(MouseEvent event) {
+ Object source = event.getSource();
+ JComboBox<?> rv = null;
+ if (source instanceof JComboBox) {
+ rv = (JComboBox) source;
+ } else if (source instanceof XPComboBoxButton) {
+ rv = ((XPComboBoxButton) source)
+ .getWindowsComboBoxUI().comboBox;
+ } else if (source instanceof JTextField &&
+ ((JTextField) source).getParent() instanceof JComboBox) {
+ rv = (JComboBox) ((JTextField) source).getParent();
+ }
+ return rv;
+ }
+
+ private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
+ JComboBox<?> comboBox = getComboBox(event);
+ WindowsComboBoxUI rv = null;
+ if (comboBox != null
+ && comboBox.getUI() instanceof WindowsComboBoxUI) {
+ rv = (WindowsComboBoxUI) comboBox.getUI();
+ }
+ return rv;
+ }
+
+ };
+ private boolean isRollover = false;
+
+ private static final PropertyChangeListener componentOrientationListener =
+ new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ String propertyName = e.getPropertyName();
+ Object source = null;
+ if ("componentOrientation" == propertyName
+ && (source = e.getSource()) instanceof JComboBox
+ && ((JComboBox) source).getUI() instanceof
+ WindowsComboBoxUI) {
+ JComboBox<?> comboBox = (JComboBox) source;
+ WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
+ if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
+ ((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
+ (comboBox.getComponentOrientation() ==
+ ComponentOrientation.RIGHT_TO_LEFT)
+ ? Part.CP_DROPDOWNBUTTONLEFT
+ : Part.CP_DROPDOWNBUTTONRIGHT);
+ }
+ }
+ }
+ };
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsComboBoxUI();
+ }
+
+ public void installUI( JComponent c ) {
+ super.installUI( c );
+ isRollover = false;
+ comboBox.setRequestFocusEnabled( true );
+ if (XPStyle.getXP() != null && arrowButton != null) {
+ //we can not do it in installListeners because arrowButton
+ //is initialized after installListeners is invoked
+ comboBox.addMouseListener(rolloverListener);
+ arrowButton.addMouseListener(rolloverListener);
+ // set empty border as default to see vista animated border
+ comboBox.setBorder(new EmptyBorder(0,0,0,0));
+ }
+ }
+
+ public void uninstallUI(JComponent c ) {
+ comboBox.removeMouseListener(rolloverListener);
+ if(arrowButton != null) {
+ arrowButton.removeMouseListener(rolloverListener);
+ }
+ super.uninstallUI( c );
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ @Override
+ protected void installListeners() {
+ super.installListeners();
+ XPStyle xp = XPStyle.getXP();
+ //button glyph for LTR and RTL combobox might differ
+ if (xp != null
+ && xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) {
+ comboBox.addPropertyChangeListener("componentOrientation",
+ componentOrientationListener);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ @Override
+ protected void uninstallListeners() {
+ super.uninstallListeners();
+ comboBox.removePropertyChangeListener("componentOrientation",
+ componentOrientationListener);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected void configureEditor() {
+ super.configureEditor();
+ if (XPStyle.getXP() != null) {
+ editor.addMouseListener(rolloverListener);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected void unconfigureEditor() {
+ super.unconfigureEditor();
+ editor.removeMouseListener(rolloverListener);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ public void paint(Graphics g, JComponent c) {
+ if (XPStyle.getXP() != null) {
+ paintXPComboBoxBackground(g, c);
+ }
+ super.paint(g, c);
+ }
+
+ State getXPComboBoxState(JComponent c) {
+ State state = State.NORMAL;
+ if (!c.isEnabled()) {
+ state = State.DISABLED;
+ } else if (isPopupVisible(comboBox)) {
+ state = State.PRESSED;
+ } else if (comboBox.isEditable()
+ && comboBox.getEditor().getEditorComponent().isFocusOwner()) {
+ state = State.PRESSED;
+ } else if (isRollover) {
+ state = State.HOT;
+ }
+ return state;
+ }
+
+ private void paintXPComboBoxBackground(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
+ State state = getXPComboBoxState(c);
+ Skin skin = null;
+ if (! comboBox.isEditable()
+ && xp.isSkinDefined(c, Part.CP_READONLY)) {
+ skin = xp.getSkin(c, Part.CP_READONLY);
+ }
+ if (skin == null) {
+ skin = xp.getSkin(c, Part.CP_BORDER);
+ }
+ skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
+ }
+
+ /**
+ * If necessary paints the currently selected item.
+ *
+ * @param g Graphics to paint to
+ * @param bounds Region to paint current value to
+ * @param hasFocus whether or not the JComboBox has focus
+ * @throws NullPointerException if any of the arguments are null.
+ * @since 1.5
+ */
+ public void paintCurrentValue(Graphics g, Rectangle bounds,
+ boolean hasFocus) {
+ XPStyle xp = XPStyle.getXP();
+ if ( xp != null) {
+ bounds.x += 2;
+ bounds.y += 2;
+ bounds.width -= 4;
+ bounds.height -= 4;
+ } else {
+ bounds.x += 1;
+ bounds.y += 1;
+ bounds.width -= 2;
+ bounds.height -= 2;
+ }
+ if (! comboBox.isEditable()
+ && xp != null
+ && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
+ // On vista for READNLY ComboBox
+ // color for currentValue is the same as for any other item
+
+ // mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
+ ListCellRenderer<Object> renderer = comboBox.getRenderer();
+ Component c;
+ if ( hasFocus && !isPopupVisible(comboBox) ) {
+ c = renderer.getListCellRendererComponent(
+ listBox,
+ comboBox.getSelectedItem(),
+ -1,
+ true,
+ false );
+ } else {
+ c = renderer.getListCellRendererComponent(
+ listBox,
+ comboBox.getSelectedItem(),
+ -1,
+ false,
+ false );
+ }
+ c.setFont(comboBox.getFont());
+ if ( comboBox.isEnabled() ) {
+ c.setForeground(comboBox.getForeground());
+ c.setBackground(comboBox.getBackground());
+ } else {
+ c.setForeground(DefaultLookup.getColor(
+ comboBox, this, "ComboBox.disabledForeground", null));
+ c.setBackground(DefaultLookup.getColor(
+ comboBox, this, "ComboBox.disabledBackground", null));
+ }
+ boolean shouldValidate = false;
+ if (c instanceof JPanel) {
+ shouldValidate = true;
+ }
+ currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y,
+ bounds.width, bounds.height, shouldValidate);
+
+ } else {
+ super.paintCurrentValue(g, bounds, hasFocus);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ public void paintCurrentValueBackground(Graphics g, Rectangle bounds,
+ boolean hasFocus) {
+ if (XPStyle.getXP() == null) {
+ super.paintCurrentValueBackground(g, bounds, hasFocus);
+ }
+ }
+
+ public Dimension getMinimumSize( JComponent c ) {
+ Dimension d = super.getMinimumSize(c);
+ if (XPStyle.getXP() != null) {
+ d.width += 7;
+ boolean isEditable = false;
+ if (c instanceof JComboBox) {
+ isEditable = ((JComboBox) c).isEditable();
+ }
+ d.height += isEditable ? 4 : 6;
+ } else {
+ d.width += 4;
+ d.height += 2;
+ }
+ return d;
+ }
+
+ /**
+ * Creates a layout manager for managing the components which make up the
+ * combo box.
+ *
+ * @return an instance of a layout manager
+ */
+ protected LayoutManager createLayoutManager() {
+ return new BasicComboBoxUI.ComboBoxLayoutManager() {
+ public void layoutContainer(Container parent) {
+ super.layoutContainer(parent);
+
+ if (XPStyle.getXP() != null && arrowButton != null) {
+ Dimension d = parent.getSize();
+ Insets insets = getInsets();
+ int buttonWidth = arrowButton.getPreferredSize().width;
+ arrowButton.setBounds(WindowsGraphicsUtils.isLeftToRight((JComboBox)parent)
+ ? (d.width - insets.right - buttonWidth)
+ : insets.left,
+ insets.top,
+ buttonWidth, d.height - insets.top - insets.bottom);
+ }
+ }
+ };
+ }
+
+ protected void installKeyboardActions() {
+ super.installKeyboardActions();
+ }
+
+ protected ComboPopup createPopup() {
+ return new WinComboPopUp(comboBox);
+ }
+
+ /**
+ * Creates the default editor that will be used in editable combo boxes.
+ * A default editor will be used only if an editor has not been
+ * explicitly set with <code>setEditor</code>.
+ *
+ * @return a <code>ComboBoxEditor</code> used for the combo box
+ * @see javax.swing.JComboBox#setEditor
+ */
+ protected ComboBoxEditor createEditor() {
+ return new WindowsComboBoxEditor();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ @Override
+ protected ListCellRenderer<Object> createRenderer() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
+ return new WindowsComboBoxRenderer();
+ } else {
+ return super.createRenderer();
+ }
+ }
+
+ /**
+ * Creates an button which will be used as the control to show or hide
+ * the popup portion of the combo box.
+ *
+ * @return a button which represents the popup control
+ */
+ protected JButton createArrowButton() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return new XPComboBoxButton(xp);
+ } else {
+ return super.createArrowButton();
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPComboBoxButton extends XPStyle.GlyphButton {
+ private State prevState = null;
+
+ public XPComboBoxButton(XPStyle xp) {
+ super(comboBox,
+ (! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
+ ? Part.CP_DROPDOWNBUTTON
+ : (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
+ ? Part.CP_DROPDOWNBUTTONLEFT
+ : Part.CP_DROPDOWNBUTTONRIGHT
+ );
+ setRequestFocusEnabled(false);
+ }
+
+ @Override
+ protected State getState() {
+ State rv;
+
+ getModel().setPressed(comboBox.isPopupVisible());
+
+ rv = super.getState();
+ XPStyle xp = XPStyle.getXP();
+ if (rv != State.DISABLED
+ && comboBox != null && ! comboBox.isEditable()
+ && xp != null && xp.isSkinDefined(comboBox,
+ Part.CP_DROPDOWNBUTTONRIGHT)) {
+ /*
+ * for non editable ComboBoxes Vista seems to have the
+ * same glyph for all non DISABLED states
+ */
+ rv = State.NORMAL;
+ }
+ if (rv == State.NORMAL && (prevState == State.HOT || prevState == State.PRESSED)) {
+ /*
+ * State NORMAL of combobox button cannot overpaint states HOT or PRESSED
+ * Therefore HOT state must be painted from alpha 1 to 0 and not as usual that
+ * NORMAL state is painted from alpha 0 to alpha 1.
+ */
+ skin.switchStates(true);
+ }
+ if (rv != prevState) {
+ prevState = rv;
+ }
+
+ return rv;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(17, 21);
+ }
+
+ void setPart(Part part) {
+ setPart(comboBox, part);
+ }
+
+ WindowsComboBoxUI getWindowsComboBoxUI() {
+ return WindowsComboBoxUI.this;
+ }
+ }
+
+
+ /**
+ * Subclassed to add Windows specific Key Bindings.
+ * This class is now obsolete and doesn't do anything.
+ * Only included for backwards API compatibility.
+ * Do not call or override.
+ *
+ * @deprecated As of Java 2 platform v1.4.
+ */
+ @Deprecated
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ protected class WindowsComboPopup extends BasicComboPopup {
+
+ public WindowsComboPopup( JComboBox<Object> cBox ) {
+ super( cBox );
+ }
+
+ protected KeyListener createKeyListener() {
+ return new InvocationKeyHandler();
+ }
+
+ protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
+ protected InvocationKeyHandler() {
+ WindowsComboPopup.this.super();
+ }
+ }
+ }
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ protected class WinComboPopUp extends BasicComboPopup {
+ private Skin listBoxBorder = null;
+ private XPStyle xp;
+
+ public WinComboPopUp(JComboBox<Object> combo) {
+ super(combo);
+ xp = XPStyle.getXP();
+ if (xp != null && xp.isSkinDefined(combo, Part.LBCP_BORDER_NOSCROLL)) {
+ this.listBoxBorder = new Skin(combo, Part.LBCP_BORDER_NOSCROLL);
+ this.setBorder(new EmptyBorder(1,1,1,1));
+ }
+ }
+
+ protected KeyListener createKeyListener() {
+ return new InvocationKeyHandler();
+ }
+
+ protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
+ protected InvocationKeyHandler() {
+ WinComboPopUp.this.super();
+ }
+ }
+
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ if (this.listBoxBorder != null) {
+ this.listBoxBorder.paintSkinRaw(g, this.getX(), this.getY(),
+ this.getWidth(), this.getHeight(), State.HOT);
+ }
+ }
+ }
+
+
+ /**
+ * Subclassed to highlight selected item in an editable combo box.
+ */
+ public static class WindowsComboBoxEditor
+ extends BasicComboBoxEditor.UIResource {
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected JTextField createEditorComponent() {
+ JTextField editor = super.createEditorComponent();
+ Border border = (Border)UIManager.get("ComboBox.editorBorder");
+
+ if (border != null) {
+ editor.setBorder(border);
+ }
+ editor.setOpaque(false);
+ return editor;
+ }
+
+ public void setItem(Object item) {
+ super.setItem(item);
+ Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ if ((focus == editor) || (focus == editor.getParent())) {
+ editor.selectAll();
+ }
+ }
+ }
+
+ /**
+ * Subclassed to set opacity {@code false} on the renderer
+ * and to show border for focused cells.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private static class WindowsComboBoxRenderer
+ extends BasicComboBoxRenderer.UIResource {
+ private static final Object BORDER_KEY
+ = new StringUIClientPropertyKey("BORDER_KEY");
+ private static final Border NULL_BORDER = new EmptyBorder(0, 0, 0, 0);
+
+ // Create own version of DashedBorder with more space on left side
+ private class WindowsComboBoxDashedBorder extends DashedBorder {
+
+ public WindowsComboBoxDashedBorder(Color color, int thickness) {
+ super(color, thickness);
+ }
+
+ public WindowsComboBoxDashedBorder(Color color) {
+ super(color);
+ }
+
+ @Override
+ public Insets getBorderInsets(Component c, Insets i) {
+ return new Insets(0,2,0,0);
+ }
+ }
+
+ public WindowsComboBoxRenderer() {
+ super();
+
+ // correct space on the left side of text items in the combo popup list
+ Insets i = getBorder().getBorderInsets(this);
+ setBorder(new EmptyBorder(0, 2, 0, i.right));
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Component getListCellRendererComponent(
+ JList<?> list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+ Component rv =
+ super.getListCellRendererComponent(list, value, index,
+ isSelected, cellHasFocus);
+ if (rv instanceof JComponent) {
+ JComponent component = (JComponent) rv;
+ if (index == -1 && isSelected) {
+ Border border = component.getBorder();
+ Border dashedBorder =
+ new WindowsComboBoxDashedBorder(list.getForeground());
+ component.setBorder(dashedBorder);
+ //store current border in client property if needed
+ if (component.getClientProperty(BORDER_KEY) == null) {
+ component.putClientProperty(BORDER_KEY,
+ (border == null) ? NULL_BORDER : border);
+ }
+ } else {
+ if (component.getBorder() instanceof
+ WindowsBorders.DashedBorder) {
+ Object storedBorder = component.getClientProperty(BORDER_KEY);
+ if (storedBorder instanceof Border) {
+ component.setBorder(
+ (storedBorder == NULL_BORDER) ? null
+ : (Border) storedBorder);
+ }
+ component.putClientProperty(BORDER_KEY, null);
+ }
+ }
+ if (index == -1) {
+ component.setOpaque(false);
+ component.setForeground(list.getForeground());
+ } else {
+ component.setOpaque(true);
+ }
+ }
+ return rv;
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.border.*;
+
+
+
+/**
+ * Windows icon for a minimized window on the desktop.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsDesktopIconUI extends BasicDesktopIconUI {
+ private int width;
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsDesktopIconUI();
+ }
+
+ public void installDefaults() {
+ super.installDefaults();
+ width = UIManager.getInt("DesktopIcon.width");
+ }
+
+ public void installUI(JComponent c) {
+ super.installUI(c);
+
+ c.setOpaque(XPStyle.getXP() == null);
+ }
+
+ // Uninstall the listeners added by the WindowsInternalFrameTitlePane
+ public void uninstallUI(JComponent c) {
+ WindowsInternalFrameTitlePane thePane =
+ (WindowsInternalFrameTitlePane)iconPane;
+ super.uninstallUI(c);
+ thePane.uninstallListeners();
+ }
+
+ protected void installComponents() {
+ iconPane = new WindowsInternalFrameTitlePane(frame);
+ desktopIcon.setLayout(new BorderLayout());
+ desktopIcon.add(iconPane, BorderLayout.CENTER);
+
+ if (XPStyle.getXP() != null) {
+ desktopIcon.setBorder(null);
+ }
+ }
+
+ public Dimension getPreferredSize(JComponent c) {
+ // Windows desktop icons can not be resized. Therefore, we should
+ // always return the minimum size of the desktop icon. See
+ // getMinimumSize(JComponent c).
+ return getMinimumSize(c);
+ }
+
+ /**
+ * Windows desktop icons are restricted to a width of 160 pixels by
+ * default. This value is retrieved by the DesktopIcon.width property.
+ */
+ public Dimension getMinimumSize(JComponent c) {
+ Dimension dim = super.getMinimumSize(c);
+ dim.width = width;
+ return dim;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.DefaultDesktopManager;
+import javax.swing.JInternalFrame;
+import javax.swing.JLayeredPane;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.beans.PropertyVetoException;
+import java.util.Vector;
+import java.lang.ref.WeakReference;
+
+/**
+ * This class implements a DesktopManager which more closely follows
+ * the MDI model than the DefaultDesktopManager. Unlike the
+ * DefaultDesktopManager policy, MDI requires that the selected
+ * and activated child frames are the same, and that that frame
+ * always be the top-most window.
+ * <p>
+ * The maximized state is managed by the DesktopManager with MDI,
+ * instead of just being a property of the individual child frame.
+ * This means that if the currently selected window is maximized
+ * and another window is selected, that new window will be maximized.
+ *
+ * @see javax.swing.DefaultDesktopManager
+ * @author Thomas Ball
+ */
+@SuppressWarnings("serial") // JDK-implementation class
+public class WindowsDesktopManager extends DefaultDesktopManager
+ implements java.io.Serializable, javax.swing.plaf.UIResource {
+
+ /* The frame which is currently selected/activated.
+ * We store this value to enforce MDI's single-selection model.
+ */
+ private WeakReference<JInternalFrame> currentFrameRef;
+
+ public void activateFrame(JInternalFrame f) {
+ JInternalFrame currentFrame = currentFrameRef != null ?
+ currentFrameRef.get() : null;
+ try {
+ super.activateFrame(f);
+ if (currentFrame != null && f != currentFrame) {
+ // If the current frame is maximized, transfer that
+ // attribute to the frame being activated.
+ if (!currentFrame.isClosed() && currentFrame.isMaximum() &&
+ (f.getClientProperty("JInternalFrame.frameType") !=
+ "optionDialog") ) {
+ //Special case. If key binding was used to select next
+ //frame instead of minimizing the icon via the minimize
+ //icon.
+ if (!currentFrame.isIcon()) {
+ currentFrame.setMaximum(false);
+ if (f.isMaximizable()) {
+ if (!f.isMaximum()) {
+ f.setMaximum(true);
+ } else if (f.isMaximum() && f.isIcon()) {
+ f.setIcon(false);
+ } else {
+ f.setMaximum(false);
+ }
+ }
+ }
+ }
+ if (currentFrame.isSelected()) {
+ currentFrame.setSelected(false);
+ }
+ }
+
+ if (!f.isSelected()) {
+ f.setSelected(true);
+ }
+ } catch (PropertyVetoException e) {}
+ if (f != currentFrame) {
+ currentFrameRef = new WeakReference<JInternalFrame>(f);
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.ComponentUI;
+import java.awt.event.*;
+
+/**
+ * Windows desktop pane.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author David Kloba
+ */
+public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
+{
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsDesktopPaneUI();
+ }
+
+ protected void installDesktopManager() {
+ desktopManager = desktop.getDesktopManager();
+ if(desktopManager == null) {
+ desktopManager = new WindowsDesktopManager();
+ desktop.setDesktopManager(desktopManager);
+ }
+ }
+
+ protected void installDefaults() {
+ super.installDefaults();
+ }
+
+ @SuppressWarnings("deprecation")
+ protected void installKeyboardActions() {
+ super.installKeyboardActions();
+
+ // Request focus if it isn't set.
+ if(!desktop.requestDefaultFocus()) {
+ desktop.requestFocus();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopProperty.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.UIManager;
+
+import sun.swing.plaf.DesktopProperty;
+
+/**
+ * Wrapper for a value from the desktop. The value is lazily looked up, and
+ * can be accessed using the <code>UIManager.ActiveValue</code> method
+ * <code>createValue</code>. If the underlying desktop property changes this
+ * will force the UIs to update all known Frames. You can invoke
+ * <code>invalidate</code> to force the value to be fetched again.
+ */
+public class WindowsDesktopProperty extends DesktopProperty {
+
+ /**
+ * Updates the UIs of all the known Frames.
+ */
+ @Override
+ protected final void updateAllUIs() {
+ // Check if the current UI is WindowsLookAndfeel and flush the XP style map.
+ // Note: Change the package test if this class is moved to a different package.
+ Class<?> uiClass = UIManager.getLookAndFeel().getClass();
+ if (uiClass.getPackage().equals(WindowsDesktopProperty.class.getPackage())) {
+ XPStyle.invalidateStyle();
+ }
+ super.updateAllUIs();
+ }
+
+ /**
+ * Creates a WindowsDesktopProperty.
+ *
+ * @param key Key used in looking up desktop value.
+ * @param fallback Value used if desktop property is null.
+ */
+ public WindowsDesktopProperty(String key, Object fallback) {
+ super(key,fallback);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.text.Caret;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsEditorPaneUI extends BasicEditorPaneUI
+{
+
+ /**
+ * Creates a UI for a JEditorPane.
+ *
+ * @param c the configurable text component
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsEditorPaneUI();
+ }
+
+ /**
+ * Creates the object to use for a caret. By default an
+ * instance of WindowsCaret is created. This method
+ * can be redefined to provide something else that implements
+ * the InputPosition interface or a subclass of DefaultCaret.
+ *
+ * @return the caret object
+ */
+ protected Caret createCaret() {
+ return new WindowsTextUI.WindowsCaret();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,1325 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.filechooser.*;
+import javax.swing.event.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.BufferedImage;
+import java.beans.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import sun.awt.shell.ShellFolder;
+import sun.swing.*;
+
+import javax.accessibility.*;
+
+/**
+ * Windows {@literal L&F} implementation of a FileChooser.
+ *
+ * @author Jeff Dinkins
+ */
+public class WindowsFileChooserUI extends BasicFileChooserUI {
+
+ // The following are private because the implementation of the
+ // Windows FileChooser L&F is not complete yet.
+
+ private JPanel centerPanel;
+
+ private JLabel lookInLabel;
+ private JComboBox<File> directoryComboBox;
+ private DirectoryComboBoxModel directoryComboBoxModel;
+ private ActionListener directoryComboBoxAction = new DirectoryComboBoxAction();
+
+ private FilterComboBoxModel filterComboBoxModel;
+
+ private JTextField filenameTextField;
+ private FilePane filePane;
+ private WindowsPlacesBar placesBar;
+
+ private JButton approveButton;
+ private JButton cancelButton;
+
+ private JPanel buttonPanel;
+ private JPanel bottomPanel;
+
+ private JComboBox<FileFilter> filterComboBox;
+
+ private static final Dimension hstrut10 = new Dimension(10, 1);
+
+ private static final Dimension vstrut4 = new Dimension(1, 4);
+ private static final Dimension vstrut6 = new Dimension(1, 6);
+ private static final Dimension vstrut8 = new Dimension(1, 8);
+
+ private static final Insets shrinkwrap = new Insets(0,0,0,0);
+
+ // Preferred and Minimum sizes for the dialog box
+ private static int PREF_WIDTH = 425;
+ private static int PREF_HEIGHT = 245;
+ private static Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT);
+
+ private static int MIN_WIDTH = 425;
+ private static int MIN_HEIGHT = 245;
+
+ private static int LIST_PREF_WIDTH = 444;
+ private static int LIST_PREF_HEIGHT = 138;
+ private static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
+
+ // Labels, mnemonics, and tooltips (oh my!)
+ private int lookInLabelMnemonic = 0;
+ private String lookInLabelText = null;
+ private String saveInLabelText = null;
+
+ private int fileNameLabelMnemonic = 0;
+ private String fileNameLabelText = null;
+ private int folderNameLabelMnemonic = 0;
+ private String folderNameLabelText = null;
+
+ private int filesOfTypeLabelMnemonic = 0;
+ private String filesOfTypeLabelText = null;
+
+ private String upFolderToolTipText = null;
+ private String upFolderAccessibleName = null;
+
+ private String newFolderToolTipText = null;
+ private String newFolderAccessibleName = null;
+
+ private String viewMenuButtonToolTipText = null;
+ private String viewMenuButtonAccessibleName = null;
+
+ private BasicFileView fileView = new WindowsFileView();
+
+ private JLabel fileNameLabel;
+
+ private void populateFileNameLabel() {
+ if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
+ fileNameLabel.setText(folderNameLabelText);
+ fileNameLabel.setDisplayedMnemonic(folderNameLabelMnemonic);
+ } else {
+ fileNameLabel.setText(fileNameLabelText);
+ fileNameLabel.setDisplayedMnemonic(fileNameLabelMnemonic);
+ }
+ }
+
+ //
+ // ComponentUI Interface Implementation methods
+ //
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsFileChooserUI((JFileChooser) c);
+ }
+
+ public WindowsFileChooserUI(JFileChooser filechooser) {
+ super(filechooser);
+ }
+
+ public void installUI(JComponent c) {
+ super.installUI(c);
+ }
+
+ public void uninstallComponents(JFileChooser fc) {
+ fc.removeAll();
+ }
+
+ private class WindowsFileChooserUIAccessor implements FilePane.FileChooserUIAccessor {
+ public JFileChooser getFileChooser() {
+ return WindowsFileChooserUI.this.getFileChooser();
+ }
+
+ public BasicDirectoryModel getModel() {
+ return WindowsFileChooserUI.this.getModel();
+ }
+
+ public JPanel createList() {
+ return WindowsFileChooserUI.this.createList(getFileChooser());
+ }
+
+ public JPanel createDetailsView() {
+ return WindowsFileChooserUI.this.createDetailsView(getFileChooser());
+ }
+
+ public boolean isDirectorySelected() {
+ return WindowsFileChooserUI.this.isDirectorySelected();
+ }
+
+ public File getDirectory() {
+ return WindowsFileChooserUI.this.getDirectory();
+ }
+
+ public Action getChangeToParentDirectoryAction() {
+ return WindowsFileChooserUI.this.getChangeToParentDirectoryAction();
+ }
+
+ public Action getApproveSelectionAction() {
+ return WindowsFileChooserUI.this.getApproveSelectionAction();
+ }
+
+ public Action getNewFolderAction() {
+ return WindowsFileChooserUI.this.getNewFolderAction();
+ }
+
+ public MouseListener createDoubleClickListener(JList<?> list) {
+ return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(),
+ list);
+ }
+
+ public ListSelectionListener createListSelectionListener() {
+ return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
+ }
+ }
+
+ public void installComponents(JFileChooser fc) {
+ filePane = new FilePane(new WindowsFileChooserUIAccessor());
+ fc.addPropertyChangeListener(filePane);
+
+ FileSystemView fsv = fc.getFileSystemView();
+
+ fc.setBorder(new EmptyBorder(4, 10, 10, 10));
+ fc.setLayout(new BorderLayout(8, 8));
+
+ updateUseShellFolder();
+
+ // ********************************* //
+ // **** Construct the top panel **** //
+ // ********************************* //
+
+ // Directory manipulation buttons
+ JToolBar topPanel = new JToolBar();
+ topPanel.setFloatable(false);
+ topPanel.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
+
+ // Add the top panel to the fileChooser
+ fc.add(topPanel, BorderLayout.NORTH);
+
+ // ComboBox Label
+ @SuppressWarnings("serial") // anonymous class
+ JLabel tmp1 = new JLabel(lookInLabelText, JLabel.TRAILING) {
+ public Dimension getPreferredSize() {
+ return getMinimumSize();
+ }
+
+ public Dimension getMinimumSize() {
+ Dimension d = super.getPreferredSize();
+ if (placesBar != null) {
+ d.width = Math.max(d.width, placesBar.getWidth());
+ }
+ return d;
+ }
+ };
+ lookInLabel = tmp1;
+ lookInLabel.setDisplayedMnemonic(lookInLabelMnemonic);
+ lookInLabel.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ lookInLabel.setAlignmentY(JComponent.CENTER_ALIGNMENT);
+ topPanel.add(lookInLabel);
+ topPanel.add(Box.createRigidArea(new Dimension(8,0)));
+
+ // CurrentDir ComboBox
+ @SuppressWarnings("serial") // anonymous class
+ JComboBox<File> tmp2 = new JComboBox<File>() {
+ public Dimension getMinimumSize() {
+ Dimension d = super.getMinimumSize();
+ d.width = 60;
+ return d;
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension d = super.getPreferredSize();
+ // Must be small enough to not affect total width.
+ d.width = 150;
+ return d;
+ }
+ };
+ directoryComboBox = tmp2;
+ directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
+ lookInLabel.setLabelFor(directoryComboBox);
+ directoryComboBoxModel = createDirectoryComboBoxModel(fc);
+ directoryComboBox.setModel(directoryComboBoxModel);
+ directoryComboBox.addActionListener(directoryComboBoxAction);
+ directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
+ directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ directoryComboBox.setAlignmentY(JComponent.CENTER_ALIGNMENT);
+ directoryComboBox.setMaximumRowCount(8);
+
+ topPanel.add(directoryComboBox);
+ topPanel.add(Box.createRigidArea(hstrut10));
+
+ // Up Button
+ JButton upFolderButton = createToolButton(getChangeToParentDirectoryAction(), upFolderIcon,
+ upFolderToolTipText, upFolderAccessibleName);
+ topPanel.add(upFolderButton);
+
+ // New Directory Button
+ if (!UIManager.getBoolean("FileChooser.readOnly")) {
+ JButton newFolderButton = createToolButton(filePane.getNewFolderAction(), newFolderIcon,
+ newFolderToolTipText, newFolderAccessibleName);
+ topPanel.add(newFolderButton);
+ }
+
+ // View button group
+ ButtonGroup viewButtonGroup = new ButtonGroup();
+
+ // Popup Menu
+ final JPopupMenu viewTypePopupMenu = new JPopupMenu();
+
+ final JRadioButtonMenuItem listViewMenuItem = new JRadioButtonMenuItem(
+ filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
+ listViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_LIST);
+ viewTypePopupMenu.add(listViewMenuItem);
+ viewButtonGroup.add(listViewMenuItem);
+
+ final JRadioButtonMenuItem detailsViewMenuItem = new JRadioButtonMenuItem(
+ filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
+ detailsViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_DETAILS);
+ viewTypePopupMenu.add(detailsViewMenuItem);
+ viewButtonGroup.add(detailsViewMenuItem);
+
+ // Create icon for viewMenuButton
+ BufferedImage image = new BufferedImage(viewMenuIcon.getIconWidth() + 7, viewMenuIcon.getIconHeight(),
+ BufferedImage.TYPE_INT_ARGB);
+ Graphics graphics = image.getGraphics();
+ viewMenuIcon.paintIcon(filePane, graphics, 0, 0);
+ int x = image.getWidth() - 5;
+ int y = image.getHeight() / 2 - 1;
+ graphics.setColor(Color.BLACK);
+ graphics.fillPolygon(new int[]{x, x + 5, x + 2}, new int[]{y, y, y + 3}, 3);
+
+ // Details Button
+ final JButton viewMenuButton = createToolButton(null, new ImageIcon(image), viewMenuButtonToolTipText,
+ viewMenuButtonAccessibleName);
+
+ viewMenuButton.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ if (SwingUtilities.isLeftMouseButton(e) && !viewMenuButton.isSelected()) {
+ viewMenuButton.setSelected(true);
+
+ viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
+ }
+ }
+ });
+ viewMenuButton.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ // Forbid keyboard actions if the button is not in rollover state
+ if (e.getKeyCode() == KeyEvent.VK_SPACE && viewMenuButton.getModel().isRollover()) {
+ viewMenuButton.setSelected(true);
+
+ viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
+ }
+ }
+ });
+ viewTypePopupMenu.addPopupMenuListener(new PopupMenuListener() {
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ }
+
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ viewMenuButton.setSelected(false);
+ }
+ });
+ }
+
+ public void popupMenuCanceled(PopupMenuEvent e) {
+ }
+ });
+
+ topPanel.add(viewMenuButton);
+
+ topPanel.add(Box.createRigidArea(new Dimension(80, 0)));
+
+ filePane.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ if ("viewType".equals(e.getPropertyName())) {
+ switch (filePane.getViewType()) {
+ case FilePane.VIEWTYPE_LIST:
+ listViewMenuItem.setSelected(true);
+ break;
+
+ case FilePane.VIEWTYPE_DETAILS:
+ detailsViewMenuItem.setSelected(true);
+ break;
+ }
+ }
+ }
+ });
+
+ // ************************************** //
+ // ******* Add the directory pane ******* //
+ // ************************************** //
+ centerPanel = new JPanel(new BorderLayout());
+ centerPanel.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);
+ JComponent accessory = fc.getAccessory();
+ if(accessory != null) {
+ getAccessoryPanel().add(accessory);
+ }
+ filePane.setPreferredSize(LIST_PREF_SIZE);
+ centerPanel.add(filePane, BorderLayout.CENTER);
+ fc.add(centerPanel, BorderLayout.CENTER);
+
+ // ********************************** //
+ // **** Construct the bottom panel ** //
+ // ********************************** //
+ getBottomPanel().setLayout(new BoxLayout(getBottomPanel(), BoxLayout.LINE_AXIS));
+
+ // Add the bottom panel to file chooser
+ centerPanel.add(getBottomPanel(), BorderLayout.SOUTH);
+
+ // labels
+ JPanel labelPanel = new JPanel();
+ labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
+ labelPanel.add(Box.createRigidArea(vstrut4));
+
+ fileNameLabel = new JLabel();
+ populateFileNameLabel();
+ fileNameLabel.setAlignmentY(0);
+ labelPanel.add(fileNameLabel);
+
+ labelPanel.add(Box.createRigidArea(new Dimension(1,12)));
+
+ JLabel ftl = new JLabel(filesOfTypeLabelText);
+ ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
+ labelPanel.add(ftl);
+
+ getBottomPanel().add(labelPanel);
+ getBottomPanel().add(Box.createRigidArea(new Dimension(15, 0)));
+
+ // file entry and filters
+ JPanel fileAndFilterPanel = new JPanel();
+ fileAndFilterPanel.add(Box.createRigidArea(vstrut8));
+ fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));
+
+ @SuppressWarnings("serial") // anonymous class
+ JTextField tmp3 = new JTextField(35) {
+ public Dimension getMaximumSize() {
+ return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
+ }
+ };
+ filenameTextField = tmp3;
+
+ fileNameLabel.setLabelFor(filenameTextField);
+ filenameTextField.addFocusListener(
+ new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ if (!getFileChooser().isMultiSelectionEnabled()) {
+ filePane.clearSelection();
+ }
+ }
+ }
+ );
+
+ if (fc.isMultiSelectionEnabled()) {
+ setFileName(fileNameString(fc.getSelectedFiles()));
+ } else {
+ setFileName(fileNameString(fc.getSelectedFile()));
+ }
+
+ fileAndFilterPanel.add(filenameTextField);
+ fileAndFilterPanel.add(Box.createRigidArea(vstrut8));
+
+ filterComboBoxModel = createFilterComboBoxModel();
+ fc.addPropertyChangeListener(filterComboBoxModel);
+ filterComboBox = new JComboBox<FileFilter>(filterComboBoxModel);
+ ftl.setLabelFor(filterComboBox);
+ filterComboBox.setRenderer(createFilterComboBoxRenderer());
+ fileAndFilterPanel.add(filterComboBox);
+
+ getBottomPanel().add(fileAndFilterPanel);
+ getBottomPanel().add(Box.createRigidArea(new Dimension(30, 0)));
+
+ // buttons
+ getButtonPanel().setLayout(new BoxLayout(getButtonPanel(), BoxLayout.Y_AXIS));
+
+ @SuppressWarnings("serial") // anonymous class
+ JButton tmp4 = new JButton(getApproveButtonText(fc)) {
+ public Dimension getMaximumSize() {
+ return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
+ approveButton.getPreferredSize() : cancelButton.getPreferredSize();
+ }
+ };
+ approveButton = tmp4;
+ Insets buttonMargin = approveButton.getMargin();
+ buttonMargin = new InsetsUIResource(buttonMargin.top, buttonMargin.left + 5,
+ buttonMargin.bottom, buttonMargin.right + 5);
+ approveButton.setMargin(buttonMargin);
+ approveButton.setMnemonic(getApproveButtonMnemonic(fc));
+ approveButton.addActionListener(getApproveSelectionAction());
+ approveButton.setToolTipText(getApproveButtonToolTipText(fc));
+ getButtonPanel().add(Box.createRigidArea(vstrut6));
+ getButtonPanel().add(approveButton);
+ getButtonPanel().add(Box.createRigidArea(vstrut4));
+
+ @SuppressWarnings("serial") // anonymous class
+ JButton tmp5 = new JButton(cancelButtonText) {
+ public Dimension getMaximumSize() {
+ return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
+ approveButton.getPreferredSize() : cancelButton.getPreferredSize();
+ }
+ };
+ cancelButton = tmp5;
+ cancelButton.setMargin(buttonMargin);
+ cancelButton.setToolTipText(cancelButtonToolTipText);
+ cancelButton.addActionListener(getCancelSelectionAction());
+ getButtonPanel().add(cancelButton);
+
+ if(fc.getControlButtonsAreShown()) {
+ addControlButtons();
+ }
+ }
+
+ private void updateUseShellFolder() {
+ // Decide whether to use the ShellFolder class to populate shortcut
+ // panel and combobox.
+ JFileChooser fc = getFileChooser();
+
+ if (FilePane.usesShellFolder(fc)) {
+ if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
+ placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
+ fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
+ fc.addPropertyChangeListener(placesBar);
+ }
+ } else {
+ if (placesBar != null) {
+ fc.remove(placesBar);
+ fc.removePropertyChangeListener(placesBar);
+ placesBar = null;
+ }
+ }
+ }
+
+ protected JPanel getButtonPanel() {
+ if(buttonPanel == null) {
+ buttonPanel = new JPanel();
+ }
+ return buttonPanel;
+ }
+
+ protected JPanel getBottomPanel() {
+ if(bottomPanel == null) {
+ bottomPanel = new JPanel();
+ }
+ return bottomPanel;
+ }
+
+ protected void installStrings(JFileChooser fc) {
+ super.installStrings(fc);
+
+ Locale l = fc.getLocale();
+
+ lookInLabelMnemonic = getMnemonic("FileChooser.lookInLabelMnemonic", l);
+ lookInLabelText = UIManager.getString("FileChooser.lookInLabelText",l);
+ saveInLabelText = UIManager.getString("FileChooser.saveInLabelText",l);
+
+ fileNameLabelMnemonic = getMnemonic("FileChooser.fileNameLabelMnemonic", l);
+ fileNameLabelText = UIManager.getString("FileChooser.fileNameLabelText",l);
+ folderNameLabelMnemonic = getMnemonic("FileChooser.folderNameLabelMnemonic", l);
+ folderNameLabelText = UIManager.getString("FileChooser.folderNameLabelText",l);
+
+ filesOfTypeLabelMnemonic = getMnemonic("FileChooser.filesOfTypeLabelMnemonic", l);
+ filesOfTypeLabelText = UIManager.getString("FileChooser.filesOfTypeLabelText",l);
+
+ upFolderToolTipText = UIManager.getString("FileChooser.upFolderToolTipText",l);
+ upFolderAccessibleName = UIManager.getString("FileChooser.upFolderAccessibleName",l);
+
+ newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText",l);
+ newFolderAccessibleName = UIManager.getString("FileChooser.newFolderAccessibleName",l);
+
+ viewMenuButtonToolTipText = UIManager.getString("FileChooser.viewMenuButtonToolTipText",l);
+ viewMenuButtonAccessibleName = UIManager.getString("FileChooser.viewMenuButtonAccessibleName",l);
+ }
+
+ private Integer getMnemonic(String key, Locale l) {
+ return SwingUtilities2.getUIDefaultsInt(key, l);
+ }
+
+ protected void installListeners(JFileChooser fc) {
+ super.installListeners(fc);
+ ActionMap actionMap = getActionMap();
+ SwingUtilities.replaceUIActionMap(fc, actionMap);
+ }
+
+ protected ActionMap getActionMap() {
+ return createActionMap();
+ }
+
+ protected ActionMap createActionMap() {
+ ActionMap map = new ActionMapUIResource();
+ FilePane.addActionsToMap(map, filePane.getActions());
+ return map;
+ }
+
+ protected JPanel createList(JFileChooser fc) {
+ return filePane.createList();
+ }
+
+ protected JPanel createDetailsView(JFileChooser fc) {
+ return filePane.createDetailsView();
+ }
+
+ /**
+ * Creates a selection listener for the list of files and directories.
+ *
+ * @param fc a <code>JFileChooser</code>
+ * @return a <code>ListSelectionListener</code>
+ */
+ public ListSelectionListener createListSelectionListener(JFileChooser fc) {
+ return super.createListSelectionListener(fc);
+ }
+
+ // Obsolete class, not used in this version.
+ @SuppressWarnings("serial")
+ protected class WindowsNewFolderAction extends NewFolderAction {
+ }
+
+ // Obsolete class, not used in this version.
+ protected class SingleClickListener extends MouseAdapter {
+ }
+
+ // Obsolete class, not used in this version.
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ protected class FileRenderer extends DefaultListCellRenderer {
+ }
+
+ public void uninstallUI(JComponent c) {
+ // Remove listeners
+ c.removePropertyChangeListener(filterComboBoxModel);
+ c.removePropertyChangeListener(filePane);
+ if (placesBar != null) {
+ c.removePropertyChangeListener(placesBar);
+ }
+ cancelButton.removeActionListener(getCancelSelectionAction());
+ approveButton.removeActionListener(getApproveSelectionAction());
+ filenameTextField.removeActionListener(getApproveSelectionAction());
+
+ if (filePane != null) {
+ filePane.uninstallUI();
+ filePane = null;
+ }
+
+ super.uninstallUI(c);
+ }
+
+ /**
+ * Returns the preferred size of the specified
+ * <code>JFileChooser</code>.
+ * The preferred size is at least as large,
+ * in both height and width,
+ * as the preferred size recommended
+ * by the file chooser's layout manager.
+ *
+ * @param c a <code>JFileChooser</code>
+ * @return a <code>Dimension</code> specifying the preferred
+ * width and height of the file chooser
+ */
+ @Override
+ public Dimension getPreferredSize(JComponent c) {
+ int prefWidth = PREF_SIZE.width;
+ Dimension d = c.getLayout().preferredLayoutSize(c);
+ if (d != null) {
+ return new Dimension(d.width < prefWidth ? prefWidth : d.width,
+ d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height);
+ } else {
+ return new Dimension(prefWidth, PREF_SIZE.height);
+ }
+ }
+
+ /**
+ * Returns the minimum size of the <code>JFileChooser</code>.
+ *
+ * @param c a <code>JFileChooser</code>
+ * @return a <code>Dimension</code> specifying the minimum
+ * width and height of the file chooser
+ */
+ @Override
+ public Dimension getMinimumSize(JComponent c) {
+ return new Dimension(MIN_WIDTH, MIN_HEIGHT);
+ }
+
+ /**
+ * Returns the maximum size of the <code>JFileChooser</code>.
+ *
+ * @param c a <code>JFileChooser</code>
+ * @return a <code>Dimension</code> specifying the maximum
+ * width and height of the file chooser
+ */
+ @Override
+ public Dimension getMaximumSize(JComponent c) {
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ private String fileNameString(File file) {
+ if (file == null) {
+ return null;
+ } else {
+ JFileChooser fc = getFileChooser();
+ if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
+ (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){
+ return file.getPath();
+ } else {
+ return file.getName();
+ }
+ }
+ }
+
+ private String fileNameString(File[] files) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; files != null && i < files.length; i++) {
+ if (i > 0) {
+ buf.append(" ");
+ }
+ if (files.length > 1) {
+ buf.append("\"");
+ }
+ buf.append(fileNameString(files[i]));
+ if (files.length > 1) {
+ buf.append("\"");
+ }
+ }
+ return buf.toString();
+ }
+
+ /* The following methods are used by the PropertyChange Listener */
+
+ private void doSelectedFileChanged(PropertyChangeEvent e) {
+ File f = (File) e.getNewValue();
+ JFileChooser fc = getFileChooser();
+ if (f != null
+ && ((fc.isFileSelectionEnabled() && !f.isDirectory())
+ || (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {
+
+ setFileName(fileNameString(f));
+ }
+ }
+
+ private void doSelectedFilesChanged(PropertyChangeEvent e) {
+ File[] files = (File[]) e.getNewValue();
+ JFileChooser fc = getFileChooser();
+ if (files != null
+ && files.length > 0
+ && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
+ setFileName(fileNameString(files));
+ }
+ }
+
+ private void doDirectoryChanged(PropertyChangeEvent e) {
+ JFileChooser fc = getFileChooser();
+ FileSystemView fsv = fc.getFileSystemView();
+
+ clearIconCache();
+ File currentDirectory = fc.getCurrentDirectory();
+ if(currentDirectory != null) {
+ directoryComboBoxModel.addItem(currentDirectory);
+
+ if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
+ if (fsv.isFileSystem(currentDirectory)) {
+ setFileName(currentDirectory.getPath());
+ } else {
+ setFileName(null);
+ }
+ }
+ }
+ }
+
+ private void doFilterChanged(PropertyChangeEvent e) {
+ clearIconCache();
+ }
+
+ private void doFileSelectionModeChanged(PropertyChangeEvent e) {
+ if (fileNameLabel != null) {
+ populateFileNameLabel();
+ }
+ clearIconCache();
+
+ JFileChooser fc = getFileChooser();
+ File currentDirectory = fc.getCurrentDirectory();
+ if (currentDirectory != null
+ && fc.isDirectorySelectionEnabled()
+ && !fc.isFileSelectionEnabled()
+ && fc.getFileSystemView().isFileSystem(currentDirectory)) {
+
+ setFileName(currentDirectory.getPath());
+ } else {
+ setFileName(null);
+ }
+ }
+
+ private void doAccessoryChanged(PropertyChangeEvent e) {
+ if(getAccessoryPanel() != null) {
+ if(e.getOldValue() != null) {
+ getAccessoryPanel().remove((JComponent) e.getOldValue());
+ }
+ JComponent accessory = (JComponent) e.getNewValue();
+ if(accessory != null) {
+ getAccessoryPanel().add(accessory, BorderLayout.CENTER);
+ }
+ }
+ }
+
+ private void doApproveButtonTextChanged(PropertyChangeEvent e) {
+ JFileChooser chooser = getFileChooser();
+ approveButton.setText(getApproveButtonText(chooser));
+ approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
+ approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
+ }
+
+ private void doDialogTypeChanged(PropertyChangeEvent e) {
+ JFileChooser chooser = getFileChooser();
+ approveButton.setText(getApproveButtonText(chooser));
+ approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
+ approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
+ if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
+ lookInLabel.setText(saveInLabelText);
+ } else {
+ lookInLabel.setText(lookInLabelText);
+ }
+ }
+
+ private void doApproveButtonMnemonicChanged(PropertyChangeEvent e) {
+ approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
+ }
+
+ private void doControlButtonsChanged(PropertyChangeEvent e) {
+ if(getFileChooser().getControlButtonsAreShown()) {
+ addControlButtons();
+ } else {
+ removeControlButtons();
+ }
+ }
+
+ /*
+ * Listen for filechooser property changes, such as
+ * the selected file changing, or the type of the dialog changing.
+ */
+ public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
+ return new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ String s = e.getPropertyName();
+ if(s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
+ doSelectedFileChanged(e);
+ } else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
+ doSelectedFilesChanged(e);
+ } else if(s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
+ doDirectoryChanged(e);
+ } else if(s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
+ doFilterChanged(e);
+ } else if(s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
+ doFileSelectionModeChanged(e);
+ } else if(s.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
+ doAccessoryChanged(e);
+ } else if (s.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
+ s.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {
+ doApproveButtonTextChanged(e);
+ } else if(s.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
+ doDialogTypeChanged(e);
+ } else if(s.equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
+ doApproveButtonMnemonicChanged(e);
+ } else if(s.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
+ doControlButtonsChanged(e);
+ } else if (s == "FileChooser.useShellFolder") {
+ updateUseShellFolder();
+ doDirectoryChanged(e);
+ } else if (s.equals("componentOrientation")) {
+ ComponentOrientation o = (ComponentOrientation)e.getNewValue();
+ JFileChooser cc = (JFileChooser)e.getSource();
+ if (o != e.getOldValue()) {
+ cc.applyComponentOrientation(o);
+ }
+ } else if (s.equals("ancestor")) {
+ if (e.getOldValue() == null && e.getNewValue() != null) {
+ // Ancestor was added, set initial focus
+ filenameTextField.selectAll();
+ filenameTextField.requestFocus();
+ }
+ }
+ }
+ };
+ }
+
+
+ protected void removeControlButtons() {
+ getBottomPanel().remove(getButtonPanel());
+ }
+
+ protected void addControlButtons() {
+ getBottomPanel().add(getButtonPanel());
+ }
+
+ public void ensureFileIsVisible(JFileChooser fc, File f) {
+ filePane.ensureFileIsVisible(fc, f);
+ }
+
+ public void rescanCurrentDirectory(JFileChooser fc) {
+ filePane.rescanCurrentDirectory();
+ }
+
+ public String getFileName() {
+ if(filenameTextField != null) {
+ return filenameTextField.getText();
+ } else {
+ return null;
+ }
+ }
+
+ public void setFileName(String filename) {
+ if(filenameTextField != null) {
+ filenameTextField.setText(filename);
+ }
+ }
+
+ /**
+ * Property to remember whether a directory is currently selected in the UI.
+ * This is normally called by the UI on a selection event.
+ *
+ * @param directorySelected if a directory is currently selected.
+ * @since 1.4
+ */
+ protected void setDirectorySelected(boolean directorySelected) {
+ super.setDirectorySelected(directorySelected);
+ JFileChooser chooser = getFileChooser();
+ if(directorySelected) {
+ approveButton.setText(directoryOpenButtonText);
+ approveButton.setToolTipText(directoryOpenButtonToolTipText);
+ approveButton.setMnemonic(directoryOpenButtonMnemonic);
+ } else {
+ approveButton.setText(getApproveButtonText(chooser));
+ approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
+ approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
+ }
+ }
+
+ public String getDirectoryName() {
+ // PENDING(jeff) - get the name from the directory combobox
+ return null;
+ }
+
+ public void setDirectoryName(String dirname) {
+ // PENDING(jeff) - set the name in the directory combobox
+ }
+
+ protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
+ return new DirectoryComboBoxRenderer();
+ }
+
+ @SuppressWarnings("serial") // anonymous class
+ private static JButton createToolButton(Action a, Icon defaultIcon, String toolTipText, String accessibleName) {
+ final JButton result = new JButton(a);
+
+ result.setText(null);
+ result.setIcon(defaultIcon);
+ result.setToolTipText(toolTipText);
+ result.setRequestFocusEnabled(false);
+ result.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
+ result.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY, Boolean.TRUE);
+ result.setAlignmentX(JComponent.LEFT_ALIGNMENT);
+ result.setAlignmentY(JComponent.CENTER_ALIGNMENT);
+ result.setMargin(shrinkwrap);
+ result.setFocusPainted(false);
+
+ result.setModel(new DefaultButtonModel() {
+ public void setPressed(boolean b) {
+ // Forbid keyboard actions if the button is not in rollover state
+ if (!b || isRollover()) {
+ super.setPressed(b);
+ }
+ }
+
+ public void setRollover(boolean b) {
+ if (b && !isRollover()) {
+ // Reset other buttons
+ for (Component component : result.getParent().getComponents()) {
+ if (component instanceof JButton && component != result) {
+ ((JButton) component).getModel().setRollover(false);
+ }
+ }
+ }
+
+ super.setRollover(b);
+ }
+
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+
+ if (b) {
+ stateMask |= PRESSED | ARMED;
+ } else {
+ stateMask &= ~(PRESSED | ARMED);
+ }
+ }
+ });
+
+ result.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ result.getModel().setRollover(true);
+ }
+
+ public void focusLost(FocusEvent e) {
+ result.getModel().setRollover(false);
+ }
+ });
+
+ return result;
+ }
+
+ //
+ // Renderer for DirectoryComboBox
+ //
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ class DirectoryComboBoxRenderer extends DefaultListCellRenderer {
+ IndentIcon ii = new IndentIcon();
+ public Component getListCellRendererComponent(JList<?> list, Object value,
+ int index, boolean isSelected,
+ boolean cellHasFocus) {
+
+ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+
+ if (value == null) {
+ setText("");
+ return this;
+ }
+ File directory = (File)value;
+ setText(getFileChooser().getName(directory));
+ Icon icon = getFileChooser().getIcon(directory);
+ ii.icon = icon;
+ ii.depth = directoryComboBoxModel.getDepth(index);
+ setIcon(ii);
+
+ return this;
+ }
+ }
+
+ static final int space = 10;
+ class IndentIcon implements Icon {
+
+ Icon icon = null;
+ int depth = 0;
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ if (c.getComponentOrientation().isLeftToRight()) {
+ icon.paintIcon(c, g, x+depth*space, y);
+ } else {
+ icon.paintIcon(c, g, x, y);
+ }
+ }
+
+ public int getIconWidth() {
+ return icon.getIconWidth() + depth*space;
+ }
+
+ public int getIconHeight() {
+ return icon.getIconHeight();
+ }
+
+ }
+
+ //
+ // DataModel for DirectoryComboxbox
+ //
+ protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) {
+ return new DirectoryComboBoxModel();
+ }
+
+ /**
+ * Data model for a type-face selection combo-box.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
+ Vector<File> directories = new Vector<File>();
+ int[] depths = null;
+ File selectedDirectory = null;
+ JFileChooser chooser = getFileChooser();
+ FileSystemView fsv = chooser.getFileSystemView();
+
+ public DirectoryComboBoxModel() {
+ // Add the current directory to the model, and make it the
+ // selectedDirectory
+ File dir = getFileChooser().getCurrentDirectory();
+ if(dir != null) {
+ addItem(dir);
+ }
+ }
+
+ /**
+ * Adds the directory to the model and sets it to be selected,
+ * additionally clears out the previous selected directory and
+ * the paths leading up to it, if any.
+ */
+ private void addItem(File directory) {
+
+ if(directory == null) {
+ return;
+ }
+
+ boolean useShellFolder = FilePane.usesShellFolder(chooser);
+
+ directories.clear();
+
+ File[] baseFolders = (useShellFolder)
+ ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
+ : fsv.getRoots();
+ directories.addAll(Arrays.asList(baseFolders));
+
+ // Get the canonical (full) path. This has the side
+ // benefit of removing extraneous chars from the path,
+ // for example /foo/bar/ becomes /foo/bar
+ File canonical;
+ try {
+ canonical = directory.getCanonicalFile();
+ } catch (IOException e) {
+ // Maybe drive is not ready. Can't abort here.
+ canonical = directory;
+ }
+
+ // create File instances of each directory leading up to the top
+ try {
+ File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
+ : canonical;
+ File f = sf;
+ Vector<File> path = new Vector<File>(10);
+ do {
+ path.addElement(f);
+ } while ((f = f.getParentFile()) != null);
+
+ int pathCount = path.size();
+ // Insert chain at appropriate place in vector
+ for (int i = 0; i < pathCount; i++) {
+ f = path.get(i);
+ if (directories.contains(f)) {
+ int topIndex = directories.indexOf(f);
+ for (int j = i-1; j >= 0; j--) {
+ directories.insertElementAt(path.get(j), topIndex+i-j);
+ }
+ break;
+ }
+ }
+ calculateDepths();
+ setSelectedItem(sf);
+ } catch (FileNotFoundException ex) {
+ calculateDepths();
+ }
+ }
+
+ private void calculateDepths() {
+ depths = new int[directories.size()];
+ for (int i = 0; i < depths.length; i++) {
+ File dir = directories.get(i);
+ File parent = dir.getParentFile();
+ depths[i] = 0;
+ if (parent != null) {
+ for (int j = i-1; j >= 0; j--) {
+ if (parent.equals(directories.get(j))) {
+ depths[i] = depths[j] + 1;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public int getDepth(int i) {
+ return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0;
+ }
+
+ public void setSelectedItem(Object selectedDirectory) {
+ this.selectedDirectory = (File)selectedDirectory;
+ fireContentsChanged(this, -1, -1);
+ }
+
+ public Object getSelectedItem() {
+ return selectedDirectory;
+ }
+
+ public int getSize() {
+ return directories.size();
+ }
+
+ public File getElementAt(int index) {
+ return directories.elementAt(index);
+ }
+ }
+
+ //
+ // Renderer for Types ComboBox
+ //
+ protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
+ return new FilterComboBoxRenderer();
+ }
+
+ /**
+ * Render different type sizes and styles.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public class FilterComboBoxRenderer extends DefaultListCellRenderer {
+ public Component getListCellRendererComponent(JList<?> list,
+ Object value, int index, boolean isSelected,
+ boolean cellHasFocus) {
+
+ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+
+ if (value != null && value instanceof FileFilter) {
+ setText(((FileFilter)value).getDescription());
+ }
+
+ return this;
+ }
+ }
+
+ //
+ // DataModel for Types Comboxbox
+ //
+ protected FilterComboBoxModel createFilterComboBoxModel() {
+ return new FilterComboBoxModel();
+ }
+
+ /**
+ * Data model for a type-face selection combo-box.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+ PropertyChangeListener {
+ protected FileFilter[] filters;
+ protected FilterComboBoxModel() {
+ super();
+ filters = getFileChooser().getChoosableFileFilters();
+ }
+
+ public void propertyChange(PropertyChangeEvent e) {
+ String prop = e.getPropertyName();
+ if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) {
+ filters = (FileFilter[]) e.getNewValue();
+ fireContentsChanged(this, -1, -1);
+ } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
+ fireContentsChanged(this, -1, -1);
+ }
+ }
+
+ public void setSelectedItem(Object filter) {
+ if(filter != null) {
+ getFileChooser().setFileFilter((FileFilter) filter);
+ fireContentsChanged(this, -1, -1);
+ }
+ }
+
+ public Object getSelectedItem() {
+ // Ensure that the current filter is in the list.
+ // NOTE: we shouldnt' have to do this, since JFileChooser adds
+ // the filter to the choosable filters list when the filter
+ // is set. Lets be paranoid just in case someone overrides
+ // setFileFilter in JFileChooser.
+ FileFilter currentFilter = getFileChooser().getFileFilter();
+ boolean found = false;
+ if(currentFilter != null) {
+ for (FileFilter filter : filters) {
+ if (filter == currentFilter) {
+ found = true;
+ }
+ }
+ if(found == false) {
+ getFileChooser().addChoosableFileFilter(currentFilter);
+ }
+ }
+ return getFileChooser().getFileFilter();
+ }
+
+ public int getSize() {
+ if(filters != null) {
+ return filters.length;
+ } else {
+ return 0;
+ }
+ }
+
+ public FileFilter getElementAt(int index) {
+ if(index > getSize() - 1) {
+ // This shouldn't happen. Try to recover gracefully.
+ return getFileChooser().getFileFilter();
+ }
+ if(filters != null) {
+ return filters[index];
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public void valueChanged(ListSelectionEvent e) {
+ JFileChooser fc = getFileChooser();
+ File f = fc.getSelectedFile();
+ if (!e.getValueIsAdjusting() && f != null && !getFileChooser().isTraversable(f)) {
+ setFileName(fileNameString(f));
+ }
+ }
+
+ /**
+ * Acts when DirectoryComboBox has changed the selected item.
+ */
+ protected class DirectoryComboBoxAction implements ActionListener {
+
+
+
+
+ public void actionPerformed(ActionEvent e) {
+ File f = (File)directoryComboBox.getSelectedItem();
+ getFileChooser().setCurrentDirectory(f);
+ }
+ }
+
+ protected JButton getApproveButton(JFileChooser fc) {
+ return approveButton;
+ }
+
+ public FileView getFileView(JFileChooser fc) {
+ return fileView;
+ }
+
+ // ***********************
+ // * FileView operations *
+ // ***********************
+ protected class WindowsFileView extends BasicFileView {
+ /* FileView type descriptions */
+
+ public Icon getIcon(File f) {
+ Icon icon = getCachedIcon(f);
+ if (icon != null) {
+ return icon;
+ }
+ if (f != null) {
+ icon = getFileChooser().getFileSystemView().getSystemIcon(f);
+ }
+ if (icon == null) {
+ icon = super.getIcon(f);
+ }
+ cacheIcon(f, icon);
+ return icon;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.swing.SwingUtilities2;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.UIResource;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+
+/**
+ * A collection of static utility methods used for rendering the Windows look
+ * and feel.
+ *
+ * @author Mark Davidson
+ * @since 1.4
+ */
+public class WindowsGraphicsUtils {
+
+ /**
+ * Renders a text String in Windows without the mnemonic.
+ * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
+ * the overriden paintText methods of the ButtonUI delegates will call this static method.
+ *
+ * @param g Graphics context
+ * @param b Current button to render
+ * @param textRect Bounding rectangle to render the text.
+ * @param text String to render
+ */
+ public static void paintText(Graphics g, AbstractButton b,
+ Rectangle textRect, String text,
+ int textShiftOffset) {
+ FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
+
+ int mnemIndex = b.getDisplayedMnemonicIndex();
+ // W2K Feature: Check to see if the Underscore should be rendered.
+ if (WindowsLookAndFeel.isMnemonicHidden() == true) {
+ mnemIndex = -1;
+ }
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null && !(b instanceof JMenuItem)) {
+ paintXPText(b, g, textRect.x + textShiftOffset,
+ textRect.y + fm.getAscent() + textShiftOffset,
+ text, mnemIndex);
+ } else {
+ paintClassicText(b, g, textRect.x + textShiftOffset,
+ textRect.y + fm.getAscent() + textShiftOffset,
+ text, mnemIndex);
+ }
+ }
+
+ static void paintClassicText(AbstractButton b, Graphics g, int x, int y,
+ String text, int mnemIndex) {
+ ButtonModel model = b.getModel();
+
+ /* Draw the Text */
+ Color color = b.getForeground();
+ if(model.isEnabled()) {
+ /*** paint the text normally */
+ if(!(b instanceof JMenuItem && model.isArmed())
+ && !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) {
+ /* We shall not set foreground color for selected menu or
+ * armed menuitem. Foreground must be set in appropriate
+ * Windows* class because these colors passes from
+ * BasicMenuItemUI as protected fields and we can't
+ * reach them from this class */
+ g.setColor(b.getForeground());
+ }
+ SwingUtilities2.drawStringUnderlineCharAt(b, g,text, mnemIndex, x, y);
+ } else { /*** paint the text disabled ***/
+ color = getDisabledTextColor(b);
+ if (color == null) {
+ color = UIManager.getColor("Button.shadow");
+ }
+ Color shadow = UIManager.getColor("Button.disabledShadow");
+ if(model.isArmed()) {
+ color = UIManager.getColor("Button.disabledForeground");
+ } else {
+ if (shadow == null) {
+ shadow = b.getBackground().darker();
+ }
+ g.setColor(shadow);
+ SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
+ x + 1, y + 1);
+ }
+ if (color == null) {
+ color = b.getBackground().brighter();
+ }
+ g.setColor(color);
+ SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
+ }
+ }
+
+ private static Color getDisabledTextColor(AbstractButton b) {
+ if (b instanceof JCheckBox) {
+ return UIManager.getColor("CheckBox.disabledText");
+ } else if (b instanceof JRadioButton) {
+ return UIManager.getColor("RadioButton.disabledText");
+ } else if (b instanceof JToggleButton) {
+ return UIManager.getColor("ToggleButton.disabledText");
+ } else if (b instanceof JButton) {
+ return UIManager.getColor("Button.disabledText");
+ }
+ return null;
+ }
+
+ static void paintXPText(AbstractButton b, Graphics g, int x, int y,
+ String text, int mnemIndex) {
+ Part part = WindowsButtonUI.getXPButtonType(b);
+ State state = WindowsButtonUI.getXPButtonState(b);
+ paintXPText(b, part, state, g, x, y, text, mnemIndex);
+ }
+
+ static void paintXPText(AbstractButton b, Part part, State state,
+ Graphics g, int x, int y, String text, int mnemIndex) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
+ Color textColor;
+ if (b.isEnabled()) {
+ textColor = b.getForeground();
+ }
+ else {
+ textColor = getDisabledTextColor(b);
+ }
+
+ if (textColor == null || textColor instanceof UIResource) {
+ textColor = xp.getColor(b, part, state, Prop.TEXTCOLOR, b.getForeground());
+ // to work around an apparent bug in Windows, use the pushbutton
+ // color for disabled toolbar buttons if the disabled color is the
+ // same as the enabled color
+ if (part == Part.TP_BUTTON && state == State.DISABLED) {
+ Color enabledColor = xp.getColor(b, part, State.NORMAL,
+ Prop.TEXTCOLOR, b.getForeground());
+ if(textColor.equals(enabledColor)) {
+ textColor = xp.getColor(b, Part.BP_PUSHBUTTON, state,
+ Prop.TEXTCOLOR, textColor);
+ }
+ }
+ // only draw shadow if developer hasn't changed the foreground color
+ // and if the current style has text shadows.
+ TypeEnum shadowType = xp.getTypeEnum(b, part,
+ state, Prop.TEXTSHADOWTYPE);
+ if (shadowType == TypeEnum.TST_SINGLE ||
+ shadowType == TypeEnum.TST_CONTINUOUS) {
+ Color shadowColor = xp.getColor(b, part, state,
+ Prop.TEXTSHADOWCOLOR, Color.black);
+ Point offset = xp.getPoint(b, part, state, Prop.TEXTSHADOWOFFSET);
+ if (offset != null) {
+ g.setColor(shadowColor);
+ SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
+ x + offset.x,
+ y + offset.y);
+ }
+ }
+ }
+
+ g.setColor(textColor);
+ SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
+ }
+
+ static boolean isLeftToRight(Component c) {
+ return c.getComponentOrientation().isLeftToRight();
+ }
+
+ /*
+ * Repaints all the components with the mnemonics in the given window and
+ * all its owned windows.
+ */
+ static void repaintMnemonicsInWindow(Window w) {
+ if(w == null || !w.isShowing()) {
+ return;
+ }
+
+ Window[] ownedWindows = w.getOwnedWindows();
+ for(int i=0;i<ownedWindows.length;i++) {
+ repaintMnemonicsInWindow(ownedWindows[i]);
+ }
+
+ repaintMnemonicsInContainer(w);
+ }
+
+ /*
+ * Repaints all the components with the mnemonics in container.
+ * Recursively searches for all the subcomponents.
+ */
+ static void repaintMnemonicsInContainer(Container cont) {
+ Component c;
+ for(int i=0; i<cont.getComponentCount(); i++) {
+ c = cont.getComponent(i);
+ if(c == null || !c.isVisible()) {
+ continue;
+ }
+ if(c instanceof AbstractButton
+ && ((AbstractButton)c).getMnemonic() != '\0') {
+ c.repaint();
+ continue;
+ } else if(c instanceof JLabel
+ && ((JLabel)c).getDisplayedMnemonic() != '\0') {
+ c.repaint();
+ continue;
+ }
+ if(c instanceof Container) {
+ repaintMnemonicsInContainer((Container)c);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,974 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.*;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.UIResource;
+
+import java.awt.*;
+import java.io.Serializable;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+import sun.swing.MenuItemCheckIconFactory;
+import sun.swing.SwingUtilities2;
+
+/**
+ * Factory object that can vend Icons appropriate for the Windows {@literal L & F}.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author David Kloba
+ * @author Georges Saab
+ * @author Rich Schiavi
+ */
+@SuppressWarnings("serial") // Same-version serialization only
+public class WindowsIconFactory implements Serializable
+{
+ private static Icon frame_closeIcon;
+ private static Icon frame_iconifyIcon;
+ private static Icon frame_maxIcon;
+ private static Icon frame_minIcon;
+ private static Icon frame_resizeIcon;
+ private static Icon checkBoxIcon;
+ private static Icon radioButtonIcon;
+ private static Icon checkBoxMenuItemIcon;
+ private static Icon radioButtonMenuItemIcon;
+ private static Icon menuItemCheckIcon;
+ private static Icon menuItemArrowIcon;
+ private static Icon menuArrowIcon;
+ private static VistaMenuItemCheckIconFactory menuItemCheckIconFactory;
+
+ public static Icon getMenuItemCheckIcon() {
+ if (menuItemCheckIcon == null) {
+ menuItemCheckIcon = new MenuItemCheckIcon();
+ }
+ return menuItemCheckIcon;
+ }
+
+ public static Icon getMenuItemArrowIcon() {
+ if (menuItemArrowIcon == null) {
+ menuItemArrowIcon = new MenuItemArrowIcon();
+ }
+ return menuItemArrowIcon;
+ }
+
+ public static Icon getMenuArrowIcon() {
+ if (menuArrowIcon == null) {
+ menuArrowIcon = new MenuArrowIcon();
+ }
+ return menuArrowIcon;
+ }
+
+ public static Icon getCheckBoxIcon() {
+ if (checkBoxIcon == null) {
+ checkBoxIcon = new CheckBoxIcon();
+ }
+ return checkBoxIcon;
+ }
+
+ public static Icon getRadioButtonIcon() {
+ if (radioButtonIcon == null) {
+ radioButtonIcon = new RadioButtonIcon();
+ }
+ return radioButtonIcon;
+ }
+
+ public static Icon getCheckBoxMenuItemIcon() {
+ if (checkBoxMenuItemIcon == null) {
+ checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
+ }
+ return checkBoxMenuItemIcon;
+ }
+
+ public static Icon getRadioButtonMenuItemIcon() {
+ if (radioButtonMenuItemIcon == null) {
+ radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
+ }
+ return radioButtonMenuItemIcon;
+ }
+
+ static
+ synchronized VistaMenuItemCheckIconFactory getMenuItemCheckIconFactory() {
+ if (menuItemCheckIconFactory == null) {
+ menuItemCheckIconFactory =
+ new VistaMenuItemCheckIconFactory();
+ }
+ return menuItemCheckIconFactory;
+ }
+
+ public static Icon createFrameCloseIcon() {
+ if (frame_closeIcon == null) {
+ frame_closeIcon = new FrameButtonIcon(Part.WP_CLOSEBUTTON);
+ }
+ return frame_closeIcon;
+ }
+
+ public static Icon createFrameIconifyIcon() {
+ if (frame_iconifyIcon == null) {
+ frame_iconifyIcon = new FrameButtonIcon(Part.WP_MINBUTTON);
+ }
+ return frame_iconifyIcon;
+ }
+
+ public static Icon createFrameMaximizeIcon() {
+ if (frame_maxIcon == null) {
+ frame_maxIcon = new FrameButtonIcon(Part.WP_MAXBUTTON);
+ }
+ return frame_maxIcon;
+ }
+
+ public static Icon createFrameMinimizeIcon() {
+ if (frame_minIcon == null) {
+ frame_minIcon = new FrameButtonIcon(Part.WP_RESTOREBUTTON);
+ }
+ return frame_minIcon;
+ }
+
+ public static Icon createFrameResizeIcon() {
+ if(frame_resizeIcon == null)
+ frame_resizeIcon = new ResizeIcon();
+ return frame_resizeIcon;
+ }
+
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class FrameButtonIcon implements Icon, Serializable {
+ private Part part;
+
+ private FrameButtonIcon(Part part) {
+ this.part = part;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x0, int y0) {
+ int width = getIconWidth();
+ int height = getIconHeight();
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(c, part);
+ AbstractButton b = (AbstractButton)c;
+ ButtonModel model = b.getModel();
+
+ // Find out if frame is inactive
+ JInternalFrame jif = (JInternalFrame)SwingUtilities.
+ getAncestorOfClass(JInternalFrame.class, b);
+ boolean jifSelected = (jif != null && jif.isSelected());
+
+ State state;
+ if (jifSelected) {
+ if (!model.isEnabled()) {
+ state = State.DISABLED;
+ } else if (model.isArmed() && model.isPressed()) {
+ state = State.PUSHED;
+ } else if (model.isRollover()) {
+ state = State.HOT;
+ } else {
+ state = State.NORMAL;
+ }
+ } else {
+ if (!model.isEnabled()) {
+ state = State.INACTIVEDISABLED;
+ } else if (model.isArmed() && model.isPressed()) {
+ state = State.INACTIVEPUSHED;
+ } else if (model.isRollover()) {
+ state = State.INACTIVEHOT;
+ } else {
+ state = State.INACTIVENORMAL;
+ }
+ }
+ skin.paintSkin(g, 0, 0, width, height, state);
+ } else {
+ g.setColor(Color.black);
+ int x = width / 12 + 2;
+ int y = height / 5;
+ int h = height - y * 2 - 1;
+ int w = width * 3/4 -3;
+ int thickness2 = Math.max(height / 8, 2);
+ int thickness = Math.max(width / 15, 1);
+ if (part == Part.WP_CLOSEBUTTON) {
+ int lineWidth;
+ if (width > 47) lineWidth = 6;
+ else if (width > 37) lineWidth = 5;
+ else if (width > 26) lineWidth = 4;
+ else if (width > 16) lineWidth = 3;
+ else if (width > 12) lineWidth = 2;
+ else lineWidth = 1;
+ y = height / 12 + 2;
+ if (lineWidth == 1) {
+ if (w % 2 == 1) { x++; w++; }
+ g.drawLine(x, y, x+w-2, y+w-2);
+ g.drawLine(x+w-2, y, x, y+w-2);
+ } else if (lineWidth == 2) {
+ if (w > 6) { x++; w--; }
+ g.drawLine(x, y, x+w-2, y+w-2);
+ g.drawLine(x+w-2, y, x, y+w-2);
+ g.drawLine(x+1, y, x+w-1, y+w-2);
+ g.drawLine(x+w-1, y, x+1, y+w-2);
+ } else {
+ x += 2; y++; w -= 2;
+ g.drawLine(x, y, x+w-1, y+w-1);
+ g.drawLine(x+w-1, y, x, y+w-1);
+ g.drawLine(x+1, y, x+w-1, y+w-2);
+ g.drawLine(x+w-2, y, x, y+w-2);
+ g.drawLine(x, y+1, x+w-2, y+w-1);
+ g.drawLine(x+w-1, y+1, x+1, y+w-1);
+ for (int i = 4; i <= lineWidth; i++) {
+ g.drawLine(x+i-2, y, x+w-1, y+w-i+1);
+ g.drawLine(x, y+i-2, x+w-i+1, y+w-1);
+ g.drawLine(x+w-i+1, y, x, y+w-i+1);
+ g.drawLine(x+w-1, y+i-2, x+i-2, y+w-1);
+ }
+ }
+ } else if (part == Part.WP_MINBUTTON) {
+ g.fillRect(x, y+h-thickness2, w-w/3, thickness2);
+ } else if (part == Part.WP_MAXBUTTON) {
+ g.fillRect(x, y, w, thickness2);
+ g.fillRect(x, y, thickness, h);
+ g.fillRect(x+w-thickness, y, thickness, h);
+ g.fillRect(x, y+h-thickness, w, thickness);
+ } else if (part == Part.WP_RESTOREBUTTON) {
+ g.fillRect(x+w/3, y, w-w/3, thickness2);
+ g.fillRect(x+w/3, y, thickness, h/3);
+ g.fillRect(x+w-thickness, y, thickness, h-h/3);
+ g.fillRect(x+w-w/3, y+h-h/3-thickness, w/3, thickness);
+
+ g.fillRect(x, y+h/3, w-w/3, thickness2);
+ g.fillRect(x, y+h/3, thickness, h-h/3);
+ g.fillRect(x+w-w/3-thickness, y+h/3, thickness, h-h/3);
+ g.fillRect(x, y+h-thickness, w-w/3, thickness);
+ }
+ }
+ }
+
+ public int getIconWidth() {
+ int width;
+ if (XPStyle.getXP() != null) {
+ // Fix for XP bug where sometimes these sizes aren't updated properly
+ // Assume for now that height is correct and derive width using the
+ // ratio from the uxtheme part
+ width = UIManager.getInt("InternalFrame.titleButtonHeight") -2;
+ Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
+ if (d != null && d.width != 0 && d.height != 0) {
+ width = (int) ((float) width * d.width / d.height);
+ }
+ } else {
+ width = UIManager.getInt("InternalFrame.titleButtonWidth") -2;
+ }
+ if (XPStyle.getXP() != null) {
+ width -= 2;
+ }
+ return width;
+ }
+
+ public int getIconHeight() {
+ int height = UIManager.getInt("InternalFrame.titleButtonHeight")-4;
+ return height;
+ }
+ }
+
+
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class ResizeIcon implements Icon, Serializable {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ g.setColor(UIManager.getColor("InternalFrame.resizeIconHighlight"));
+ g.drawLine(0, 11, 11, 0);
+ g.drawLine(4, 11, 11, 4);
+ g.drawLine(8, 11, 11, 8);
+
+ g.setColor(UIManager.getColor("InternalFrame.resizeIconShadow"));
+ g.drawLine(1, 11, 11, 1);
+ g.drawLine(2, 11, 11, 2);
+ g.drawLine(5, 11, 11, 5);
+ g.drawLine(6, 11, 11, 6);
+ g.drawLine(9, 11, 11, 9);
+ g.drawLine(10, 11, 11, 10);
+ }
+ public int getIconWidth() { return 13; }
+ public int getIconHeight() { return 13; }
+ };
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class CheckBoxIcon implements Icon, Serializable
+ {
+ static final int csize = 13;
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ JCheckBox cb = (JCheckBox) c;
+ ButtonModel model = cb.getModel();
+ XPStyle xp = XPStyle.getXP();
+
+ if (xp != null) {
+ State state;
+ if (model.isSelected()) {
+ state = State.CHECKEDNORMAL;
+ if (!model.isEnabled()) {
+ state = State.CHECKEDDISABLED;
+ } else if (model.isPressed() && model.isArmed()) {
+ state = State.CHECKEDPRESSED;
+ } else if (model.isRollover()) {
+ state = State.CHECKEDHOT;
+ }
+ } else {
+ state = State.UNCHECKEDNORMAL;
+ if (!model.isEnabled()) {
+ state = State.UNCHECKEDDISABLED;
+ } else if (model.isPressed() && model.isArmed()) {
+ state = State.UNCHECKEDPRESSED;
+ } else if (model.isRollover()) {
+ state = State.UNCHECKEDHOT;
+ }
+ }
+ Part part = Part.BP_CHECKBOX;
+ xp.getSkin(c, part).paintSkin(g, x, y, state);
+ } else {
+ // outer bevel
+ if(!cb.isBorderPaintedFlat()) {
+ // Outer top/left
+ g.setColor(UIManager.getColor("CheckBox.shadow"));
+ g.drawLine(x, y, x+11, y);
+ g.drawLine(x, y+1, x, y+11);
+
+ // Outer bottom/right
+ g.setColor(UIManager.getColor("CheckBox.highlight"));
+ g.drawLine(x+12, y, x+12, y+12);
+ g.drawLine(x, y+12, x+11, y+12);
+
+ // Inner top.left
+ g.setColor(UIManager.getColor("CheckBox.darkShadow"));
+ g.drawLine(x+1, y+1, x+10, y+1);
+ g.drawLine(x+1, y+2, x+1, y+10);
+
+ // Inner bottom/right
+ g.setColor(UIManager.getColor("CheckBox.light"));
+ g.drawLine(x+1, y+11, x+11, y+11);
+ g.drawLine(x+11, y+1, x+11, y+10);
+
+ // inside box
+ if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
+ g.setColor(UIManager.getColor("CheckBox.background"));
+ } else {
+ g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
+ }
+ g.fillRect(x+2, y+2, csize-4, csize-4);
+ } else {
+ g.setColor(UIManager.getColor("CheckBox.shadow"));
+ g.drawRect(x+1, y+1, csize-3, csize-3);
+
+ if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
+ g.setColor(UIManager.getColor("CheckBox.background"));
+ } else {
+ g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
+ }
+ g.fillRect(x+2, y+2, csize-4, csize-4);
+ }
+
+ if(model.isEnabled()) {
+ g.setColor(UIManager.getColor("CheckBox.foreground"));
+ } else {
+ g.setColor(UIManager.getColor("CheckBox.shadow"));
+ }
+
+ // paint check
+ if (model.isSelected()) {
+ if (SwingUtilities2.isScaledGraphics(g)) {
+ int[] xPoints = {3, 5, 9, 9, 5, 3};
+ int[] yPoints = {5, 7, 3, 5, 9, 7};
+ g.translate(x, y);
+ g.fillPolygon(xPoints, yPoints, 6);
+ g.drawPolygon(xPoints, yPoints, 6);
+ g.translate(-x, -y);
+ } else {
+ g.drawLine(x + 9, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 4, x + 9, y + 4);
+ g.drawLine(x + 7, y + 5, x + 9, y + 5);
+ g.drawLine(x + 6, y + 6, x + 8, y + 6);
+ g.drawLine(x + 3, y + 7, x + 7, y + 7);
+ g.drawLine(x + 4, y + 8, x + 6, y + 8);
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
+ g.drawLine(x + 3, y + 5, x + 3, y + 5);
+ g.drawLine(x + 3, y + 6, x + 4, y + 6);
+ }
+ }
+ }
+ }
+
+ public int getIconWidth() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return xp.getSkin(null, Part.BP_CHECKBOX).getWidth();
+ } else {
+ return csize;
+ }
+ }
+
+ public int getIconHeight() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return xp.getSkin(null, Part.BP_CHECKBOX).getHeight();
+ } else {
+ return csize;
+ }
+ }
+ }
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class RadioButtonIcon implements Icon, UIResource, Serializable
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ AbstractButton b = (AbstractButton) c;
+ ButtonModel model = b.getModel();
+ XPStyle xp = XPStyle.getXP();
+
+ if (xp != null) {
+ Part part = Part.BP_RADIOBUTTON;
+ Skin skin = xp.getSkin(b, part);
+ State state;
+ int index = 0;
+ if (model.isSelected()) {
+ state = State.CHECKEDNORMAL;
+ if (!model.isEnabled()) {
+ state = State.CHECKEDDISABLED;
+ } else if (model.isPressed() && model.isArmed()) {
+ state = State.CHECKEDPRESSED;
+ } else if (model.isRollover()) {
+ state = State.CHECKEDHOT;
+ }
+ } else {
+ state = State.UNCHECKEDNORMAL;
+ if (!model.isEnabled()) {
+ state = State.UNCHECKEDDISABLED;
+ } else if (model.isPressed() && model.isArmed()) {
+ state = State.UNCHECKEDPRESSED;
+ } else if (model.isRollover()) {
+ state = State.UNCHECKEDHOT;
+ }
+ }
+ skin.paintSkin(g, x, y, state);
+ } else {
+ // fill interior
+ if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
+ g.setColor(UIManager.getColor("RadioButton.background"));
+ } else {
+ g.setColor(UIManager.getColor("RadioButton.interiorBackground"));
+ }
+ g.fillRect(x+2, y+2, 8, 8);
+
+
+ boolean isScaledGraphics = SwingUtilities2.isScaledGraphics(g);
+
+ if (isScaledGraphics) {
+
+ Graphics2D g2d = (Graphics2D) g;
+ Stroke oldStroke = g2d.getStroke();
+ g2d.setStroke(new BasicStroke(1.03f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_ROUND));
+ Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
+ // outter left arc
+ g.setColor(UIManager.getColor("RadioButton.shadow"));
+ g.drawArc(x, y, 11, 11, 45, 180);
+ // outter right arc
+ g.setColor(UIManager.getColor("RadioButton.highlight"));
+ g.drawArc(x, y, 11, 11, 45, -180);
+ // inner left arc
+ g.setColor(UIManager.getColor("RadioButton.darkShadow"));
+ g.drawArc(x + 1, y + 1, 9, 9, 45, 180);
+ // inner right arc
+ g.setColor(UIManager.getColor("RadioButton.light"));
+ g.drawArc(x + 1, y + 1, 9, 9, 45, -180);
+
+ g2d.setStroke(oldStroke);
+
+ if (model.isSelected()) {
+ if (model.isEnabled()) {
+ g.setColor(UIManager.getColor("RadioButton.foreground"));
+ } else {
+ g.setColor(UIManager.getColor("RadioButton.shadow"));
+ }
+ g.fillOval(x + 3, y + 3, 5, 5);
+ }
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
+
+ } else {
+
+ // outter left arc
+ g.setColor(UIManager.getColor("RadioButton.shadow"));
+ g.drawLine(x+4, y+0, x+7, y+0);
+ g.drawLine(x+2, y+1, x+3, y+1);
+ g.drawLine(x+8, y+1, x+9, y+1);
+ g.drawLine(x+1, y+2, x+1, y+3);
+ g.drawLine(x+0, y+4, x+0, y+7);
+ g.drawLine(x+1, y+8, x+1, y+9);
+
+ // outter right arc
+ g.setColor(UIManager.getColor("RadioButton.highlight"));
+ g.drawLine(x+2, y+10, x+3, y+10);
+ g.drawLine(x+4, y+11, x+7, y+11);
+ g.drawLine(x+8, y+10, x+9, y+10);
+ g.drawLine(x+10, y+9, x+10, y+8);
+ g.drawLine(x+11, y+7, x+11, y+4);
+ g.drawLine(x+10, y+3, x+10, y+2);
+
+
+ // inner left arc
+ g.setColor(UIManager.getColor("RadioButton.darkShadow"));
+ g.drawLine(x+4, y+1, x+7, y+1);
+ g.drawLine(x+2, y+2, x+3, y+2);
+ g.drawLine(x+8, y+2, x+9, y+2);
+ g.drawLine(x+2, y+3, x+2, y+3);
+ g.drawLine(x+1, y+4, x+1, y+7);
+ g.drawLine(x+2, y+8, x+2, y+8);
+
+
+ // inner right arc
+ g.setColor(UIManager.getColor("RadioButton.light"));
+ g.drawLine(x+2, y+9, x+3, y+9);
+ g.drawLine(x+4, y+10, x+7, y+10);
+ g.drawLine(x+8, y+9, x+9, y+9);
+ g.drawLine(x+9, y+8, x+9, y+8);
+ g.drawLine(x+10, y+7, x+10, y+4);
+ g.drawLine(x+9, y+3, x+9, y+3);
+
+
+ // indicate whether selected or not
+ if (model.isSelected()) {
+ if (model.isEnabled()) {
+ g.setColor(UIManager.getColor("RadioButton.foreground"));
+ } else {
+ g.setColor(UIManager.getColor("RadioButton.shadow"));
+ }
+ g.fillRect(x+4, y+5, 4, 2);
+ g.fillRect(x+5, y+4, 2, 4);
+ }
+ }
+ }
+ }
+
+ public int getIconWidth() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return xp.getSkin(null, Part.BP_RADIOBUTTON).getWidth();
+ } else {
+ return 13;
+ }
+ }
+
+ public int getIconHeight() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return xp.getSkin(null, Part.BP_RADIOBUTTON).getHeight();
+ } else {
+ return 13;
+ }
+ }
+ } // end class RadioButtonIcon
+
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ AbstractButton b = (AbstractButton) c;
+ ButtonModel model = b.getModel();
+ boolean isSelected = model.isSelected();
+ if (isSelected) {
+ y = y - getIconHeight() / 2;
+ g.drawLine(x+9, y+3, x+9, y+3);
+ g.drawLine(x+8, y+4, x+9, y+4);
+ g.drawLine(x+7, y+5, x+9, y+5);
+ g.drawLine(x+6, y+6, x+8, y+6);
+ g.drawLine(x+3, y+7, x+7, y+7);
+ g.drawLine(x+4, y+8, x+6, y+8);
+ g.drawLine(x+5, y+9, x+5, y+9);
+ g.drawLine(x+3, y+5, x+3, y+5);
+ g.drawLine(x+3, y+6, x+4, y+6);
+ }
+ }
+ public int getIconWidth() { return 9; }
+ public int getIconHeight() { return 9; }
+
+ } // End class CheckBoxMenuItemIcon
+
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
+ {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ AbstractButton b = (AbstractButton) c;
+ ButtonModel model = b.getModel();
+ if (b.isSelected() == true) {
+ g.fillRoundRect(x+3,y+3, getIconWidth()-6, getIconHeight()-6,
+ 4, 4);
+ }
+ }
+ public int getIconWidth() { return 12; }
+ public int getIconHeight() { return 12; }
+
+ } // End class RadioButtonMenuItemIcon
+
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class MenuItemCheckIcon implements Icon, UIResource, Serializable{
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ /* For debugging:
+ Color oldColor = g.getColor();
+ g.setColor(Color.orange);
+ g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
+ g.setColor(oldColor);
+ */
+ }
+ public int getIconWidth() { return 9; }
+ public int getIconHeight() { return 9; }
+
+ } // End class MenuItemCheckIcon
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class MenuItemArrowIcon implements Icon, UIResource, Serializable {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ /* For debugging:
+ Color oldColor = g.getColor();
+ g.setColor(Color.green);
+ g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
+ g.setColor(oldColor);
+ */
+ }
+ public int getIconWidth() { return 4; }
+ public int getIconHeight() { return 8; }
+
+ } // End class MenuItemArrowIcon
+
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class MenuArrowIcon implements Icon, UIResource, Serializable {
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ State state = State.NORMAL;
+ if (c instanceof JMenuItem) {
+ state = ((JMenuItem) c).getModel().isEnabled()
+ ? State.NORMAL : State.DISABLED;
+ }
+ Skin skin = xp.getSkin(c, Part.MP_POPUPSUBMENU);
+ if (WindowsGraphicsUtils.isLeftToRight(c)) {
+ skin.paintSkin(g, x, y, state);
+ } else {
+ Graphics2D g2d = (Graphics2D)g.create();
+ g2d.translate(x + skin.getWidth(), y);
+ g2d.scale(-1, 1);
+ skin.paintSkin(g2d, 0, 0, state);
+ g2d.dispose();
+ }
+ } else {
+ g.translate(x,y);
+ if( WindowsGraphicsUtils.isLeftToRight(c) ) {
+ g.drawLine( 0, 0, 0, 7 );
+ g.drawLine( 1, 1, 1, 6 );
+ g.drawLine( 2, 2, 2, 5 );
+ g.drawLine( 3, 3, 3, 4 );
+ } else {
+ g.drawLine( 4, 0, 4, 7 );
+ g.drawLine( 3, 1, 3, 6 );
+ g.drawLine( 2, 2, 2, 5 );
+ g.drawLine( 1, 3, 1, 4 );
+ }
+ g.translate(-x,-y);
+ }
+ }
+ public int getIconWidth() {
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
+ return skin.getWidth();
+ } else {
+ return 4;
+ }
+ }
+ public int getIconHeight() {
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
+ return skin.getHeight();
+ } else {
+ return 8;
+ }
+ }
+ } // End class MenuArrowIcon
+
+ static class VistaMenuItemCheckIconFactory
+ implements MenuItemCheckIconFactory {
+ private static final int OFFSET = 3;
+
+ public Icon getIcon(JMenuItem component) {
+ return new VistaMenuItemCheckIcon(component);
+ }
+
+ public boolean isCompatible(Object icon, String prefix) {
+ return icon instanceof VistaMenuItemCheckIcon
+ && ((VistaMenuItemCheckIcon) icon).type == getType(prefix);
+ }
+
+ public Icon getIcon(String type) {
+ return new VistaMenuItemCheckIcon(type);
+ }
+
+ static int getIconWidth() {
+ XPStyle xp = XPStyle.getXP();
+ return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16)
+ + 2 * OFFSET;
+ }
+
+ private static Class<? extends JMenuItem> getType(Component c) {
+ Class<? extends JMenuItem> rv = null;
+ if (c instanceof JCheckBoxMenuItem) {
+ rv = JCheckBoxMenuItem.class;
+ } else if (c instanceof JRadioButtonMenuItem) {
+ rv = JRadioButtonMenuItem.class;
+ } else if (c instanceof JMenu) {
+ rv = JMenu.class;
+ } else if (c instanceof JMenuItem) {
+ rv = JMenuItem.class;
+ }
+ return rv;
+ }
+
+ private static Class<? extends JMenuItem> getType(String type) {
+ Class<? extends JMenuItem> rv = null;
+ if (type == "CheckBoxMenuItem") {
+ rv = JCheckBoxMenuItem.class;
+ } else if (type == "RadioButtonMenuItem") {
+ rv = JRadioButtonMenuItem.class;
+ } else if (type == "Menu") {
+ rv = JMenu.class;
+ } else if (type == "MenuItem") {
+ rv = JMenuItem.class;
+ } else {
+ // this should never happen
+ rv = JMenuItem.class;
+ }
+ return rv;
+ }
+
+ /**
+ * CheckIcon for JMenuItem, JMenu, JCheckBoxMenuItem and
+ * JRadioButtonMenuItem.
+ * Note: to be used on Vista only.
+ */
+ @SuppressWarnings("serial") // Same-version serialization only
+ private static class VistaMenuItemCheckIcon
+ implements Icon, UIResource, Serializable {
+
+ private final JMenuItem menuItem;
+ private final Class<? extends JMenuItem> type;
+
+ VistaMenuItemCheckIcon(JMenuItem menuItem) {
+ this.type = getType(menuItem);
+ this.menuItem = menuItem;
+ }
+ VistaMenuItemCheckIcon(String type) {
+ this.type = getType(type);
+ this.menuItem = null;
+ }
+
+ public int getIconHeight() {
+ Icon lafIcon = getLaFIcon();
+ if (lafIcon != null) {
+ return lafIcon.getIconHeight();
+ }
+ Icon icon = getIcon();
+ int height = 0;
+ if (icon != null) {
+ height = icon.getIconHeight();
+ } else {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK);
+ height = skin.getHeight();
+ } else {
+ height = 16;
+ }
+ }
+ height += 2 * OFFSET;
+ return height;
+ }
+
+ public int getIconWidth() {
+ Icon lafIcon = getLaFIcon();
+ if (lafIcon != null) {
+ return lafIcon.getIconWidth();
+ }
+ Icon icon = getIcon();
+ int width = 0;
+ if (icon != null) {
+ width = icon.getIconWidth() + 2 * OFFSET;
+ } else {
+ width = VistaMenuItemCheckIconFactory.getIconWidth();
+ }
+ return width;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Icon lafIcon = getLaFIcon();
+ if (lafIcon != null) {
+ lafIcon.paintIcon(c, g, x, y);
+ return;
+ }
+ assert menuItem == null || c == menuItem;
+ Icon icon = getIcon();
+ if (type == JCheckBoxMenuItem.class
+ || type == JRadioButtonMenuItem.class) {
+ AbstractButton b = (AbstractButton) c;
+ if (b.isSelected()) {
+ Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
+ Part part = Part.MP_POPUPCHECK;
+ State backgroundState;
+ State state;
+ if (isEnabled(c, null)) {
+ backgroundState =
+ (icon != null) ? State.BITMAP : State.NORMAL;
+ state = (type == JRadioButtonMenuItem.class)
+ ? State.BULLETNORMAL
+ : State.CHECKMARKNORMAL;
+ } else {
+ backgroundState = State.DISABLEDPUSHED;
+ state =
+ (type == JRadioButtonMenuItem.class)
+ ? State.BULLETDISABLED
+ : State.CHECKMARKDISABLED;
+ }
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin;
+ skin = xp.getSkin(c, backgroundPart);
+ skin.paintSkin(g, x, y,
+ getIconWidth(), getIconHeight(), backgroundState);
+ if (icon == null) {
+ skin = xp.getSkin(c, part);
+ skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
+ }
+ }
+ }
+ }
+ if (icon != null) {
+ icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
+ }
+ }
+ private static WindowsMenuItemUIAccessor getAccessor(
+ JMenuItem menuItem) {
+ WindowsMenuItemUIAccessor rv = null;
+ ButtonUI uiObject = (menuItem != null) ? menuItem.getUI()
+ : null;
+ if (uiObject instanceof WindowsMenuItemUI) {
+ rv = ((WindowsMenuItemUI) uiObject).accessor;
+ } else if (uiObject instanceof WindowsMenuUI) {
+ rv = ((WindowsMenuUI) uiObject).accessor;
+ } else if (uiObject instanceof WindowsCheckBoxMenuItemUI) {
+ rv = ((WindowsCheckBoxMenuItemUI) uiObject).accessor;
+ } else if (uiObject instanceof WindowsRadioButtonMenuItemUI) {
+ rv = ((WindowsRadioButtonMenuItemUI) uiObject).accessor;
+ }
+ return rv;
+ }
+
+ private static boolean isEnabled(Component c, State state) {
+ if (state == null && c instanceof JMenuItem) {
+ WindowsMenuItemUIAccessor accessor =
+ getAccessor((JMenuItem) c);
+ if (accessor != null) {
+ state = accessor.getState((JMenuItem) c);
+ }
+ }
+ if (state == null) {
+ if (c != null) {
+ return c.isEnabled();
+ } else {
+ return true;
+ }
+ } else {
+ return (state != State.DISABLED)
+ && (state != State.DISABLEDHOT)
+ && (state != State.DISABLEDPUSHED);
+ }
+ }
+ private Icon getIcon() {
+ Icon rv = null;
+ if (menuItem == null) {
+ return rv;
+ }
+ WindowsMenuItemUIAccessor accessor =
+ getAccessor(menuItem);
+ State state = (accessor != null) ? accessor.getState(menuItem)
+ : null;
+ if (isEnabled(menuItem, null)) {
+ if (state == State.PUSHED) {
+ rv = menuItem.getPressedIcon();
+ } else {
+ rv = menuItem.getIcon();
+ }
+ } else {
+ rv = menuItem.getDisabledIcon();
+ }
+ return rv;
+ }
+ /**
+ * Check if developer changed icon in the UI table.
+ *
+ * @return the icon to use or {@code null} if the current one is to
+ * be used
+ */
+ private Icon getLaFIcon() {
+ // use icon from the UI table if it does not match this one.
+ Icon rv = (Icon) UIManager.getDefaults().get(typeToString(type));
+ if (rv instanceof VistaMenuItemCheckIcon
+ && ((VistaMenuItemCheckIcon) rv).type == type) {
+ rv = null;
+ }
+ return rv;
+ }
+
+ private static String typeToString(
+ Class<? extends JMenuItem> type) {
+ assert type == JMenuItem.class
+ || type == JMenu.class
+ || type == JCheckBoxMenuItem.class
+ || type == JRadioButtonMenuItem.class;
+ StringBuilder sb = new StringBuilder(type.getName());
+ // remove package name, dot and the first character
+ sb.delete(0, sb.lastIndexOf("J") + 1);
+ sb.append(".checkIcon");
+ return sb.toString();
+ }
+ }
+ } // End class VistaMenuItemCheckIconFactory
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,572 @@
+/*
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.swing.SwingUtilities2;
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.UIManager;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+@SuppressWarnings("serial") // Superclass is not serializable across versions
+public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
+ private Color selectedTitleGradientColor;
+ private Color notSelectedTitleGradientColor;
+ private JPopupMenu systemPopupMenu;
+ private JLabel systemLabel;
+
+ private Font titleFont;
+ private int titlePaneHeight;
+ private int buttonWidth, buttonHeight;
+ private boolean hotTrackingOn;
+
+ public WindowsInternalFrameTitlePane(JInternalFrame f) {
+ super(f);
+ }
+
+ protected void addSubComponents() {
+ add(systemLabel);
+ add(iconButton);
+ add(maxButton);
+ add(closeButton);
+ }
+
+ protected void installDefaults() {
+ super.installDefaults();
+
+ titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
+ buttonWidth = UIManager.getInt("InternalFrame.titleButtonWidth") - 4;
+ buttonHeight = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
+
+ Object obj = UIManager.get("InternalFrame.titleButtonToolTipsOn");
+ hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
+
+
+ if (XPStyle.getXP() != null) {
+ // Fix for XP bug where sometimes these sizes aren't updated properly
+ // Assume for now that height is correct and derive width using the
+ // ratio from the uxtheme part
+ buttonWidth = buttonHeight;
+ Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
+ if (d != null && d.width != 0 && d.height != 0) {
+ buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
+ }
+ } else {
+ buttonWidth += 2;
+ Color activeBorderColor =
+ UIManager.getColor("InternalFrame.activeBorderColor");
+ setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
+ }
+ // JDK-8039383: initialize these colors because getXP() may return null when theme is changed
+ selectedTitleGradientColor =
+ UIManager.getColor("InternalFrame.activeTitleGradient");
+ notSelectedTitleGradientColor =
+ UIManager.getColor("InternalFrame.inactiveTitleGradient");
+ }
+
+ protected void uninstallListeners() {
+ // Get around protected method in superclass
+ super.uninstallListeners();
+ }
+
+ protected void createButtons() {
+ super.createButtons();
+ if (XPStyle.getXP() != null) {
+ iconButton.setContentAreaFilled(false);
+ maxButton.setContentAreaFilled(false);
+ closeButton.setContentAreaFilled(false);
+ }
+ }
+
+ protected void setButtonIcons() {
+ super.setButtonIcons();
+
+ if (!hotTrackingOn) {
+ iconButton.setToolTipText(null);
+ maxButton.setToolTipText(null);
+ closeButton.setToolTipText(null);
+ }
+ }
+
+
+ public void paintComponent(Graphics g) {
+ XPStyle xp = XPStyle.getXP();
+
+ paintTitleBackground(g);
+
+ String title = frame.getTitle();
+ if (title != null) {
+ boolean isSelected = frame.isSelected();
+ Font oldFont = g.getFont();
+ Font newFont = (titleFont != null) ? titleFont : getFont();
+ g.setFont(newFont);
+
+ // Center text vertically.
+ FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, newFont);
+ int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
+ fm.getDescent()) / 2;
+
+ Rectangle lastIconBounds = new Rectangle(0, 0, 0, 0);
+ if (frame.isIconifiable()) {
+ lastIconBounds = iconButton.getBounds();
+ } else if (frame.isMaximizable()) {
+ lastIconBounds = maxButton.getBounds();
+ } else if (frame.isClosable()) {
+ lastIconBounds = closeButton.getBounds();
+ }
+
+ int titleX;
+ int titleW;
+ int gap = 2;
+ if (WindowsGraphicsUtils.isLeftToRight(frame)) {
+ if (lastIconBounds.x == 0) { // There are no icons
+ lastIconBounds.x = frame.getWidth() - frame.getInsets().right;
+ }
+ titleX = systemLabel.getX() + systemLabel.getWidth() + gap;
+ if (xp != null) {
+ titleX += 2;
+ }
+ titleW = lastIconBounds.x - titleX - gap;
+ } else {
+ if (lastIconBounds.x == 0) { // There are no icons
+ lastIconBounds.x = frame.getInsets().left;
+ }
+ titleW = SwingUtilities2.stringWidth(frame, fm, title);
+ int minTitleX = lastIconBounds.x + lastIconBounds.width + gap;
+ if (xp != null) {
+ minTitleX += 2;
+ }
+ int availableWidth = systemLabel.getX() - gap - minTitleX;
+ if (availableWidth > titleW) {
+ titleX = systemLabel.getX() - gap - titleW;
+ } else {
+ titleX = minTitleX;
+ titleW = availableWidth;
+ }
+ }
+ title = getTitle(frame.getTitle(), fm, titleW);
+
+ if (xp != null) {
+ String shadowType = null;
+ if (isSelected) {
+ shadowType = xp.getString(this, Part.WP_CAPTION,
+ State.ACTIVE, Prop.TEXTSHADOWTYPE);
+ }
+ if ("single".equalsIgnoreCase(shadowType)) {
+ Point shadowOffset = xp.getPoint(this, Part.WP_WINDOW, State.ACTIVE,
+ Prop.TEXTSHADOWOFFSET);
+ Color shadowColor = xp.getColor(this, Part.WP_WINDOW, State.ACTIVE,
+ Prop.TEXTSHADOWCOLOR, null);
+ if (shadowOffset != null && shadowColor != null) {
+ g.setColor(shadowColor);
+ SwingUtilities2.drawString(frame, g, title,
+ titleX + shadowOffset.x,
+ baseline + shadowOffset.y);
+ }
+ }
+ }
+ g.setColor(isSelected ? selectedTextColor : notSelectedTextColor);
+ SwingUtilities2.drawString(frame, g, title, titleX, baseline);
+ g.setFont(oldFont);
+ }
+ }
+
+ public Dimension getPreferredSize() {
+ return getMinimumSize();
+ }
+
+ public Dimension getMinimumSize() {
+ Dimension d = new Dimension(super.getMinimumSize());
+ d.height = titlePaneHeight + 2;
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ // Note: Don't know how to calculate height on XP,
+ // the captionbarheight is 25 but native caption is 30 (maximized 26)
+ if (frame.isMaximum()) {
+ d.height -= 1;
+ } else {
+ d.height += 3;
+ }
+ }
+ return d;
+ }
+
+ protected void paintTitleBackground(Graphics g) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Part part = frame.isIcon() ? Part.WP_MINCAPTION
+ : (frame.isMaximum() ? Part.WP_MAXCAPTION
+ : Part.WP_CAPTION);
+ State state = frame.isSelected() ? State.ACTIVE : State.INACTIVE;
+ Skin skin = xp.getSkin(this, part);
+ skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
+ } else {
+ Boolean gradientsOn = (Boolean)LookAndFeel.getDesktopPropertyValue(
+ "win.frame.captionGradientsOn", Boolean.valueOf(false));
+ if (gradientsOn.booleanValue() && g instanceof Graphics2D) {
+ Graphics2D g2 = (Graphics2D)g;
+ Paint savePaint = g2.getPaint();
+
+ boolean isSelected = frame.isSelected();
+ int w = getWidth();
+
+ if (isSelected) {
+ GradientPaint titleGradient = new GradientPaint(0,0,
+ selectedTitleColor,
+ (int)(w*.75),0,
+ selectedTitleGradientColor);
+ g2.setPaint(titleGradient);
+ } else {
+ GradientPaint titleGradient = new GradientPaint(0,0,
+ notSelectedTitleColor,
+ (int)(w*.75),0,
+ notSelectedTitleGradientColor);
+ g2.setPaint(titleGradient);
+ }
+ g2.fillRect(0, 0, getWidth(), getHeight());
+ g2.setPaint(savePaint);
+ } else {
+ super.paintTitleBackground(g);
+ }
+ }
+ }
+
+ protected void assembleSystemMenu() {
+ systemPopupMenu = new JPopupMenu();
+ addSystemMenuItems(systemPopupMenu);
+ enableActions();
+ @SuppressWarnings("serial") // anonymous class
+ JLabel tmp = new JLabel(frame.getFrameIcon()) {
+ protected void paintComponent(Graphics g) {
+ int x = 0;
+ int y = 0;
+ int w = getWidth();
+ int h = getHeight();
+ g = g.create(); // Create scratch graphics
+ if (isOpaque()) {
+ g.setColor(getBackground());
+ g.fillRect(0, 0, w, h);
+ }
+ Icon icon = getIcon();
+ int iconWidth;
+ int iconHeight;
+ if (icon != null &&
+ (iconWidth = icon.getIconWidth()) > 0 &&
+ (iconHeight = icon.getIconHeight()) > 0) {
+
+ // Set drawing scale to make icon scale to our desired size
+ double drawScale;
+ if (iconWidth > iconHeight) {
+ // Center icon vertically
+ y = (h - w*iconHeight/iconWidth) / 2;
+ drawScale = w / (double)iconWidth;
+ } else {
+ // Center icon horizontally
+ x = (w - h*iconWidth/iconHeight) / 2;
+ drawScale = h / (double)iconHeight;
+ }
+ ((Graphics2D)g).translate(x, y);
+ ((Graphics2D)g).scale(drawScale, drawScale);
+ icon.paintIcon(this, g, 0, 0);
+ }
+ g.dispose();
+ }
+ };
+ systemLabel = tmp;
+ systemLabel.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2 && frame.isClosable() &&
+ !frame.isIcon()) {
+ systemPopupMenu.setVisible(false);
+ frame.doDefaultCloseAction();
+ }
+ else {
+ super.mouseClicked(e);
+ }
+ }
+ public void mousePressed(MouseEvent e) {
+ try {
+ frame.setSelected(true);
+ } catch(PropertyVetoException pve) {
+ }
+ showSystemPopupMenu(e.getComponent());
+ }
+ });
+ }
+
+ protected void addSystemMenuItems(JPopupMenu menu) {
+ JMenuItem mi = menu.add(restoreAction);
+ mi.setMnemonic(getButtonMnemonic("restore"));
+ mi = menu.add(moveAction);
+ mi.setMnemonic(getButtonMnemonic("move"));
+ mi = menu.add(sizeAction);
+ mi.setMnemonic(getButtonMnemonic("size"));
+ mi = menu.add(iconifyAction);
+ mi.setMnemonic(getButtonMnemonic("minimize"));
+ mi = menu.add(maximizeAction);
+ mi.setMnemonic(getButtonMnemonic("maximize"));
+ menu.add(new JSeparator());
+ mi = menu.add(closeAction);
+ mi.setMnemonic(getButtonMnemonic("close"));
+ }
+
+ private static int getButtonMnemonic(String button) {
+ try {
+ return Integer.parseInt(UIManager.getString(
+ "InternalFrameTitlePane." + button + "Button.mnemonic"));
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ protected void showSystemMenu(){
+ showSystemPopupMenu(systemLabel);
+ }
+
+ private void showSystemPopupMenu(Component invoker){
+ Dimension dim = new Dimension();
+ Border border = frame.getBorder();
+ if (border != null) {
+ dim.width += border.getBorderInsets(frame).left +
+ border.getBorderInsets(frame).right;
+ dim.height += border.getBorderInsets(frame).bottom +
+ border.getBorderInsets(frame).top;
+ }
+ if (!frame.isIcon()) {
+ systemPopupMenu.show(invoker,
+ getX() - dim.width,
+ getY() + getHeight() - dim.height);
+ } else {
+ systemPopupMenu.show(invoker,
+ getX() - dim.width,
+ getY() - systemPopupMenu.getPreferredSize().height -
+ dim.height);
+ }
+ }
+
+ protected PropertyChangeListener createPropertyChangeListener() {
+ return new WindowsPropertyChangeHandler();
+ }
+
+ protected LayoutManager createLayout() {
+ return new WindowsTitlePaneLayout();
+ }
+
+ public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
+ private Insets captionMargin = null;
+ private Insets contentMargin = null;
+ private XPStyle xp = XPStyle.getXP();
+
+ WindowsTitlePaneLayout() {
+ if (xp != null) {
+ Component c = WindowsInternalFrameTitlePane.this;
+ captionMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CAPTIONMARGINS);
+ contentMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CONTENTMARGINS);
+ }
+ if (captionMargin == null) {
+ captionMargin = new Insets(0, 2, 0, 2);
+ }
+ if (contentMargin == null) {
+ contentMargin = new Insets(0, 0, 0, 0);
+ }
+ }
+
+ private int layoutButton(JComponent button, Part part,
+ int x, int y, int w, int h, int gap,
+ boolean leftToRight) {
+ if (!leftToRight) {
+ x -= w;
+ }
+ button.setBounds(x, y, w, h);
+ if (leftToRight) {
+ x += w + 2;
+ } else {
+ x -= 2;
+ }
+ return x;
+ }
+
+ public void layoutContainer(Container c) {
+ boolean leftToRight = WindowsGraphicsUtils.isLeftToRight(frame);
+ int x, y;
+ int w = getWidth();
+ int h = getHeight();
+
+ // System button
+ // Note: this icon is square, but the buttons aren't always.
+ int iconSize = (xp != null) ? (h-2)*6/10 : h-4;
+ if (xp != null) {
+ x = (leftToRight) ? captionMargin.left + 2 : w - captionMargin.right - 2;
+ } else {
+ x = (leftToRight) ? captionMargin.left : w - captionMargin.right;
+ }
+ y = (h - iconSize) / 2;
+ layoutButton(systemLabel, Part.WP_SYSBUTTON,
+ x, y, iconSize, iconSize, 0,
+ leftToRight);
+
+ // Right hand buttons
+ if (xp != null) {
+ x = (leftToRight) ? w - captionMargin.right - 2 : captionMargin.left + 2;
+ y = 1; // XP seems to ignore margins and offset here
+ if (frame.isMaximum()) {
+ y += 1;
+ } else {
+ y += 5;
+ }
+ } else {
+ x = (leftToRight) ? w - captionMargin.right : captionMargin.left;
+ y = (h - buttonHeight) / 2;
+ }
+
+ if(frame.isClosable()) {
+ x = layoutButton(closeButton, Part.WP_CLOSEBUTTON,
+ x, y, buttonWidth, buttonHeight, 2,
+ !leftToRight);
+ }
+
+ if(frame.isMaximizable()) {
+ x = layoutButton(maxButton, Part.WP_MAXBUTTON,
+ x, y, buttonWidth, buttonHeight, (xp != null) ? 2 : 0,
+ !leftToRight);
+ }
+
+ if(frame.isIconifiable()) {
+ layoutButton(iconButton, Part.WP_MINBUTTON,
+ x, y, buttonWidth, buttonHeight, 0,
+ !leftToRight);
+ }
+ }
+ } // end WindowsTitlePaneLayout
+
+ public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
+ public void propertyChange(PropertyChangeEvent evt) {
+ String prop = evt.getPropertyName();
+
+ // Update the internal frame icon for the system menu.
+ if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
+ systemLabel != null) {
+ systemLabel.setIcon(frame.getFrameIcon());
+ }
+
+ super.propertyChange(evt);
+ }
+ }
+
+ /**
+ * A versatile Icon implementation which can take an array of Icon
+ * instances (typically <code>ImageIcon</code>s) and choose one that gives the best
+ * quality for a given Graphics2D scale factor when painting.
+ * <p>
+ * The class is public so it can be instantiated by UIDefaults.ProxyLazyValue.
+ * <p>
+ * Note: We assume here that icons are square.
+ */
+ public static class ScalableIconUIResource implements Icon, UIResource {
+ // We can use an arbitrary size here because we scale to it in paintIcon()
+ private static final int SIZE = 16;
+
+ private Icon[] icons;
+
+ /**
+ * @param objects an array of Icon or UIDefaults.LazyValue
+ * <p>
+ * The constructor is public so it can be called by UIDefaults.ProxyLazyValue.
+ */
+ public ScalableIconUIResource(Object[] objects) {
+ this.icons = new Icon[objects.length];
+
+ for (int i = 0; i < objects.length; i++) {
+ if (objects[i] instanceof UIDefaults.LazyValue) {
+ icons[i] = (Icon)((UIDefaults.LazyValue)objects[i]).createValue(null);
+ } else {
+ icons[i] = (Icon)objects[i];
+ }
+ }
+ }
+
+ /**
+ * @return the <code>Icon</code> closest to the requested size
+ */
+ protected Icon getBestIcon(int size) {
+ if (icons != null && icons.length > 0) {
+ int bestIndex = 0;
+ int minDiff = Integer.MAX_VALUE;
+ for (int i=0; i < icons.length; i++) {
+ Icon icon = icons[i];
+ int iconSize;
+ if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
+ int diff = Math.abs(iconSize - size);
+ if (diff < minDiff) {
+ minDiff = diff;
+ bestIndex = i;
+ }
+ }
+ }
+ return icons[bestIndex];
+ } else {
+ return null;
+ }
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Graphics2D g2d = (Graphics2D)g.create();
+ // Calculate how big our drawing area is in pixels
+ // Assume we are square
+ int size = getIconWidth();
+ double scale = g2d.getTransform().getScaleX();
+ Icon icon = getBestIcon((int)(size * scale));
+ int iconSize;
+ if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
+ // Set drawing scale to make icon act true to our reported size
+ double drawScale = size / (double)iconSize;
+ g2d.translate(x, y);
+ g2d.scale(drawScale, drawScale);
+ icon.paintIcon(c, g2d, 0, 0);
+ }
+ g2d.dispose();
+ }
+
+ public int getIconWidth() {
+ return SIZE;
+ }
+
+ public int getIconHeight() {
+ return SIZE;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.beans.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.ComponentUI;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsInternalFrameUI extends BasicInternalFrameUI
+{
+ XPStyle xp = XPStyle.getXP();
+
+ public void installDefaults() {
+ super.installDefaults();
+
+ if (xp != null) {
+ frame.setBorder(new XPBorder());
+ } else {
+ frame.setBorder(UIManager.getBorder("InternalFrame.border"));
+ }
+ }
+
+ public void installUI(JComponent c) {
+ super.installUI(c);
+
+ LookAndFeel.installProperty(c, "opaque",
+ xp == null? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public void uninstallDefaults() {
+ frame.setBorder(null);
+ super.uninstallDefaults();
+ }
+
+ public static ComponentUI createUI(JComponent b) {
+ return new WindowsInternalFrameUI((JInternalFrame)b);
+ }
+
+ public WindowsInternalFrameUI(JInternalFrame w){
+ super(w);
+ }
+
+ protected DesktopManager createDesktopManager(){
+ return new WindowsDesktopManager();
+ }
+
+ protected JComponent createNorthPane(JInternalFrame w) {
+ titlePane = new WindowsInternalFrameTitlePane(w);
+ return titlePane;
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPBorder extends AbstractBorder {
+ private Skin leftSkin = xp.getSkin(frame, Part.WP_FRAMELEFT);
+ private Skin rightSkin = xp.getSkin(frame, Part.WP_FRAMERIGHT);
+ private Skin bottomSkin = xp.getSkin(frame, Part.WP_FRAMEBOTTOM);
+
+ /**
+ * @param x the x position of the painted border
+ * @param y the y position of the painted border
+ * @param width the width of the painted border
+ * @param height the height of the painted border
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ State state = ((JInternalFrame)c).isSelected() ? State.ACTIVE : State.INACTIVE;
+ int topBorderHeight = (titlePane != null) ? titlePane.getSize().height : 0;
+
+ bottomSkin.paintSkin(g, 0, height-bottomSkin.getHeight(),
+ width, bottomSkin.getHeight(),
+ state);
+
+ leftSkin.paintSkin(g, 0, topBorderHeight-1,
+ leftSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
+ state);
+
+ rightSkin.paintSkin(g, width-rightSkin.getWidth(), topBorderHeight-1,
+ rightSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
+ state);
+
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ insets.top = 4;
+ insets.left = leftSkin.getWidth();
+ insets.right = rightSkin.getWidth();
+ insets.bottom = bottomSkin.getHeight();
+
+ return insets;
+ }
+
+ public boolean isBorderOpaque() {
+ return true;
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.UIManager;
+
+import javax.swing.plaf.ComponentUI;
+
+import javax.swing.plaf.basic.BasicLabelUI;
+
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsLabelUI extends BasicLabelUI {
+
+ private static final Object WINDOWS_LABEL_UI_KEY = new Object();
+
+ // ********************************
+ // Create PLAF
+ // ********************************
+ public static ComponentUI createUI(JComponent c) {
+ AppContext appContext = AppContext.getAppContext();
+ WindowsLabelUI windowsLabelUI =
+ (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
+ if (windowsLabelUI == null) {
+ windowsLabelUI = new WindowsLabelUI();
+ appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
+ }
+ return windowsLabelUI;
+ }
+
+ protected void paintEnabledText(JLabel l, Graphics g, String s,
+ int textX, int textY) {
+ int mnemonicIndex = l.getDisplayedMnemonicIndex();
+ // W2K Feature: Check to see if the Underscore should be rendered.
+ if (WindowsLookAndFeel.isMnemonicHidden() == true) {
+ mnemonicIndex = -1;
+ }
+
+ g.setColor(l.getForeground());
+ SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
+ textX, textY);
+ }
+
+ protected void paintDisabledText(JLabel l, Graphics g, String s,
+ int textX, int textY) {
+ int mnemonicIndex = l.getDisplayedMnemonicIndex();
+ // W2K Feature: Check to see if the Underscore should be rendered.
+ if (WindowsLookAndFeel.isMnemonicHidden() == true) {
+ mnemonicIndex = -1;
+ }
+ if ( UIManager.getColor("Label.disabledForeground") instanceof Color &&
+ UIManager.getColor("Label.disabledShadow") instanceof Color) {
+ g.setColor( UIManager.getColor("Label.disabledShadow") );
+ SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
+ mnemonicIndex,
+ textX + 1, textY + 1);
+ g.setColor( UIManager.getColor("Label.disabledForeground") );
+ SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
+ mnemonicIndex,
+ textX, textY);
+ } else {
+ Color background = l.getBackground();
+ g.setColor(background.brighter());
+ SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
+ textX + 1, textY + 1);
+ g.setColor(background.darker());
+ SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
+ textX, textY);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,2588 @@
+/*
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * <p>These classes are designed to be used while the
+ * corresponding <code>LookAndFeel</code> class has been installed
+ * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
+ * Using them while a different <code>LookAndFeel</code> is installed
+ * may produce unexpected results, including exceptions.
+ * Additionally, changing the <code>LookAndFeel</code>
+ * maintained by the <code>UIManager</code> without updating the
+ * corresponding <code>ComponentUI</code> of any
+ * <code>JComponent</code>s may also produce unexpected results,
+ * such as the wrong colors showing up, and is generally not
+ * encouraged.
+ *
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageFilter;
+import java.awt.image.ImageProducer;
+import java.awt.image.FilteredImageSource;
+import java.awt.image.RGBImageFilter;
+
+import javax.swing.plaf.*;
+import javax.swing.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.border.*;
+import javax.swing.text.DefaultEditorKit;
+import static javax.swing.UIDefaults.LazyValue;
+
+import java.awt.Font;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+
+import java.security.AccessController;
+
+import sun.awt.SunToolkit;
+import sun.awt.OSInfo;
+import sun.awt.shell.ShellFolder;
+import sun.font.FontUtilities;
+import sun.security.action.GetPropertyAction;
+
+import sun.swing.DefaultLayoutStyle;
+import sun.swing.ImageIconUIResource;
+import sun.swing.SwingAccessor;
+import sun.swing.icon.SortArrowIcon;
+import sun.swing.SwingUtilities2;
+import sun.swing.StringUIClientPropertyKey;
+import sun.swing.plaf.windows.ClassicSortArrowIcon;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+import com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory;
+
+/**
+ * Implements the Windows95/98/NT/2000 Look and Feel.
+ * UI classes not implemented specifically for Windows will
+ * default to those implemented in Basic.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author unattributed
+ */
+@SuppressWarnings("serial") // Superclass is not serializable across versions
+public class WindowsLookAndFeel extends BasicLookAndFeel
+{
+ /**
+ * A client property that can be used with any JComponent that will end up
+ * calling the LookAndFeel.getDisabledIcon method. This client property,
+ * when set to Boolean.TRUE, will cause getDisabledIcon to use an
+ * alternate algorithm for creating disabled icons to produce icons
+ * that appear similar to the native Windows file chooser
+ */
+ static final Object HI_RES_DISABLED_ICON_CLIENT_KEY =
+ new StringUIClientPropertyKey(
+ "WindowsLookAndFeel.generateHiResDisabledIcon");
+
+ private boolean updatePending = false;
+
+ private boolean useSystemFontSettings = true;
+ private boolean useSystemFontSizeSettings;
+
+ // These properties are not used directly, but are kept as
+ // private members to avoid being GC'd.
+ private WindowsDesktopProperty themeActive, dllName, colorName, sizeName;
+ private WindowsDesktopProperty aaSettings;
+
+ private transient LayoutStyle style;
+
+ /**
+ * Base dialog units along the horizontal axis.
+ */
+ private int baseUnitX;
+
+ /**
+ * Base dialog units along the vertical axis.
+ */
+ private int baseUnitY;
+
+ public String getName() {
+ return "Windows";
+ }
+
+ public String getDescription() {
+ return "The Microsoft Windows Look and Feel";
+ }
+
+ public String getID() {
+ return "Windows";
+ }
+
+ public boolean isNativeLookAndFeel() {
+ return OSInfo.getOSType() == OSInfo.OSType.WINDOWS;
+ }
+
+ public boolean isSupportedLookAndFeel() {
+ return isNativeLookAndFeel();
+ }
+
+ public void initialize() {
+ super.initialize();
+
+ // Set the flag which determines which version of Windows should
+ // be rendered. This flag only need to be set once.
+ // if version <= 4.0 then the classic LAF should be loaded.
+ if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
+ isClassicWindows = true;
+ } else {
+ isClassicWindows = false;
+ XPStyle.invalidateStyle();
+ }
+
+ // Using the fonts set by the user can potentially cause
+ // performance and compatibility issues, so allow this feature
+ // to be switched off either at runtime or programmatically
+ //
+ String systemFonts = java.security.AccessController.doPrivileged(
+ new GetPropertyAction("swing.useSystemFontSettings"));
+ useSystemFontSettings = (systemFonts == null ||
+ Boolean.valueOf(systemFonts).booleanValue());
+
+ if (useSystemFontSettings) {
+ Object value = UIManager.get("Application.useSystemFontSettings");
+
+ useSystemFontSettings = (value == null ||
+ Boolean.TRUE.equals(value));
+ }
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().
+ addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
+
+ }
+
+ /**
+ * Initialize the uiClassID to BasicComponentUI mapping.
+ * The JComponent classes define their own uiClassID constants
+ * (see AbstractComponent.getUIClassID). This table must
+ * map those constants to a BasicComponentUI class of the
+ * appropriate type.
+ *
+ * @see BasicLookAndFeel#getDefaults
+ */
+ protected void initClassDefaults(UIDefaults table)
+ {
+ super.initClassDefaults(table);
+
+ final String windowsPackageName = "com.sun.java.swing.plaf.windows.";
+
+ Object[] uiDefaults = {
+ "ButtonUI", windowsPackageName + "WindowsButtonUI",
+ "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI",
+ "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI",
+ "LabelUI", windowsPackageName + "WindowsLabelUI",
+ "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI",
+ "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI",
+ "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI",
+ "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI",
+ "SliderUI", windowsPackageName + "WindowsSliderUI",
+ "SeparatorUI", windowsPackageName + "WindowsSeparatorUI",
+ "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI",
+ "SpinnerUI", windowsPackageName + "WindowsSpinnerUI",
+ "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI",
+ "TextAreaUI", windowsPackageName + "WindowsTextAreaUI",
+ "TextFieldUI", windowsPackageName + "WindowsTextFieldUI",
+ "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI",
+ "TextPaneUI", windowsPackageName + "WindowsTextPaneUI",
+ "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI",
+ "TreeUI", windowsPackageName + "WindowsTreeUI",
+ "ToolBarUI", windowsPackageName + "WindowsToolBarUI",
+ "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI",
+ "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI",
+ "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI",
+ "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI",
+ "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI",
+ "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI",
+ "FileChooserUI", windowsPackageName + "WindowsFileChooserUI",
+ "MenuUI", windowsPackageName + "WindowsMenuUI",
+ "MenuItemUI", windowsPackageName + "WindowsMenuItemUI",
+ "MenuBarUI", windowsPackageName + "WindowsMenuBarUI",
+ "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI",
+ "PopupMenuSeparatorUI", windowsPackageName + "WindowsPopupMenuSeparatorUI",
+ "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI",
+ "RootPaneUI", windowsPackageName + "WindowsRootPaneUI"
+ };
+
+ table.putDefaults(uiDefaults);
+ }
+
+ /**
+ * Load the SystemColors into the defaults table. The keys
+ * for SystemColor defaults are the same as the names of
+ * the public fields in SystemColor. If the table is being
+ * created on a native Windows platform we use the SystemColor
+ * values, otherwise we create color objects whose values match
+ * the defaults Windows95 colors.
+ */
+ protected void initSystemColorDefaults(UIDefaults table)
+ {
+ String[] defaultSystemColors = {
+ "desktop", "#005C5C", /* Color of the desktop background */
+ "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
+ "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
+ "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
+ "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
+ "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
+ "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
+ "window", "#FFFFFF", /* Default color for the interior of windows */
+ "windowBorder", "#000000", /* ??? */
+ "windowText", "#000000", /* ??? */
+ "menu", "#C0C0C0", /* Background color for menus */
+ "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */
+ "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */
+ "menuText", "#000000", /* Text color for menus */
+ "text", "#C0C0C0", /* Text background color */
+ "textText", "#000000", /* Text foreground color */
+ "textHighlight", "#000080", /* Text background color when selected */
+ "textHighlightText", "#FFFFFF", /* Text color when selected */
+ "textInactiveText", "#808080", /* Text color when disabled */
+ "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
+ "controlText", "#000000", /* Default color for text in controls */
+ "controlHighlight", "#C0C0C0",
+
+ /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */
+ "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
+ "controlShadow", "#808080", /* Shadow color for controls */
+ "controlDkShadow", "#000000", /* Dark shadow color for controls */
+ "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
+ "info", "#FFFFE1", /* ??? */
+ "infoText", "#000000" /* ??? */
+ };
+
+ loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
+ }
+
+ /**
+ * Initialize the defaults table with the name of the ResourceBundle
+ * used for getting localized defaults.
+ */
+ private void initResourceBundle(UIDefaults table) {
+ SwingAccessor.getUIDefaultsAccessor()
+ .addInternalBundle(table,
+ "com.sun.java.swing.plaf.windows.resources.windows");
+ }
+
+ // XXX - there are probably a lot of redundant values that could be removed.
+ // ie. Take a look at RadioButtonBorder, etc...
+ protected void initComponentDefaults(UIDefaults table)
+ {
+ super.initComponentDefaults( table );
+
+ initResourceBundle(table);
+
+ // *** Shared Fonts
+ LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
+
+ LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
+ LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
+ LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
+
+ // *** Colors
+ // XXX - some of these doens't seem to be used
+ ColorUIResource red = new ColorUIResource(Color.red);
+ ColorUIResource black = new ColorUIResource(Color.black);
+ ColorUIResource white = new ColorUIResource(Color.white);
+ ColorUIResource gray = new ColorUIResource(Color.gray);
+ ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
+ ColorUIResource scrollBarTrackHighlight = darkGray;
+
+ // Set the flag which determines which version of Windows should
+ // be rendered. This flag only need to be set once.
+ // if version <= 4.0 then the classic LAF should be loaded.
+ isClassicWindows = OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0;
+
+ // *** Tree
+ Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon();
+
+ Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon();
+
+
+ // *** Text
+ Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
+ "control C", DefaultEditorKit.copyAction,
+ "control V", DefaultEditorKit.pasteAction,
+ "control X", DefaultEditorKit.cutAction,
+ "COPY", DefaultEditorKit.copyAction,
+ "PASTE", DefaultEditorKit.pasteAction,
+ "CUT", DefaultEditorKit.cutAction,
+ "control INSERT", DefaultEditorKit.copyAction,
+ "shift INSERT", DefaultEditorKit.pasteAction,
+ "shift DELETE", DefaultEditorKit.cutAction,
+ "control A", DefaultEditorKit.selectAllAction,
+ "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
+ "shift LEFT", DefaultEditorKit.selectionBackwardAction,
+ "shift RIGHT", DefaultEditorKit.selectionForwardAction,
+ "control LEFT", DefaultEditorKit.previousWordAction,
+ "control RIGHT", DefaultEditorKit.nextWordAction,
+ "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
+ "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
+ "HOME", DefaultEditorKit.beginLineAction,
+ "END", DefaultEditorKit.endLineAction,
+ "shift HOME", DefaultEditorKit.selectionBeginLineAction,
+ "shift END", DefaultEditorKit.selectionEndLineAction,
+ "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "ctrl H", DefaultEditorKit.deletePrevCharAction,
+ "DELETE", DefaultEditorKit.deleteNextCharAction,
+ "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
+ "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
+ "RIGHT", DefaultEditorKit.forwardAction,
+ "LEFT", DefaultEditorKit.backwardAction,
+ "KP_RIGHT", DefaultEditorKit.forwardAction,
+ "KP_LEFT", DefaultEditorKit.backwardAction,
+ "ENTER", JTextField.notifyAction,
+ "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
+ });
+
+ Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
+ "control C", DefaultEditorKit.copyAction,
+ "control V", DefaultEditorKit.pasteAction,
+ "control X", DefaultEditorKit.cutAction,
+ "COPY", DefaultEditorKit.copyAction,
+ "PASTE", DefaultEditorKit.pasteAction,
+ "CUT", DefaultEditorKit.cutAction,
+ "control INSERT", DefaultEditorKit.copyAction,
+ "shift INSERT", DefaultEditorKit.pasteAction,
+ "shift DELETE", DefaultEditorKit.cutAction,
+ "control A", DefaultEditorKit.selectAllAction,
+ "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
+ "shift LEFT", DefaultEditorKit.selectionBackwardAction,
+ "shift RIGHT", DefaultEditorKit.selectionForwardAction,
+ "control LEFT", DefaultEditorKit.beginLineAction,
+ "control RIGHT", DefaultEditorKit.endLineAction,
+ "control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
+ "control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
+ "HOME", DefaultEditorKit.beginLineAction,
+ "END", DefaultEditorKit.endLineAction,
+ "shift HOME", DefaultEditorKit.selectionBeginLineAction,
+ "shift END", DefaultEditorKit.selectionEndLineAction,
+ "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "ctrl H", DefaultEditorKit.deletePrevCharAction,
+ "DELETE", DefaultEditorKit.deleteNextCharAction,
+ "RIGHT", DefaultEditorKit.forwardAction,
+ "LEFT", DefaultEditorKit.backwardAction,
+ "KP_RIGHT", DefaultEditorKit.forwardAction,
+ "KP_LEFT", DefaultEditorKit.backwardAction,
+ "ENTER", JTextField.notifyAction,
+ "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
+ });
+
+ Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
+ "control C", DefaultEditorKit.copyAction,
+ "control V", DefaultEditorKit.pasteAction,
+ "control X", DefaultEditorKit.cutAction,
+ "COPY", DefaultEditorKit.copyAction,
+ "PASTE", DefaultEditorKit.pasteAction,
+ "CUT", DefaultEditorKit.cutAction,
+ "control INSERT", DefaultEditorKit.copyAction,
+ "shift INSERT", DefaultEditorKit.pasteAction,
+ "shift DELETE", DefaultEditorKit.cutAction,
+ "shift LEFT", DefaultEditorKit.selectionBackwardAction,
+ "shift RIGHT", DefaultEditorKit.selectionForwardAction,
+ "control LEFT", DefaultEditorKit.previousWordAction,
+ "control RIGHT", DefaultEditorKit.nextWordAction,
+ "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
+ "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
+ "control A", DefaultEditorKit.selectAllAction,
+ "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
+ "HOME", DefaultEditorKit.beginLineAction,
+ "END", DefaultEditorKit.endLineAction,
+ "shift HOME", DefaultEditorKit.selectionBeginLineAction,
+ "shift END", DefaultEditorKit.selectionEndLineAction,
+ "control HOME", DefaultEditorKit.beginAction,
+ "control END", DefaultEditorKit.endAction,
+ "control shift HOME", DefaultEditorKit.selectionBeginAction,
+ "control shift END", DefaultEditorKit.selectionEndAction,
+ "UP", DefaultEditorKit.upAction,
+ "DOWN", DefaultEditorKit.downAction,
+ "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "ctrl H", DefaultEditorKit.deletePrevCharAction,
+ "DELETE", DefaultEditorKit.deleteNextCharAction,
+ "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
+ "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
+ "RIGHT", DefaultEditorKit.forwardAction,
+ "LEFT", DefaultEditorKit.backwardAction,
+ "KP_RIGHT", DefaultEditorKit.forwardAction,
+ "KP_LEFT", DefaultEditorKit.backwardAction,
+ "PAGE_UP", DefaultEditorKit.pageUpAction,
+ "PAGE_DOWN", DefaultEditorKit.pageDownAction,
+ "shift PAGE_UP", "selection-page-up",
+ "shift PAGE_DOWN", "selection-page-down",
+ "ctrl shift PAGE_UP", "selection-page-left",
+ "ctrl shift PAGE_DOWN", "selection-page-right",
+ "shift UP", DefaultEditorKit.selectionUpAction,
+ "shift DOWN", DefaultEditorKit.selectionDownAction,
+ "ENTER", DefaultEditorKit.insertBreakAction,
+ "TAB", DefaultEditorKit.insertTabAction,
+ "control T", "next-link-action",
+ "control shift T", "previous-link-action",
+ "control SPACE", "activate-link-action",
+ "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
+ });
+
+ Object menuItemAcceleratorDelimiter = "+";
+
+ Object ControlBackgroundColor = new WindowsDesktopProperty(
+ "win.3d.backgroundColor",
+ table.get("control"));
+ Object ControlLightColor = new WindowsDesktopProperty(
+ "win.3d.lightColor",
+ table.get("controlHighlight"));
+ Object ControlHighlightColor = new WindowsDesktopProperty(
+ "win.3d.highlightColor",
+ table.get("controlLtHighlight"));
+ Object ControlShadowColor = new WindowsDesktopProperty(
+ "win.3d.shadowColor",
+ table.get("controlShadow"));
+ Object ControlDarkShadowColor = new WindowsDesktopProperty(
+ "win.3d.darkShadowColor",
+ table.get("controlDkShadow"));
+ Object ControlTextColor = new WindowsDesktopProperty(
+ "win.button.textColor",
+ table.get("controlText"));
+ Object MenuBackgroundColor = new WindowsDesktopProperty(
+ "win.menu.backgroundColor",
+ table.get("menu"));
+ Object MenuBarBackgroundColor = new WindowsDesktopProperty(
+ "win.menubar.backgroundColor",
+ table.get("menu"));
+ Object MenuTextColor = new WindowsDesktopProperty(
+ "win.menu.textColor",
+ table.get("menuText"));
+ Object SelectionBackgroundColor = new WindowsDesktopProperty(
+ "win.item.highlightColor",
+ table.get("textHighlight"));
+ Object SelectionTextColor = new WindowsDesktopProperty(
+ "win.item.highlightTextColor",
+ table.get("textHighlightText"));
+ Object WindowBackgroundColor = new WindowsDesktopProperty(
+ "win.frame.backgroundColor",
+ table.get("window"));
+ Object WindowTextColor = new WindowsDesktopProperty(
+ "win.frame.textColor",
+ table.get("windowText"));
+ Object WindowBorderWidth = new WindowsDesktopProperty(
+ "win.frame.sizingBorderWidth",
+ Integer.valueOf(1));
+ Object TitlePaneHeight = new WindowsDesktopProperty(
+ "win.frame.captionHeight",
+ Integer.valueOf(18));
+ Object TitleButtonWidth = new WindowsDesktopProperty(
+ "win.frame.captionButtonWidth",
+ Integer.valueOf(16));
+ Object TitleButtonHeight = new WindowsDesktopProperty(
+ "win.frame.captionButtonHeight",
+ Integer.valueOf(16));
+ Object InactiveTextColor = new WindowsDesktopProperty(
+ "win.text.grayedTextColor",
+ table.get("textInactiveText"));
+ Object ScrollbarBackgroundColor = new WindowsDesktopProperty(
+ "win.scrollbar.backgroundColor",
+ table.get("scrollbar"));
+ Object buttonFocusColor = new FocusColorProperty();
+
+ Object TextBackground = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
+ WindowBackgroundColor);
+ //The following four lines were commented out as part of bug 4991597
+ //This code *is* correct, however it differs from WindowsXP and is, apparently
+ //a Windows XP bug. Until Windows fixes this bug, we shall also exhibit the same
+ //behavior
+ //Object ReadOnlyTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.READONLY, Prop.FILLCOLOR,
+ // ControlBackgroundColor);
+ //Object DisabledTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.DISABLED, Prop.FILLCOLOR,
+ // ControlBackgroundColor);
+ Object ReadOnlyTextBackground = ControlBackgroundColor;
+ Object DisabledTextBackground = ControlBackgroundColor;
+
+ Object MenuFont = dialogPlain12;
+ Object FixedControlFont = monospacedPlain12;
+ Object ControlFont = dialogPlain12;
+ Object MessageFont = dialogPlain12;
+ Object WindowFont = dialogBold12;
+ Object ToolTipFont = sansSerifPlain12;
+ Object IconFont = ControlFont;
+
+ Object scrollBarWidth = new WindowsDesktopProperty("win.scrollbar.width", Integer.valueOf(16));
+
+ Object menuBarHeight = new WindowsDesktopProperty("win.menu.height", null);
+
+ Object hotTrackingOn = new WindowsDesktopProperty("win.item.hotTrackingOn", true);
+
+ Object showMnemonics = new WindowsDesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE);
+
+ if (useSystemFontSettings) {
+ MenuFont = getDesktopFontValue("win.menu.font", MenuFont);
+ FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont);
+ ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont);
+ MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont);
+ WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont);
+ IconFont = getDesktopFontValue("win.icon.font", IconFont);
+ ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont);
+
+ /* Put the desktop AA settings in the defaults.
+ * JComponent.setUI() retrieves this and makes it available
+ * as a client property on the JComponent. Use the same key name
+ * for both client property and UIDefaults.
+ * Also need to set up listeners for changes in these settings.
+ */
+ SwingUtilities2.putAATextInfo(true, table);
+ this.aaSettings =
+ new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
+ }
+ if (useSystemFontSizeSettings) {
+ MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12);
+ FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED,
+ Font.PLAIN, 12);
+ ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12);
+ MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12);
+ WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12);
+ ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12);
+ IconFont = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12);
+ }
+
+
+ if (!(this instanceof WindowsClassicLookAndFeel) &&
+ (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
+ OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0) &&
+ AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) {
+
+ // These desktop properties are not used directly, but are needed to
+ // trigger realoading of UI's.
+ this.themeActive = new TriggerDesktopProperty("win.xpstyle.themeActive");
+ this.dllName = new TriggerDesktopProperty("win.xpstyle.dllName");
+ this.colorName = new TriggerDesktopProperty("win.xpstyle.colorName");
+ this.sizeName = new TriggerDesktopProperty("win.xpstyle.sizeName");
+ }
+
+
+ Object[] defaults = {
+ // *** Auditory Feedback
+ // this key defines which of the various cues to render
+ // Overridden from BasicL&F. This L&F should play all sounds
+ // all the time. The infrastructure decides what to play.
+ // This is disabled until sound bugs can be resolved.
+ "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"),
+
+ "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings),
+
+ "TextField.focusInputMap", fieldInputMap,
+ "PasswordField.focusInputMap", passwordInputMap,
+ "TextArea.focusInputMap", multilineInputMap,
+ "TextPane.focusInputMap", multilineInputMap,
+ "EditorPane.focusInputMap", multilineInputMap,
+
+ // Buttons
+ "Button.font", ControlFont,
+ "Button.background", ControlBackgroundColor,
+ // Button.foreground, Button.shadow, Button.darkShadow,
+ // Button.disabledForground, and Button.disabledShadow are only
+ // used for Windows Classic. Windows XP will use colors
+ // from the current visual style.
+ "Button.foreground", ControlTextColor,
+ "Button.shadow", ControlShadowColor,
+ "Button.darkShadow", ControlDarkShadowColor,
+ "Button.light", ControlLightColor,
+ "Button.highlight", ControlHighlightColor,
+ "Button.disabledForeground", InactiveTextColor,
+ "Button.disabledShadow", ControlHighlightColor,
+ "Button.focus", buttonFocusColor,
+ "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
+ "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
+ "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
+ "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)),
+ "Button.textShiftOffset", new XPValue(Integer.valueOf(0),
+ Integer.valueOf(1)),
+ // W2K keyboard navigation hidding.
+ "Button.showMnemonics", showMnemonics,
+ "Button.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "SPACE", "pressed",
+ "released SPACE", "released"
+ }),
+
+ "Caret.width",
+ new WindowsDesktopProperty("win.caret.width", null),
+
+ "CheckBox.font", ControlFont,
+ "CheckBox.interiorBackground", WindowBackgroundColor,
+ "CheckBox.background", ControlBackgroundColor,
+ "CheckBox.foreground", WindowTextColor,
+ "CheckBox.shadow", ControlShadowColor,
+ "CheckBox.darkShadow", ControlDarkShadowColor,
+ "CheckBox.light", ControlLightColor,
+ "CheckBox.highlight", ControlHighlightColor,
+ "CheckBox.focus", buttonFocusColor,
+ "CheckBox.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "SPACE", "pressed",
+ "released SPACE", "released"
+ }),
+ // margin is 2 all the way around, BasicBorders.RadioButtonBorder
+ // (checkbox uses RadioButtonBorder) is 2 all the way around too.
+ "CheckBox.totalInsets", new Insets(4, 4, 4, 4),
+
+ "CheckBoxMenuItem.font", MenuFont,
+ "CheckBoxMenuItem.background", MenuBackgroundColor,
+ "CheckBoxMenuItem.foreground", MenuTextColor,
+ "CheckBoxMenuItem.selectionForeground", SelectionTextColor,
+ "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor,
+ "CheckBoxMenuItem.acceleratorForeground", MenuTextColor,
+ "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor,
+ "CheckBoxMenuItem.commandSound", "win.sound.menuCommand",
+
+ "ComboBox.font", ControlFont,
+ "ComboBox.background", WindowBackgroundColor,
+ "ComboBox.foreground", WindowTextColor,
+ "ComboBox.buttonBackground", ControlBackgroundColor,
+ "ComboBox.buttonShadow", ControlShadowColor,
+ "ComboBox.buttonDarkShadow", ControlDarkShadowColor,
+ "ComboBox.buttonHighlight", ControlHighlightColor,
+ "ComboBox.selectionBackground", SelectionBackgroundColor,
+ "ComboBox.selectionForeground", SelectionTextColor,
+ "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,4,1,1),
+ new EmptyBorder(1,4,1,4)),
+ "ComboBox.disabledBackground",
+ new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
+ Prop.FILLCOLOR, DisabledTextBackground),
+ "ComboBox.disabledForeground",
+ new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
+ Prop.TEXTCOLOR, InactiveTextColor),
+ "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "hidePopup",
+ "PAGE_UP", "pageUpPassThrough",
+ "PAGE_DOWN", "pageDownPassThrough",
+ "HOME", "homePassThrough",
+ "END", "endPassThrough",
+ "DOWN", "selectNext2",
+ "KP_DOWN", "selectNext2",
+ "UP", "selectPrevious2",
+ "KP_UP", "selectPrevious2",
+ "ENTER", "enterPressed",
+ "F4", "togglePopup",
+ "alt DOWN", "togglePopup",
+ "alt KP_DOWN", "togglePopup",
+ "alt UP", "togglePopup",
+ "alt KP_UP", "togglePopup"
+ }),
+
+ // DeskTop.
+ "Desktop.background", new WindowsDesktopProperty(
+ "win.mdi.backgroundColor",
+ table.get("desktop")),
+ "Desktop.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl F5", "restore",
+ "ctrl F4", "close",
+ "ctrl F7", "move",
+ "ctrl F8", "resize",
+ "RIGHT", "right",
+ "KP_RIGHT", "right",
+ "LEFT", "left",
+ "KP_LEFT", "left",
+ "UP", "up",
+ "KP_UP", "up",
+ "DOWN", "down",
+ "KP_DOWN", "down",
+ "ESCAPE", "escape",
+ "ctrl F9", "minimize",
+ "ctrl F10", "maximize",
+ "ctrl F6", "selectNextFrame",
+ "ctrl TAB", "selectNextFrame",
+ "ctrl alt F6", "selectNextFrame",
+ "shift ctrl alt F6", "selectPreviousFrame",
+ "ctrl F12", "navigateNext",
+ "shift ctrl F12", "navigatePrevious"
+ }),
+
+ // DesktopIcon
+ "DesktopIcon.width", Integer.valueOf(160),
+
+ "EditorPane.font", ControlFont,
+ "EditorPane.background", WindowBackgroundColor,
+ "EditorPane.foreground", WindowTextColor,
+ "EditorPane.selectionBackground", SelectionBackgroundColor,
+ "EditorPane.selectionForeground", SelectionTextColor,
+ "EditorPane.caretForeground", WindowTextColor,
+ "EditorPane.inactiveForeground", InactiveTextColor,
+ "EditorPane.inactiveBackground", WindowBackgroundColor,
+ "EditorPane.disabledBackground", DisabledTextBackground,
+
+ "FileChooser.homeFolderIcon", new LazyWindowsIcon(null,
+ "icons/HomeFolder.gif"),
+ "FileChooser.listFont", IconFont,
+ "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR,
+ WindowBackgroundColor),
+ "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
+ (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
+ "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
+ "icons/ListView.gif"),
+ "FileChooser.listViewWindowsStyle", Boolean.TRUE,
+ "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView",
+ "icons/DetailsView.gif"),
+ "FileChooser.viewMenuIcon", new LazyWindowsIcon("fileChooserIcon ViewMenu",
+ "icons/ListView.gif"),
+ "FileChooser.upFolderIcon", new LazyWindowsIcon("fileChooserIcon UpFolder",
+ "icons/UpFolder.gif"),
+ "FileChooser.newFolderIcon", new LazyWindowsIcon("fileChooserIcon NewFolder",
+ "icons/NewFolder.gif"),
+ "FileChooser.useSystemExtensionHiding", Boolean.TRUE,
+
+ "FileChooser.usesSingleFilePane", Boolean.TRUE,
+ "FileChooser.noPlacesBar", new WindowsDesktopProperty("win.comdlg.noPlacesBar",
+ Boolean.FALSE),
+ "FileChooser.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "cancelSelection",
+ "F2", "editFileName",
+ "F5", "refresh",
+ "BACK_SPACE", "Go Up"
+ }),
+
+ "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ "icons/Directory.gif"),
+ "FileView.fileIcon", SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ "icons/File.gif"),
+ "FileView.computerIcon", SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ "icons/Computer.gif"),
+ "FileView.hardDriveIcon", SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ "icons/HardDrive.gif"),
+ "FileView.floppyDriveIcon", SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ "icons/FloppyDrive.gif"),
+
+ "FormattedTextField.font", ControlFont,
+ "InternalFrame.titleFont", WindowFont,
+ "InternalFrame.titlePaneHeight", TitlePaneHeight,
+ "InternalFrame.titleButtonWidth", TitleButtonWidth,
+ "InternalFrame.titleButtonHeight", TitleButtonHeight,
+ "InternalFrame.titleButtonToolTipsOn", hotTrackingOn,
+ "InternalFrame.borderColor", ControlBackgroundColor,
+ "InternalFrame.borderShadow", ControlShadowColor,
+ "InternalFrame.borderDarkShadow", ControlDarkShadowColor,
+ "InternalFrame.borderHighlight", ControlHighlightColor,
+ "InternalFrame.borderLight", ControlLightColor,
+ "InternalFrame.borderWidth", WindowBorderWidth,
+ "InternalFrame.minimizeIconBackground", ControlBackgroundColor,
+ "InternalFrame.resizeIconHighlight", ControlLightColor,
+ "InternalFrame.resizeIconShadow", ControlShadowColor,
+ "InternalFrame.activeBorderColor", new WindowsDesktopProperty(
+ "win.frame.activeBorderColor",
+ table.get("windowBorder")),
+ "InternalFrame.inactiveBorderColor", new WindowsDesktopProperty(
+ "win.frame.inactiveBorderColor",
+ table.get("windowBorder")),
+ "InternalFrame.activeTitleBackground", new WindowsDesktopProperty(
+ "win.frame.activeCaptionColor",
+ table.get("activeCaption")),
+ "InternalFrame.activeTitleGradient", new WindowsDesktopProperty(
+ "win.frame.activeCaptionGradientColor",
+ table.get("activeCaption")),
+ "InternalFrame.activeTitleForeground", new WindowsDesktopProperty(
+ "win.frame.captionTextColor",
+ table.get("activeCaptionText")),
+ "InternalFrame.inactiveTitleBackground", new WindowsDesktopProperty(
+ "win.frame.inactiveCaptionColor",
+ table.get("inactiveCaption")),
+ "InternalFrame.inactiveTitleGradient", new WindowsDesktopProperty(
+ "win.frame.inactiveCaptionGradientColor",
+ table.get("inactiveCaption")),
+ "InternalFrame.inactiveTitleForeground", new WindowsDesktopProperty(
+ "win.frame.inactiveCaptionTextColor",
+ table.get("inactiveCaptionText")),
+
+ "InternalFrame.maximizeIcon",
+ WindowsIconFactory.createFrameMaximizeIcon(),
+ "InternalFrame.minimizeIcon",
+ WindowsIconFactory.createFrameMinimizeIcon(),
+ "InternalFrame.iconifyIcon",
+ WindowsIconFactory.createFrameIconifyIcon(),
+ "InternalFrame.closeIcon",
+ WindowsIconFactory.createFrameCloseIcon(),
+ "InternalFrame.icon",
+ (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{
+ // The constructor takes one arg: an array of UIDefaults.LazyValue
+ // representing the icons
+ SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
+ SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
+ }),
+ // Internal Frame Auditory Cue Mappings
+ "InternalFrame.closeSound", "win.sound.close",
+ "InternalFrame.maximizeSound", "win.sound.maximize",
+ "InternalFrame.minimizeSound", "win.sound.minimize",
+ "InternalFrame.restoreDownSound", "win.sound.restoreDown",
+ "InternalFrame.restoreUpSound", "win.sound.restoreUp",
+
+ "InternalFrame.windowBindings", new Object[] {
+ "shift ESCAPE", "showSystemMenu",
+ "ctrl SPACE", "showSystemMenu",
+ "ESCAPE", "hideSystemMenu"},
+
+ // Label
+ "Label.font", ControlFont,
+ "Label.background", ControlBackgroundColor,
+ "Label.foreground", WindowTextColor,
+ "Label.disabledForeground", InactiveTextColor,
+ "Label.disabledShadow", ControlHighlightColor,
+
+ // List.
+ "List.font", ControlFont,
+ "List.background", WindowBackgroundColor,
+ "List.foreground", WindowTextColor,
+ "List.selectionBackground", SelectionBackgroundColor,
+ "List.selectionForeground", SelectionTextColor,
+ "List.lockToPositionOnScroll", Boolean.TRUE,
+ "List.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl C", "copy",
+ "ctrl V", "paste",
+ "ctrl X", "cut",
+ "COPY", "copy",
+ "PASTE", "paste",
+ "CUT", "cut",
+ "control INSERT", "copy",
+ "shift INSERT", "paste",
+ "shift DELETE", "cut",
+ "UP", "selectPreviousRow",
+ "KP_UP", "selectPreviousRow",
+ "shift UP", "selectPreviousRowExtendSelection",
+ "shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift UP", "selectPreviousRowExtendSelection",
+ "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl UP", "selectPreviousRowChangeLead",
+ "ctrl KP_UP", "selectPreviousRowChangeLead",
+ "DOWN", "selectNextRow",
+ "KP_DOWN", "selectNextRow",
+ "shift DOWN", "selectNextRowExtendSelection",
+ "shift KP_DOWN", "selectNextRowExtendSelection",
+ "ctrl shift DOWN", "selectNextRowExtendSelection",
+ "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
+ "ctrl DOWN", "selectNextRowChangeLead",
+ "ctrl KP_DOWN", "selectNextRowChangeLead",
+ "LEFT", "selectPreviousColumn",
+ "KP_LEFT", "selectPreviousColumn",
+ "shift LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl LEFT", "selectPreviousColumnChangeLead",
+ "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
+ "RIGHT", "selectNextColumn",
+ "KP_RIGHT", "selectNextColumn",
+ "shift RIGHT", "selectNextColumnExtendSelection",
+ "shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl RIGHT", "selectNextColumnChangeLead",
+ "ctrl KP_RIGHT", "selectNextColumnChangeLead",
+ "HOME", "selectFirstRow",
+ "shift HOME", "selectFirstRowExtendSelection",
+ "ctrl shift HOME", "selectFirstRowExtendSelection",
+ "ctrl HOME", "selectFirstRowChangeLead",
+ "END", "selectLastRow",
+ "shift END", "selectLastRowExtendSelection",
+ "ctrl shift END", "selectLastRowExtendSelection",
+ "ctrl END", "selectLastRowChangeLead",
+ "PAGE_UP", "scrollUp",
+ "shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl PAGE_UP", "scrollUpChangeLead",
+ "PAGE_DOWN", "scrollDown",
+ "shift PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl PAGE_DOWN", "scrollDownChangeLead",
+ "ctrl A", "selectAll",
+ "ctrl SLASH", "selectAll",
+ "ctrl BACK_SLASH", "clearSelection",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "ctrl shift SPACE", "moveSelectionTo"
+ }),
+
+ // PopupMenu
+ "PopupMenu.font", MenuFont,
+ "PopupMenu.background", MenuBackgroundColor,
+ "PopupMenu.foreground", MenuTextColor,
+ "PopupMenu.popupSound", "win.sound.menuPopup",
+ "PopupMenu.consumeEventOnClose", Boolean.TRUE,
+
+ // Menus
+ "Menu.font", MenuFont,
+ "Menu.foreground", MenuTextColor,
+ "Menu.background", MenuBackgroundColor,
+ "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE,
+ "Menu.selectionForeground", SelectionTextColor,
+ "Menu.selectionBackground", SelectionBackgroundColor,
+ "Menu.acceleratorForeground", MenuTextColor,
+ "Menu.acceleratorSelectionForeground", SelectionTextColor,
+ "Menu.menuPopupOffsetX", Integer.valueOf(0),
+ "Menu.menuPopupOffsetY", Integer.valueOf(0),
+ "Menu.submenuPopupOffsetX", Integer.valueOf(-4),
+ "Menu.submenuPopupOffsetY", Integer.valueOf(-3),
+ "Menu.crossMenuMnemonic", Boolean.FALSE,
+ "Menu.preserveTopLevelSelection", Boolean.TRUE,
+
+ // MenuBar.
+ "MenuBar.font", MenuFont,
+ "MenuBar.background", new XPValue(MenuBarBackgroundColor,
+ MenuBackgroundColor),
+ "MenuBar.foreground", MenuTextColor,
+ "MenuBar.shadow", ControlShadowColor,
+ "MenuBar.highlight", ControlHighlightColor,
+ "MenuBar.height", menuBarHeight,
+ "MenuBar.rolloverEnabled", hotTrackingOn,
+ "MenuBar.windowBindings", new Object[] {
+ "F10", "takeFocus" },
+
+ "MenuItem.font", MenuFont,
+ "MenuItem.acceleratorFont", MenuFont,
+ "MenuItem.foreground", MenuTextColor,
+ "MenuItem.background", MenuBackgroundColor,
+ "MenuItem.selectionForeground", SelectionTextColor,
+ "MenuItem.selectionBackground", SelectionBackgroundColor,
+ "MenuItem.disabledForeground", InactiveTextColor,
+ "MenuItem.acceleratorForeground", MenuTextColor,
+ "MenuItem.acceleratorSelectionForeground", SelectionTextColor,
+ "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
+ // Menu Item Auditory Cue Mapping
+ "MenuItem.commandSound", "win.sound.menuCommand",
+ // indicates that keyboard navigation won't skip disabled menu items
+ "MenuItem.disabledAreNavigable", Boolean.TRUE,
+
+ "RadioButton.font", ControlFont,
+ "RadioButton.interiorBackground", WindowBackgroundColor,
+ "RadioButton.background", ControlBackgroundColor,
+ "RadioButton.foreground", WindowTextColor,
+ "RadioButton.shadow", ControlShadowColor,
+ "RadioButton.darkShadow", ControlDarkShadowColor,
+ "RadioButton.light", ControlLightColor,
+ "RadioButton.highlight", ControlHighlightColor,
+ "RadioButton.focus", buttonFocusColor,
+ "RadioButton.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "SPACE", "pressed",
+ "released SPACE", "released"
+ }),
+ // margin is 2 all the way around, BasicBorders.RadioButtonBorder
+ // is 2 all the way around too.
+ "RadioButton.totalInsets", new Insets(4, 4, 4, 4),
+
+
+ "RadioButtonMenuItem.font", MenuFont,
+ "RadioButtonMenuItem.foreground", MenuTextColor,
+ "RadioButtonMenuItem.background", MenuBackgroundColor,
+ "RadioButtonMenuItem.selectionForeground", SelectionTextColor,
+ "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor,
+ "RadioButtonMenuItem.disabledForeground", InactiveTextColor,
+ "RadioButtonMenuItem.acceleratorForeground", MenuTextColor,
+ "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor,
+ "RadioButtonMenuItem.commandSound", "win.sound.menuCommand",
+
+ // OptionPane.
+ "OptionPane.font", MessageFont,
+ "OptionPane.messageFont", MessageFont,
+ "OptionPane.buttonFont", MessageFont,
+ "OptionPane.background", ControlBackgroundColor,
+ "OptionPane.foreground", WindowTextColor,
+ "OptionPane.buttonMinimumWidth", new XPDLUValue(50, 50, SwingConstants.EAST),
+ "OptionPane.messageForeground", ControlTextColor,
+ "OptionPane.errorIcon", new LazyWindowsIcon("optionPaneIcon Error",
+ "icons/Error.gif"),
+ "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information",
+ "icons/Inform.gif"),
+ "OptionPane.questionIcon", new LazyWindowsIcon("optionPaneIcon Question",
+ "icons/Question.gif"),
+ "OptionPane.warningIcon", new LazyWindowsIcon("optionPaneIcon Warning",
+ "icons/Warn.gif"),
+ "OptionPane.windowBindings", new Object[] {
+ "ESCAPE", "close" },
+ // Option Pane Auditory Cue Mappings
+ "OptionPane.errorSound", "win.sound.hand", // Error
+ "OptionPane.informationSound", "win.sound.asterisk", // Info Plain
+ "OptionPane.questionSound", "win.sound.question", // Question
+ "OptionPane.warningSound", "win.sound.exclamation", // Warning
+
+ "FormattedTextField.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl C", DefaultEditorKit.copyAction,
+ "ctrl V", DefaultEditorKit.pasteAction,
+ "ctrl X", DefaultEditorKit.cutAction,
+ "COPY", DefaultEditorKit.copyAction,
+ "PASTE", DefaultEditorKit.pasteAction,
+ "CUT", DefaultEditorKit.cutAction,
+ "control INSERT", DefaultEditorKit.copyAction,
+ "shift INSERT", DefaultEditorKit.pasteAction,
+ "shift DELETE", DefaultEditorKit.cutAction,
+ "shift LEFT", DefaultEditorKit.selectionBackwardAction,
+ "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
+ "shift RIGHT", DefaultEditorKit.selectionForwardAction,
+ "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
+ "ctrl LEFT", DefaultEditorKit.previousWordAction,
+ "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
+ "ctrl RIGHT", DefaultEditorKit.nextWordAction,
+ "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
+ "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
+ "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
+ "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
+ "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
+ "ctrl A", DefaultEditorKit.selectAllAction,
+ "HOME", DefaultEditorKit.beginLineAction,
+ "END", DefaultEditorKit.endLineAction,
+ "shift HOME", DefaultEditorKit.selectionBeginLineAction,
+ "shift END", DefaultEditorKit.selectionEndLineAction,
+ "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
+ "ctrl H", DefaultEditorKit.deletePrevCharAction,
+ "DELETE", DefaultEditorKit.deleteNextCharAction,
+ "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
+ "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
+ "RIGHT", DefaultEditorKit.forwardAction,
+ "LEFT", DefaultEditorKit.backwardAction,
+ "KP_RIGHT", DefaultEditorKit.forwardAction,
+ "KP_LEFT", DefaultEditorKit.backwardAction,
+ "ENTER", JTextField.notifyAction,
+ "ctrl BACK_SLASH", "unselect",
+ "control shift O", "toggle-componentOrientation",
+ "ESCAPE", "reset-field-edit",
+ "UP", "increment",
+ "KP_UP", "increment",
+ "DOWN", "decrement",
+ "KP_DOWN", "decrement",
+ }),
+ "FormattedTextField.inactiveBackground", ReadOnlyTextBackground,
+ "FormattedTextField.disabledBackground", DisabledTextBackground,
+ "FormattedTextField.background", TextBackground,
+ "FormattedTextField.foreground", WindowTextColor,
+
+ // *** Panel
+ "Panel.font", ControlFont,
+ "Panel.background", ControlBackgroundColor,
+ "Panel.foreground", WindowTextColor,
+
+ // *** PasswordField
+ "PasswordField.font", ControlFont,
+ "PasswordField.background", TextBackground,
+ "PasswordField.foreground", WindowTextColor,
+ "PasswordField.inactiveForeground", InactiveTextColor, // for disabled
+ "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly
+ "PasswordField.disabledBackground", DisabledTextBackground, // for disabled
+ "PasswordField.selectionBackground", SelectionBackgroundColor,
+ "PasswordField.selectionForeground", SelectionTextColor,
+ "PasswordField.caretForeground",WindowTextColor,
+ "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
+
+ // *** ProgressBar
+ "ProgressBar.font", ControlFont,
+ "ProgressBar.foreground", SelectionBackgroundColor,
+ "ProgressBar.background", ControlBackgroundColor,
+ "ProgressBar.shadow", ControlShadowColor,
+ "ProgressBar.highlight", ControlHighlightColor,
+ "ProgressBar.selectionForeground", ControlBackgroundColor,
+ "ProgressBar.selectionBackground", SelectionBackgroundColor,
+ "ProgressBar.cellLength", Integer.valueOf(7),
+ "ProgressBar.cellSpacing", Integer.valueOf(2),
+ "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3),
+
+ // *** RootPane.
+ // These bindings are only enabled when there is a default
+ // button set on the rootpane.
+ "RootPane.defaultButtonWindowKeyBindings", new Object[] {
+ "ENTER", "press",
+ "released ENTER", "release",
+ "ctrl ENTER", "press",
+ "ctrl released ENTER", "release"
+ },
+
+ // *** ScrollBar.
+ "ScrollBar.background", ScrollbarBackgroundColor,
+ "ScrollBar.foreground", ControlBackgroundColor,
+ "ScrollBar.track", white,
+ "ScrollBar.trackForeground", ScrollbarBackgroundColor,
+ "ScrollBar.trackHighlight", black,
+ "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight,
+ "ScrollBar.thumb", ControlBackgroundColor,
+ "ScrollBar.thumbHighlight", ControlHighlightColor,
+ "ScrollBar.thumbDarkShadow", ControlDarkShadowColor,
+ "ScrollBar.thumbShadow", ControlShadowColor,
+ "ScrollBar.width", scrollBarWidth,
+ "ScrollBar.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "RIGHT", "positiveUnitIncrement",
+ "KP_RIGHT", "positiveUnitIncrement",
+ "DOWN", "positiveUnitIncrement",
+ "KP_DOWN", "positiveUnitIncrement",
+ "PAGE_DOWN", "positiveBlockIncrement",
+ "ctrl PAGE_DOWN", "positiveBlockIncrement",
+ "LEFT", "negativeUnitIncrement",
+ "KP_LEFT", "negativeUnitIncrement",
+ "UP", "negativeUnitIncrement",
+ "KP_UP", "negativeUnitIncrement",
+ "PAGE_UP", "negativeBlockIncrement",
+ "ctrl PAGE_UP", "negativeBlockIncrement",
+ "HOME", "minScroll",
+ "END", "maxScroll"
+ }),
+
+ // *** ScrollPane.
+ "ScrollPane.font", ControlFont,
+ "ScrollPane.background", ControlBackgroundColor,
+ "ScrollPane.foreground", ControlTextColor,
+ "ScrollPane.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "RIGHT", "unitScrollRight",
+ "KP_RIGHT", "unitScrollRight",
+ "DOWN", "unitScrollDown",
+ "KP_DOWN", "unitScrollDown",
+ "LEFT", "unitScrollLeft",
+ "KP_LEFT", "unitScrollLeft",
+ "UP", "unitScrollUp",
+ "KP_UP", "unitScrollUp",
+ "PAGE_UP", "scrollUp",
+ "PAGE_DOWN", "scrollDown",
+ "ctrl PAGE_UP", "scrollLeft",
+ "ctrl PAGE_DOWN", "scrollRight",
+ "ctrl HOME", "scrollHome",
+ "ctrl END", "scrollEnd"
+ }),
+
+ // *** Separator
+ "Separator.background", ControlHighlightColor,
+ "Separator.foreground", ControlShadowColor,
+
+ // *** Slider.
+ "Slider.font", ControlFont,
+ "Slider.foreground", ControlBackgroundColor,
+ "Slider.background", ControlBackgroundColor,
+ "Slider.highlight", ControlHighlightColor,
+ "Slider.shadow", ControlShadowColor,
+ "Slider.focus", ControlDarkShadowColor,
+ "Slider.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "RIGHT", "positiveUnitIncrement",
+ "KP_RIGHT", "positiveUnitIncrement",
+ "DOWN", "negativeUnitIncrement",
+ "KP_DOWN", "negativeUnitIncrement",
+ "PAGE_DOWN", "negativeBlockIncrement",
+ "LEFT", "negativeUnitIncrement",
+ "KP_LEFT", "negativeUnitIncrement",
+ "UP", "positiveUnitIncrement",
+ "KP_UP", "positiveUnitIncrement",
+ "PAGE_UP", "positiveBlockIncrement",
+ "HOME", "minScroll",
+ "END", "maxScroll"
+ }),
+
+ // Spinner
+ "Spinner.font", ControlFont,
+ "Spinner.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "UP", "increment",
+ "KP_UP", "increment",
+ "DOWN", "decrement",
+ "KP_DOWN", "decrement",
+ }),
+
+ // *** SplitPane
+ "SplitPane.background", ControlBackgroundColor,
+ "SplitPane.highlight", ControlHighlightColor,
+ "SplitPane.shadow", ControlShadowColor,
+ "SplitPane.darkShadow", ControlDarkShadowColor,
+ "SplitPane.dividerSize", Integer.valueOf(5),
+ "SplitPane.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "UP", "negativeIncrement",
+ "DOWN", "positiveIncrement",
+ "LEFT", "negativeIncrement",
+ "RIGHT", "positiveIncrement",
+ "KP_UP", "negativeIncrement",
+ "KP_DOWN", "positiveIncrement",
+ "KP_LEFT", "negativeIncrement",
+ "KP_RIGHT", "positiveIncrement",
+ "HOME", "selectMin",
+ "END", "selectMax",
+ "F8", "startResize",
+ "F6", "toggleFocus",
+ "ctrl TAB", "focusOutForward",
+ "ctrl shift TAB", "focusOutBackward"
+ }),
+
+ // *** TabbedPane
+ "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE),
+ "TabbedPane.tabInsets", new XPValue(new InsetsUIResource(1, 4, 1, 4),
+ new InsetsUIResource(0, 4, 1, 4)),
+ "TabbedPane.tabAreaInsets", new XPValue(new InsetsUIResource(3, 2, 2, 2),
+ new InsetsUIResource(3, 2, 0, 2)),
+ "TabbedPane.font", ControlFont,
+ "TabbedPane.background", ControlBackgroundColor,
+ "TabbedPane.foreground", ControlTextColor,
+ "TabbedPane.highlight", ControlHighlightColor,
+ "TabbedPane.light", ControlLightColor,
+ "TabbedPane.shadow", ControlShadowColor,
+ "TabbedPane.darkShadow", ControlDarkShadowColor,
+ "TabbedPane.focus", ControlTextColor,
+ "TabbedPane.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "RIGHT", "navigateRight",
+ "KP_RIGHT", "navigateRight",
+ "LEFT", "navigateLeft",
+ "KP_LEFT", "navigateLeft",
+ "UP", "navigateUp",
+ "KP_UP", "navigateUp",
+ "DOWN", "navigateDown",
+ "KP_DOWN", "navigateDown",
+ "ctrl DOWN", "requestFocusForVisibleComponent",
+ "ctrl KP_DOWN", "requestFocusForVisibleComponent",
+ }),
+ "TabbedPane.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl TAB", "navigateNext",
+ "ctrl shift TAB", "navigatePrevious",
+ "ctrl PAGE_DOWN", "navigatePageDown",
+ "ctrl PAGE_UP", "navigatePageUp",
+ "ctrl UP", "requestFocus",
+ "ctrl KP_UP", "requestFocus",
+ }),
+
+ // *** Table
+ "Table.font", ControlFont,
+ "Table.foreground", ControlTextColor, // cell text color
+ "Table.background", WindowBackgroundColor, // cell background color
+ "Table.highlight", ControlHighlightColor,
+ "Table.light", ControlLightColor,
+ "Table.shadow", ControlShadowColor,
+ "Table.darkShadow", ControlDarkShadowColor,
+ "Table.selectionForeground", SelectionTextColor,
+ "Table.selectionBackground", SelectionBackgroundColor,
+ "Table.gridColor", gray, // grid line color
+ "Table.focusCellBackground", WindowBackgroundColor,
+ "Table.focusCellForeground", ControlTextColor,
+ "Table.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl C", "copy",
+ "ctrl V", "paste",
+ "ctrl X", "cut",
+ "COPY", "copy",
+ "PASTE", "paste",
+ "CUT", "cut",
+ "control INSERT", "copy",
+ "shift INSERT", "paste",
+ "shift DELETE", "cut",
+ "RIGHT", "selectNextColumn",
+ "KP_RIGHT", "selectNextColumn",
+ "shift RIGHT", "selectNextColumnExtendSelection",
+ "shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift RIGHT", "selectNextColumnExtendSelection",
+ "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "ctrl RIGHT", "selectNextColumnChangeLead",
+ "ctrl KP_RIGHT", "selectNextColumnChangeLead",
+ "LEFT", "selectPreviousColumn",
+ "KP_LEFT", "selectPreviousColumn",
+ "shift LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl LEFT", "selectPreviousColumnChangeLead",
+ "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
+ "DOWN", "selectNextRow",
+ "KP_DOWN", "selectNextRow",
+ "shift DOWN", "selectNextRowExtendSelection",
+ "shift KP_DOWN", "selectNextRowExtendSelection",
+ "ctrl shift DOWN", "selectNextRowExtendSelection",
+ "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
+ "ctrl DOWN", "selectNextRowChangeLead",
+ "ctrl KP_DOWN", "selectNextRowChangeLead",
+ "UP", "selectPreviousRow",
+ "KP_UP", "selectPreviousRow",
+ "shift UP", "selectPreviousRowExtendSelection",
+ "shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl shift UP", "selectPreviousRowExtendSelection",
+ "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
+ "ctrl UP", "selectPreviousRowChangeLead",
+ "ctrl KP_UP", "selectPreviousRowChangeLead",
+ "HOME", "selectFirstColumn",
+ "shift HOME", "selectFirstColumnExtendSelection",
+ "ctrl shift HOME", "selectFirstRowExtendSelection",
+ "ctrl HOME", "selectFirstRow",
+ "END", "selectLastColumn",
+ "shift END", "selectLastColumnExtendSelection",
+ "ctrl shift END", "selectLastRowExtendSelection",
+ "ctrl END", "selectLastRow",
+ "PAGE_UP", "scrollUpChangeSelection",
+ "shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
+ "ctrl PAGE_UP", "scrollLeftChangeSelection",
+ "PAGE_DOWN", "scrollDownChangeSelection",
+ "shift PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
+ "ctrl PAGE_DOWN", "scrollRightChangeSelection",
+ "TAB", "selectNextColumnCell",
+ "shift TAB", "selectPreviousColumnCell",
+ "ENTER", "selectNextRowCell",
+ "shift ENTER", "selectPreviousRowCell",
+ "ctrl A", "selectAll",
+ "ctrl SLASH", "selectAll",
+ "ctrl BACK_SLASH", "clearSelection",
+ "ESCAPE", "cancel",
+ "F2", "startEditing",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "ctrl shift SPACE", "moveSelectionTo",
+ "F8", "focusHeader"
+ }),
+ "Table.sortIconHighlight", ControlShadowColor,
+ "Table.sortIconLight", white,
+
+ "TableHeader.font", ControlFont,
+ "TableHeader.foreground", ControlTextColor, // header text color
+ "TableHeader.background", ControlBackgroundColor, // header background
+ "TableHeader.focusCellBackground",
+ new XPValue(XPValue.NULL_VALUE, // use default bg from XP styles
+ WindowBackgroundColor), // or white bg otherwise
+
+ // *** TextArea
+ "TextArea.font", FixedControlFont,
+ "TextArea.background", WindowBackgroundColor,
+ "TextArea.foreground", WindowTextColor,
+ "TextArea.inactiveForeground", InactiveTextColor,
+ "TextArea.inactiveBackground", WindowBackgroundColor,
+ "TextArea.disabledBackground", DisabledTextBackground,
+ "TextArea.selectionBackground", SelectionBackgroundColor,
+ "TextArea.selectionForeground", SelectionTextColor,
+ "TextArea.caretForeground", WindowTextColor,
+
+ // *** TextField
+ "TextField.font", ControlFont,
+ "TextField.background", TextBackground,
+ "TextField.foreground", WindowTextColor,
+ "TextField.shadow", ControlShadowColor,
+ "TextField.darkShadow", ControlDarkShadowColor,
+ "TextField.light", ControlLightColor,
+ "TextField.highlight", ControlHighlightColor,
+ "TextField.inactiveForeground", InactiveTextColor, // for disabled
+ "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly
+ "TextField.disabledBackground", DisabledTextBackground, // for disabled
+ "TextField.selectionBackground", SelectionBackgroundColor,
+ "TextField.selectionForeground", SelectionTextColor,
+ "TextField.caretForeground", WindowTextColor,
+
+ // *** TextPane
+ "TextPane.font", ControlFont,
+ "TextPane.background", WindowBackgroundColor,
+ "TextPane.foreground", WindowTextColor,
+ "TextPane.selectionBackground", SelectionBackgroundColor,
+ "TextPane.selectionForeground", SelectionTextColor,
+ "TextPane.inactiveBackground", WindowBackgroundColor,
+ "TextPane.disabledBackground", DisabledTextBackground,
+ "TextPane.caretForeground", WindowTextColor,
+
+ // *** TitledBorder
+ "TitledBorder.font", ControlFont,
+ "TitledBorder.titleColor",
+ new XPColorValue(Part.BP_GROUPBOX, null, Prop.TEXTCOLOR,
+ WindowTextColor),
+
+ // *** ToggleButton
+ "ToggleButton.font", ControlFont,
+ "ToggleButton.background", ControlBackgroundColor,
+ "ToggleButton.foreground", ControlTextColor,
+ "ToggleButton.shadow", ControlShadowColor,
+ "ToggleButton.darkShadow", ControlDarkShadowColor,
+ "ToggleButton.light", ControlLightColor,
+ "ToggleButton.highlight", ControlHighlightColor,
+ "ToggleButton.focus", ControlTextColor,
+ "ToggleButton.textShiftOffset", Integer.valueOf(1),
+ "ToggleButton.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "SPACE", "pressed",
+ "released SPACE", "released"
+ }),
+
+ // *** ToolBar
+ "ToolBar.font", MenuFont,
+ "ToolBar.background", ControlBackgroundColor,
+ "ToolBar.foreground", ControlTextColor,
+ "ToolBar.shadow", ControlShadowColor,
+ "ToolBar.darkShadow", ControlDarkShadowColor,
+ "ToolBar.light", ControlLightColor,
+ "ToolBar.highlight", ControlHighlightColor,
+ "ToolBar.dockingBackground", ControlBackgroundColor,
+ "ToolBar.dockingForeground", red,
+ "ToolBar.floatingBackground", ControlBackgroundColor,
+ "ToolBar.floatingForeground", darkGray,
+ "ToolBar.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "UP", "navigateUp",
+ "KP_UP", "navigateUp",
+ "DOWN", "navigateDown",
+ "KP_DOWN", "navigateDown",
+ "LEFT", "navigateLeft",
+ "KP_LEFT", "navigateLeft",
+ "RIGHT", "navigateRight",
+ "KP_RIGHT", "navigateRight"
+ }),
+ "ToolBar.separatorSize", null,
+
+ // *** ToolTip
+ "ToolTip.font", ToolTipFont,
+ "ToolTip.background", new WindowsDesktopProperty("win.tooltip.backgroundColor", table.get("info")),
+ "ToolTip.foreground", new WindowsDesktopProperty("win.tooltip.textColor", table.get("infoText")),
+
+ // *** ToolTipManager
+ "ToolTipManager.enableToolTipMode", "activeApplication",
+
+ // *** Tree
+ "Tree.selectionBorderColor", black,
+ "Tree.drawDashedFocusIndicator", Boolean.TRUE,
+ "Tree.lineTypeDashed", Boolean.TRUE,
+ "Tree.font", ControlFont,
+ "Tree.background", WindowBackgroundColor,
+ "Tree.foreground", WindowTextColor,
+ "Tree.hash", gray,
+ "Tree.leftChildIndent", Integer.valueOf(8),
+ "Tree.rightChildIndent", Integer.valueOf(11),
+ "Tree.textForeground", WindowTextColor,
+ "Tree.textBackground", WindowBackgroundColor,
+ "Tree.selectionForeground", SelectionTextColor,
+ "Tree.selectionBackground", SelectionBackgroundColor,
+ "Tree.expandedIcon", treeExpandedIcon,
+ "Tree.collapsedIcon", treeCollapsedIcon,
+ "Tree.openIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
+ "shell32Icon 5", "icons/TreeOpen.gif"),
+ "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
+ "shell32Icon 4", "icons/TreeClosed.gif"),
+ "Tree.focusInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ADD", "expand",
+ "SUBTRACT", "collapse",
+ "ctrl C", "copy",
+ "ctrl V", "paste",
+ "ctrl X", "cut",
+ "COPY", "copy",
+ "PASTE", "paste",
+ "CUT", "cut",
+ "control INSERT", "copy",
+ "shift INSERT", "paste",
+ "shift DELETE", "cut",
+ "UP", "selectPrevious",
+ "KP_UP", "selectPrevious",
+ "shift UP", "selectPreviousExtendSelection",
+ "shift KP_UP", "selectPreviousExtendSelection",
+ "ctrl shift UP", "selectPreviousExtendSelection",
+ "ctrl shift KP_UP", "selectPreviousExtendSelection",
+ "ctrl UP", "selectPreviousChangeLead",
+ "ctrl KP_UP", "selectPreviousChangeLead",
+ "DOWN", "selectNext",
+ "KP_DOWN", "selectNext",
+ "shift DOWN", "selectNextExtendSelection",
+ "shift KP_DOWN", "selectNextExtendSelection",
+ "ctrl shift DOWN", "selectNextExtendSelection",
+ "ctrl shift KP_DOWN", "selectNextExtendSelection",
+ "ctrl DOWN", "selectNextChangeLead",
+ "ctrl KP_DOWN", "selectNextChangeLead",
+ "RIGHT", "selectChild",
+ "KP_RIGHT", "selectChild",
+ "LEFT", "selectParent",
+ "KP_LEFT", "selectParent",
+ "PAGE_UP", "scrollUpChangeSelection",
+ "shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl shift PAGE_UP", "scrollUpExtendSelection",
+ "ctrl PAGE_UP", "scrollUpChangeLead",
+ "PAGE_DOWN", "scrollDownChangeSelection",
+ "shift PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl PAGE_DOWN", "scrollDownChangeLead",
+ "HOME", "selectFirst",
+ "shift HOME", "selectFirstExtendSelection",
+ "ctrl shift HOME", "selectFirstExtendSelection",
+ "ctrl HOME", "selectFirstChangeLead",
+ "END", "selectLast",
+ "shift END", "selectLastExtendSelection",
+ "ctrl shift END", "selectLastExtendSelection",
+ "ctrl END", "selectLastChangeLead",
+ "F2", "startEditing",
+ "ctrl A", "selectAll",
+ "ctrl SLASH", "selectAll",
+ "ctrl BACK_SLASH", "clearSelection",
+ "ctrl LEFT", "scrollLeft",
+ "ctrl KP_LEFT", "scrollLeft",
+ "ctrl RIGHT", "scrollRight",
+ "ctrl KP_RIGHT", "scrollRight",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "ctrl shift SPACE", "moveSelectionTo"
+ }),
+ "Tree.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[] {
+ "ESCAPE", "cancel"
+ }),
+
+ // *** Viewport
+ "Viewport.font", ControlFont,
+ "Viewport.background", ControlBackgroundColor,
+ "Viewport.foreground", WindowTextColor,
+
+
+ };
+
+ table.putDefaults(defaults);
+ table.putDefaults(getLazyValueDefaults());
+ initVistaComponentDefaults(table);
+ }
+
+ static boolean isOnVista() {
+ return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
+ && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) >= 0;
+ }
+
+ static boolean isOnWindows7() {
+ return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
+ && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_7) >= 0;
+ }
+
+ private void initVistaComponentDefaults(UIDefaults table) {
+ if (! isOnVista()) {
+ return;
+ }
+ /* START handling menus for Vista */
+ String[] menuClasses = { "MenuItem", "Menu",
+ "CheckBoxMenuItem", "RadioButtonMenuItem",
+ };
+
+ Object menuDefaults[] = new Object[menuClasses.length * 2];
+
+ /* all the menus need to be non opaque. */
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".opaque";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(Boolean.FALSE, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /*
+ * acceleratorSelectionForeground color is the same as
+ * acceleratorForeground
+ */
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".acceleratorSelectionForeground";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(
+ table.getColor(
+ menuClasses[i] + ".acceleratorForeground"),
+ oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /* they have the same MenuItemCheckIconFactory */
+ VistaMenuItemCheckIconFactory menuItemCheckIconFactory =
+ WindowsIconFactory.getMenuItemCheckIconFactory();
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".checkIconFactory";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(menuItemCheckIconFactory, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".checkIcon";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]),
+ oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+
+ /* height can be even */
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".evenHeight";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /*For Windows7 margin and checkIconOffset should be greater than 0 */
+ if (!isOnWindows7()) {
+ /* no margins */
+ InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0);
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".margin";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] = new XPValue(insets, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /* set checkIcon offset */
+ Integer checkIconOffsetInteger =
+ Integer.valueOf(0);
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".checkIconOffset";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(checkIconOffsetInteger, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+ }
+ /* set width of the gap after check icon */
+ Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter()
+ + WindowsPopupMenuUI.getGutterWidth()
+ + WindowsPopupMenuUI.getSpanAfterGutter();
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".afterCheckIconGap";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] =
+ new XPValue(afterCheckIconGap, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /* text is started after this position */
+ Object minimumTextOffset = new UIDefaults.ActiveValue() {
+ public Object createValue(UIDefaults table) {
+ return VistaMenuItemCheckIconFactory.getIconWidth()
+ + WindowsPopupMenuUI.getSpanBeforeGutter()
+ + WindowsPopupMenuUI.getGutterWidth()
+ + WindowsPopupMenuUI.getSpanAfterGutter();
+ }
+ };
+ for (int i = 0, j = 0; i < menuClasses.length; i++) {
+ String key = menuClasses[i] + ".minimumTextOffset";
+ Object oldValue = table.get(key);
+ menuDefaults[j++] = key;
+ menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue);
+ }
+ table.putDefaults(menuDefaults);
+
+ /*
+ * JPopupMenu has a bit of free space around menu items
+ */
+ String POPUP_MENU_BORDER = "PopupMenu.border";
+
+ Object popupMenuBorder = new XPBorderValue(Part.MENU,
+ (LazyValue) t -> BasicBorders.getInternalFrameBorder(),
+ BorderFactory.createEmptyBorder(2, 2, 2, 2));
+ table.put(POPUP_MENU_BORDER, popupMenuBorder);
+ /* END handling menus for Vista */
+
+ /* START table handling for Vista */
+ table.put("Table.ascendingSortIcon", new XPValue(
+ new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
+ (LazyValue) t -> new ClassicSortArrowIcon(true)));
+ table.put("Table.descendingSortIcon", new XPValue(
+ new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
+ (LazyValue) t -> new ClassicSortArrowIcon(false)));
+ /* END table handling for Vista */
+ }
+
+ /**
+ * If we support loading of fonts from the desktop this will return
+ * a WindowsDesktopProperty representing the font. If the font can't be
+ * represented in the current encoding this will return null and
+ * turn off the use of system fonts.
+ */
+ private Object getDesktopFontValue(String fontName, Object backup) {
+ if (useSystemFontSettings) {
+ return new WindowsFontProperty(fontName, backup);
+ }
+ return null;
+ }
+
+ // When a desktop property change is detected, these classes must be
+ // reinitialized in the defaults table to ensure the classes reference
+ // the updated desktop property values (colors mostly)
+ //
+ private Object[] getLazyValueDefaults() {
+
+ Object buttonBorder =
+ new XPBorderValue(Part.BP_PUSHBUTTON,
+ (LazyValue) t -> BasicBorders.getButtonBorder());
+
+ Object textFieldBorder =
+ new XPBorderValue(Part.EP_EDIT,
+ (LazyValue) t -> BasicBorders.getTextFieldBorder());
+
+ Object textFieldMargin =
+ new XPValue(new InsetsUIResource(2, 2, 2, 2),
+ new InsetsUIResource(1, 1, 1, 1));
+
+ Object spinnerBorder =
+ new XPBorderValue(Part.EP_EDIT, textFieldBorder,
+ new EmptyBorder(2, 2, 2, 2));
+
+ Object spinnerArrowInsets =
+ new XPValue(new InsetsUIResource(1, 1, 1, 1),
+ null);
+
+ Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder);
+
+ // For focus rectangle for cells and trees.
+ LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
+
+ LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
+
+ LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
+
+ LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
+
+
+ LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
+
+ LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
+
+
+ Object popupMenuBorder = new XPBorderValue(Part.MENU,
+ (LazyValue) t -> BasicBorders.getInternalFrameBorder());
+
+ // *** ProgressBar
+ LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
+
+ LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
+
+ Object scrollPaneBorder =
+ new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
+
+ Object tableScrollPaneBorder =
+ new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
+
+ LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
+
+ // *** ToolBar
+ LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
+
+ // *** ToolTips
+ LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
+
+
+
+ LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
+
+ LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
+
+ LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
+
+ LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
+
+ LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
+
+ LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
+
+ Color highlight = (Color) Toolkit.getDefaultToolkit().
+ getDesktopProperty("win.3d.highlightColor");
+
+ Color shadow = (Color) Toolkit.getDefaultToolkit().
+ getDesktopProperty("win.3d.shadowColor");
+
+ Object[] lazyDefaults = {
+ "Button.border", buttonBorder,
+ "CheckBox.border", radioButtonBorder,
+ "ComboBox.border", comboBoxBorder,
+ "DesktopIcon.border", internalFrameBorder,
+ "FormattedTextField.border", textFieldBorder,
+ "FormattedTextField.margin", textFieldMargin,
+ "InternalFrame.border", internalFrameBorder,
+ "List.focusCellHighlightBorder", focusCellHighlightBorder,
+ "Table.focusCellHighlightBorder", focusCellHighlightBorder,
+ "Menu.border", marginBorder,
+ "MenuBar.border", menuBarBorder,
+ "MenuItem.border", marginBorder,
+ "PasswordField.border", textFieldBorder,
+ "PasswordField.margin", textFieldMargin,
+ "PopupMenu.border", popupMenuBorder,
+ "ProgressBar.border", progressBarBorder,
+ "RadioButton.border", radioButtonBorder,
+ "ScrollPane.border", scrollPaneBorder,
+ "Spinner.border", spinnerBorder,
+ "Spinner.arrowButtonInsets", spinnerArrowInsets,
+ "Spinner.arrowButtonSize", new Dimension(17, 9),
+ "Table.scrollPaneBorder", tableScrollPaneBorder,
+ "TableHeader.cellBorder", tableHeaderBorder,
+ "TextArea.margin", textFieldMargin,
+ "TextField.border", textFieldBorder,
+ "TextField.margin", textFieldMargin,
+ "TitledBorder.border", new UIDefaults.LazyValue() {
+ public Object createValue(UIDefaults table) {
+ return new BorderUIResource.
+ EtchedBorderUIResource(highlight, shadow);
+ }
+ },
+ "ToggleButton.border", radioButtonBorder,
+ "ToolBar.border", toolBarBorder,
+ "ToolTip.border", toolTipBorder,
+
+ "CheckBox.icon", checkBoxIcon,
+ "Menu.arrowIcon", menuArrowIcon,
+ "MenuItem.checkIcon", menuItemCheckIcon,
+ "MenuItem.arrowIcon", menuItemArrowIcon,
+ "RadioButton.icon", radioButtonIcon,
+ "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
+ "InternalFrame.layoutTitlePaneAtOrigin",
+ new XPValue(Boolean.TRUE, Boolean.FALSE),
+ "Table.ascendingSortIcon", new XPValue(
+ (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
+ (LazyValue) t -> new ClassicSortArrowIcon(true)),
+ "Table.descendingSortIcon", new XPValue(
+ (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
+ (LazyValue) t -> new ClassicSortArrowIcon(false)),
+ };
+
+ return lazyDefaults;
+ }
+
+ public void uninitialize() {
+ super.uninitialize();
+
+ if (WindowsPopupMenuUI.mnemonicListener != null) {
+ MenuSelectionManager.defaultManager().
+ removeChangeListener(WindowsPopupMenuUI.mnemonicListener);
+ }
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().
+ removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
+ WindowsDesktopProperty.flushUnreferencedProperties();
+ }
+
+
+ // Toggle flag for drawing the mnemonic state
+ private static boolean isMnemonicHidden = true;
+
+ // Flag which indicates that the Win98/Win2k/WinME features
+ // should be disabled.
+ private static boolean isClassicWindows = false;
+
+ /**
+ * Sets the state of the hide mnemonic flag. This flag is used by the
+ * component UI delegates to determine if the mnemonic should be rendered.
+ * This method is a non operation if the underlying operating system
+ * does not support the mnemonic hiding feature.
+ *
+ * @param hide true if mnemonics should be hidden
+ * @since 1.4
+ */
+ public static void setMnemonicHidden(boolean hide) {
+ if (UIManager.getBoolean("Button.showMnemonics") == true) {
+ // Do not hide mnemonics if the UI defaults do not support this
+ isMnemonicHidden = false;
+ } else {
+ isMnemonicHidden = hide;
+ }
+ }
+
+ /**
+ * Gets the state of the hide mnemonic flag. This only has meaning
+ * if this feature is supported by the underlying OS.
+ *
+ * @return true if mnemonics are hidden, otherwise, false
+ * @see #setMnemonicHidden
+ * @since 1.4
+ */
+ public static boolean isMnemonicHidden() {
+ if (UIManager.getBoolean("Button.showMnemonics") == true) {
+ // Do not hide mnemonics if the UI defaults do not support this
+ isMnemonicHidden = false;
+ }
+ return isMnemonicHidden;
+ }
+
+ /**
+ * Gets the state of the flag which indicates if the old Windows
+ * look and feel should be rendered. This flag is used by the
+ * component UI delegates as a hint to determine which style the component
+ * should be rendered.
+ *
+ * @return true if Windows 95 and Windows NT 4 look and feel should
+ * be rendered
+ * @since 1.4
+ */
+ public static boolean isClassicWindows() {
+ return isClassicWindows;
+ }
+
+ /**
+ * <p>
+ * Invoked when the user attempts an invalid operation,
+ * such as pasting into an uneditable <code>JTextField</code>
+ * that has focus.
+ * </p>
+ * <p>
+ * If the user has enabled visual error indication on
+ * the desktop, this method will flash the caption bar
+ * of the active window. The user can also set the
+ * property awt.visualbell=true to achieve the same
+ * results.
+ * </p>
+ *
+ * @param component Component the error occurred in, may be
+ * null indicating the error condition is
+ * not directly associated with a
+ * <code>Component</code>.
+ *
+ * @see javax.swing.LookAndFeel#provideErrorFeedback
+ */
+ public void provideErrorFeedback(Component component) {
+ super.provideErrorFeedback(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public LayoutStyle getLayoutStyle() {
+ LayoutStyle style = this.style;
+ if (style == null) {
+ style = new WindowsLayoutStyle();
+ this.style = style;
+ }
+ return style;
+ }
+
+ // ********* Auditory Cue support methods and objects *********
+
+ /**
+ * Returns an <code>Action</code>.
+ * <P>
+ * This Action contains the information and logic to render an
+ * auditory cue. The <code>Object</code> that is passed to this
+ * method contains the information needed to render the auditory
+ * cue. Normally, this <code>Object</code> is a <code>String</code>
+ * that points to a <code>Toolkit</code> <code>desktopProperty</code>.
+ * This <code>desktopProperty</code> is resolved by AWT and the
+ * Windows OS.
+ * <P>
+ * This <code>Action</code>'s <code>actionPerformed</code> method
+ * is fired by the <code>playSound</code> method.
+ *
+ * @return an Action which knows how to render the auditory
+ * cue for one particular system or user activity
+ * @see #playSound(Action)
+ * @since 1.4
+ */
+ protected Action createAudioAction(Object key) {
+ if (key != null) {
+ String audioKey = (String)key;
+ String audioValue = (String)UIManager.get(key);
+ return new AudioAction(audioKey, audioValue);
+ } else {
+ return null;
+ }
+ }
+
+ static void repaintRootPane(Component c) {
+ JRootPane root = null;
+ for (; c != null; c = c.getParent()) {
+ if (c instanceof JRootPane) {
+ root = (JRootPane)c;
+ }
+ }
+
+ if (root != null) {
+ root.repaint();
+ } else {
+ c.repaint();
+ }
+ }
+
+ /**
+ * Pass the name String to the super constructor. This is used
+ * later to identify the Action and decide whether to play it or
+ * not. Store the resource String. It is used to get the audio
+ * resource. In this case, the resource is a <code>Runnable</code>
+ * supplied by <code>Toolkit</code>. This <code>Runnable</code> is
+ * effectively a pointer down into the Win32 OS that knows how to
+ * play the right sound.
+ *
+ * @since 1.4
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private static class AudioAction extends AbstractAction {
+ private Runnable audioRunnable;
+ private String audioResource;
+ /**
+ * We use the String as the name of the Action and as a pointer to
+ * the underlying OSes audio resource.
+ */
+ public AudioAction(String name, String resource) {
+ super(name);
+ audioResource = resource;
+ }
+ public void actionPerformed(ActionEvent e) {
+ if (audioRunnable == null) {
+ audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource);
+ }
+ if (audioRunnable != null) {
+ // Runnable appears to block until completed playing, hence
+ // start up another thread to handle playing.
+ new Thread(null, audioRunnable, "Audio", 0, false).start();
+ }
+ }
+ }
+
+ /**
+ * Gets an <code>Icon</code> from the native libraries if available,
+ * otherwise gets it from an image resource file.
+ */
+ private static class LazyWindowsIcon implements UIDefaults.LazyValue {
+ private String nativeImage;
+ private String resource;
+
+ LazyWindowsIcon(String nativeImage, String resource) {
+ this.nativeImage = nativeImage;
+ this.resource = resource;
+ }
+
+ public Object createValue(UIDefaults table) {
+ if (nativeImage != null) {
+ Image image = (Image)ShellFolder.get(nativeImage);
+ if (image != null) {
+ return new ImageIcon(image);
+ }
+ }
+ return SwingUtilities2.makeIcon(getClass(),
+ WindowsLookAndFeel.class,
+ resource);
+ }
+ }
+
+
+ /**
+ * Gets an <code>Icon</code> from the native libraries if available.
+ * A desktop property is used to trigger reloading the icon when needed.
+ */
+ private class ActiveWindowsIcon implements UIDefaults.ActiveValue {
+ private Icon icon;
+ private String nativeImageName;
+ private String fallbackName;
+ private WindowsDesktopProperty desktopProperty;
+
+ ActiveWindowsIcon(String desktopPropertyName,
+ String nativeImageName, String fallbackName) {
+ this.nativeImageName = nativeImageName;
+ this.fallbackName = fallbackName;
+
+ if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
+ OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) {
+ // This desktop property is needed to trigger reloading the icon.
+ // It is kept in member variable to avoid GC.
+ this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) {
+ @Override protected void updateUI() {
+ icon = null;
+ super.updateUI();
+ }
+ };
+ }
+ }
+
+ @Override
+ public Object createValue(UIDefaults table) {
+ if (icon == null) {
+ Image image = (Image)ShellFolder.get(nativeImageName);
+ if (image != null) {
+ icon = new ImageIconUIResource(image);
+ }
+ }
+ if (icon == null && fallbackName != null) {
+ UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
+ SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
+ BasicLookAndFeel.class, fallbackName);
+ icon = (Icon) fallback.createValue(table);
+ }
+ return icon;
+ }
+ }
+
+ /**
+ * Icon backed-up by XP Skin.
+ */
+ private static class SkinIcon implements Icon, UIResource {
+ private final Part part;
+ private final State state;
+ SkinIcon(Part part, State state) {
+ this.part = part;
+ this.state = state;
+ }
+
+ /**
+ * Draw the icon at the specified location. Icon implementations
+ * may use the Component argument to get properties useful for
+ * painting, e.g. the foreground or background color.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ XPStyle xp = XPStyle.getXP();
+ assert xp != null;
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, part);
+ skin.paintSkin(g, x, y, state);
+ }
+ }
+
+ /**
+ * Returns the icon's width.
+ *
+ * @return an int specifying the fixed width of the icon.
+ */
+ public int getIconWidth() {
+ int width = 0;
+ XPStyle xp = XPStyle.getXP();
+ assert xp != null;
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, part);
+ width = skin.getWidth();
+ }
+ return width;
+ }
+
+ /**
+ * Returns the icon's height.
+ *
+ * @return an int specifying the fixed height of the icon.
+ */
+ public int getIconHeight() {
+ int height = 0;
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, part);
+ height = skin.getHeight();
+ }
+ return height;
+ }
+
+ }
+
+ /**
+ * WindowsDesktopProperty for fonts. If a font with the name 'MS Sans Serif'
+ * is returned, it is mapped to 'Microsoft Sans Serif'.
+ */
+ private static class WindowsFontProperty extends WindowsDesktopProperty {
+ WindowsFontProperty(String key, Object backup) {
+ super(key, backup);
+ }
+
+ public void invalidate(LookAndFeel laf) {
+ if ("win.defaultGUI.font.height".equals(getKey())) {
+ ((WindowsLookAndFeel)laf).style = null;
+ }
+ super.invalidate(laf);
+ }
+
+ protected Object configureValue(Object value) {
+ if (value instanceof Font) {
+ Font font = (Font)value;
+ if ("MS Sans Serif".equals(font.getName())) {
+ int size = font.getSize();
+ // 4950968: Workaround to mimic the way Windows maps the default
+ // font size of 6 pts to the smallest available bitmap font size.
+ // This happens mostly on Win 98/Me & NT.
+ int dpi;
+ try {
+ dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+ } catch (HeadlessException ex) {
+ dpi = 96;
+ }
+ if (Math.round(size * 72F / dpi) < 8) {
+ size = Math.round(8 * dpi / 72F);
+ }
+ Font msFont = new FontUIResource("Microsoft Sans Serif",
+ font.getStyle(), size);
+ if (msFont.getName() != null &&
+ msFont.getName().equals(msFont.getFamily())) {
+ font = msFont;
+ } else if (size != font.getSize()) {
+ font = new FontUIResource("MS Sans Serif",
+ font.getStyle(), size);
+ }
+ }
+
+ if (FontUtilities.fontSupportsDefaultEncoding(font)) {
+ if (!(font instanceof UIResource)) {
+ font = new FontUIResource(font);
+ }
+ }
+ else {
+ font = FontUtilities.getCompositeFontUIResource(font);
+ }
+ return font;
+
+ }
+ return super.configureValue(value);
+ }
+ }
+
+
+ /**
+ * WindowsDesktopProperty for fonts that only gets sizes from the desktop,
+ * font name and style are passed into the constructor
+ */
+ private static class WindowsFontSizeProperty extends
+ WindowsDesktopProperty {
+ private String fontName;
+ private int fontSize;
+ private int fontStyle;
+
+ WindowsFontSizeProperty(String key, String fontName,
+ int fontStyle, int fontSize) {
+ super(key, null);
+ this.fontName = fontName;
+ this.fontSize = fontSize;
+ this.fontStyle = fontStyle;
+ }
+
+ protected Object configureValue(Object value) {
+ if (value == null) {
+ value = new FontUIResource(fontName, fontStyle, fontSize);
+ }
+ else if (value instanceof Integer) {
+ value = new FontUIResource(fontName, fontStyle,
+ ((Integer)value).intValue());
+ }
+ return value;
+ }
+ }
+
+
+ /**
+ * A value wrapper that actively retrieves values from xp or falls back
+ * to the classic value if not running XP styles.
+ */
+ private static class XPValue implements UIDefaults.ActiveValue {
+ protected Object classicValue, xpValue;
+
+ // A constant that lets you specify null when using XP styles.
+ private static final Object NULL_VALUE = new Object();
+
+ XPValue(Object xpValue, Object classicValue) {
+ this.xpValue = xpValue;
+ this.classicValue = classicValue;
+ }
+
+ public Object createValue(UIDefaults table) {
+ Object value = null;
+ if (XPStyle.getXP() != null) {
+ value = getXPValue(table);
+ }
+
+ if (value == null) {
+ value = getClassicValue(table);
+ } else if (value == NULL_VALUE) {
+ value = null;
+ }
+
+ return value;
+ }
+
+ protected Object getXPValue(UIDefaults table) {
+ return recursiveCreateValue(xpValue, table);
+ }
+
+ protected Object getClassicValue(UIDefaults table) {
+ return recursiveCreateValue(classicValue, table);
+ }
+
+ private Object recursiveCreateValue(Object value, UIDefaults table) {
+ if (value instanceof UIDefaults.LazyValue) {
+ value = ((UIDefaults.LazyValue)value).createValue(table);
+ }
+ if (value instanceof UIDefaults.ActiveValue) {
+ return ((UIDefaults.ActiveValue)value).createValue(table);
+ } else {
+ return value;
+ }
+ }
+ }
+
+ private static class XPBorderValue extends XPValue {
+ private final Border extraMargin;
+
+ XPBorderValue(Part xpValue, Object classicValue) {
+ this(xpValue, classicValue, null);
+ }
+
+ XPBorderValue(Part xpValue, Object classicValue, Border extraMargin) {
+ super(xpValue, classicValue);
+ this.extraMargin = extraMargin;
+ }
+
+ public Object getXPValue(UIDefaults table) {
+ XPStyle xp = XPStyle.getXP();
+ Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null;
+ if (xpBorder != null && extraMargin != null) {
+ return new BorderUIResource.
+ CompoundBorderUIResource(xpBorder, extraMargin);
+ } else {
+ return xpBorder;
+ }
+ }
+ }
+
+ private static class XPColorValue extends XPValue {
+ XPColorValue(Part part, State state, Prop prop, Object classicValue) {
+ super(new XPColorValueKey(part, state, prop), classicValue);
+ }
+
+ public Object getXPValue(UIDefaults table) {
+ XPColorValueKey key = (XPColorValueKey)xpValue;
+ XPStyle xp = XPStyle.getXP();
+ return xp != null ? xp.getColor(key.skin, key.prop, null) : null;
+ }
+
+ private static class XPColorValueKey {
+ Skin skin;
+ Prop prop;
+
+ XPColorValueKey(Part part, State state, Prop prop) {
+ this.skin = new Skin(part, state);
+ this.prop = prop;
+ }
+ }
+ }
+
+ private class XPDLUValue extends XPValue {
+ private int direction;
+
+ XPDLUValue(int xpdlu, int classicdlu, int direction) {
+ super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu));
+ this.direction = direction;
+ }
+
+ public Object getXPValue(UIDefaults table) {
+ int px = dluToPixels(((Integer)xpValue).intValue(), direction);
+ return Integer.valueOf(px);
+ }
+
+ public Object getClassicValue(UIDefaults table) {
+ int px = dluToPixels(((Integer)classicValue).intValue(), direction);
+ return Integer.valueOf(px);
+ }
+ }
+
+ private class TriggerDesktopProperty extends WindowsDesktopProperty {
+ TriggerDesktopProperty(String key) {
+ super(key, null);
+ // This call adds a property change listener for the property,
+ // which triggers a call to updateUI(). The value returned
+ // is not interesting here.
+ getValueFromDesktop();
+ }
+
+ protected void updateUI() {
+ super.updateUI();
+
+ // Make sure property change listener is readded each time
+ getValueFromDesktop();
+ }
+ }
+
+ private class FontDesktopProperty extends TriggerDesktopProperty {
+ FontDesktopProperty(String key) {
+ super(key);
+ }
+
+ protected void updateUI() {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ SwingUtilities2.putAATextInfo(true, defaults);
+ super.updateUI();
+ }
+ }
+
+ // Windows LayoutStyle. From:
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
+ @SuppressWarnings("fallthrough")
+ private class WindowsLayoutStyle extends DefaultLayoutStyle {
+ @Override
+ public int getPreferredGap(JComponent component1,
+ JComponent component2, ComponentPlacement type, int position,
+ Container parent) {
+ // Checks args
+ super.getPreferredGap(component1, component2, type, position,
+ parent);
+
+ switch(type) {
+ case INDENT:
+ // Windows doesn't spec this
+ if (position == SwingConstants.EAST ||
+ position == SwingConstants.WEST) {
+ int indent = getIndent(component1, position);
+ if (indent > 0) {
+ return indent;
+ }
+ return 10;
+ }
+ // Fall through to related.
+ case RELATED:
+ if (isLabelAndNonlabel(component1, component2, position)) {
+ // Between text labels and their associated controls (for
+ // example, text boxes and list boxes): 3
+ // NOTE: We're not honoring:
+ // 'Text label beside a button 3 down from the top of
+ // the button,' but I suspect that is an attempt to
+ // enforce a baseline layout which will be handled
+ // separately. In order to enforce this we would need
+ // this API to return a more complicated type (Insets,
+ // or something else).
+ return getButtonGap(component1, component2, position,
+ dluToPixels(3, position));
+ }
+ // Between related controls: 4
+ return getButtonGap(component1, component2, position,
+ dluToPixels(4, position));
+ case UNRELATED:
+ // Between unrelated controls: 7
+ return getButtonGap(component1, component2, position,
+ dluToPixels(7, position));
+ }
+ return 0;
+ }
+
+ @Override
+ public int getContainerGap(JComponent component, int position,
+ Container parent) {
+ // Checks args
+ super.getContainerGap(component, position, parent);
+ return getButtonGap(component, position, dluToPixels(7, position));
+ }
+
+ }
+
+ /**
+ * Converts the dialog unit argument to pixels along the specified
+ * axis.
+ */
+ private int dluToPixels(int dlu, int direction) {
+ if (baseUnitX == 0) {
+ calculateBaseUnits();
+ }
+ if (direction == SwingConstants.EAST ||
+ direction == SwingConstants.WEST) {
+ return dlu * baseUnitX / 4;
+ }
+ assert (direction == SwingConstants.NORTH ||
+ direction == SwingConstants.SOUTH);
+ return dlu * baseUnitY / 8;
+ }
+
+ /**
+ * Calculates the dialog unit mapping.
+ */
+ @SuppressWarnings("deprecation")
+ private void calculateBaseUnits() {
+ // This calculation comes from:
+ // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
+ FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
+ UIManager.getFont("Button.font"));
+ baseUnitX = metrics.stringWidth(
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
+ baseUnitX = (baseUnitX / 26 + 1) / 2;
+ // The -1 comes from experimentation.
+ baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since 1.6
+ */
+ public Icon getDisabledIcon(JComponent component, Icon icon) {
+ // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
+ // client property set to Boolean.TRUE, then use the new
+ // hi res algorithm for creating the disabled icon (used
+ // in particular by the WindowsFileChooserUI class)
+ if (icon != null
+ && component != null
+ && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
+ && icon.getIconWidth() > 0
+ && icon.getIconHeight() > 0) {
+ BufferedImage img = new BufferedImage(icon.getIconWidth(),
+ icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
+ icon.paintIcon(component, img.getGraphics(), 0, 0);
+ ImageFilter filter = new RGBGrayFilter();
+ ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
+ Image resultImage = component.createImage(producer);
+ return new ImageIconUIResource(resultImage);
+ }
+ return super.getDisabledIcon(component, icon);
+ }
+
+ private static class RGBGrayFilter extends RGBImageFilter {
+ public RGBGrayFilter() {
+ canFilterIndexColorModel = true;
+ }
+ public int filterRGB(int x, int y, int rgb) {
+ // find the average of red, green, and blue
+ float avg = (((rgb >> 16) & 0xff) / 255f +
+ ((rgb >> 8) & 0xff) / 255f +
+ (rgb & 0xff) / 255f) / 3;
+ // pull out the alpha channel
+ float alpha = (((rgb>>24)&0xff)/255f);
+ // calc the average
+ avg = Math.min(1.0f, (1f-avg)/(100.0f/35.0f) + avg);
+ // turn back into rgb
+ int rgbval = (int)(alpha * 255f) << 24 |
+ (int)(avg * 255f) << 16 |
+ (int)(avg * 255f) << 8 |
+ (int)(avg * 255f);
+ return rgbval;
+ }
+ }
+
+ private static class FocusColorProperty extends WindowsDesktopProperty {
+ public FocusColorProperty () {
+ // Fallback value is never used because of the configureValue method doesn't return null
+ super("win.3d.backgroundColor", Color.BLACK);
+ }
+
+ @Override
+ protected Object configureValue(Object value) {
+ Object highContrastOn = Toolkit.getDefaultToolkit().
+ getDesktopProperty("win.highContrast.on");
+ if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) {
+ return Color.BLACK;
+ }
+ return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import java.awt.event.ActionEvent;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.awt.event.WindowStateListener;
+
+import java.awt.*;
+
+import com.sun.java.swing.plaf.windows.TMSchema.*;
+import com.sun.java.swing.plaf.windows.XPStyle.*;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsMenuBarUI extends BasicMenuBarUI
+{
+ /* to be accessed on the EDT only */
+ private WindowListener windowListener = null;
+ private HierarchyListener hierarchyListener = null;
+ private Window window = null;
+
+ public static ComponentUI createUI(JComponent x) {
+ return new WindowsMenuBarUI();
+ }
+
+ @Override
+ protected void uninstallListeners() {
+ uninstallWindowListener();
+ if (hierarchyListener != null) {
+ menuBar.removeHierarchyListener(hierarchyListener);
+ hierarchyListener = null;
+ }
+ super.uninstallListeners();
+ }
+ private void installWindowListener() {
+ if (windowListener == null) {
+ Component component = menuBar.getTopLevelAncestor();
+ if (component instanceof Window) {
+ window = (Window) component;
+ windowListener = new WindowAdapter() {
+ @Override
+ public void windowActivated(WindowEvent e) {
+ menuBar.repaint();
+ }
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ menuBar.repaint();
+ }
+ };
+ ((Window) component).addWindowListener(windowListener);
+ }
+ }
+ }
+ private void uninstallWindowListener() {
+ if (windowListener != null && window != null) {
+ window.removeWindowListener(windowListener);
+ }
+ window = null;
+ windowListener = null;
+ }
+ @Override
+ protected void installListeners() {
+ if (WindowsLookAndFeel.isOnVista()) {
+ installWindowListener();
+ hierarchyListener =
+ new HierarchyListener() {
+ public void hierarchyChanged(HierarchyEvent e) {
+ if ((e.getChangeFlags()
+ & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
+ if (menuBar.isDisplayable()) {
+ installWindowListener();
+ } else {
+ uninstallWindowListener();
+ }
+ }
+ }
+ };
+ menuBar.addHierarchyListener(hierarchyListener);
+ }
+ super.installListeners();
+ }
+
+ protected void installKeyboardActions() {
+ super.installKeyboardActions();
+ ActionMap map = SwingUtilities.getUIActionMap(menuBar);
+ if (map == null) {
+ map = new ActionMapUIResource();
+ SwingUtilities.replaceUIActionMap(menuBar, map);
+ }
+ map.put("takeFocus", new TakeFocus());
+ }
+
+ /**
+ * Action that activates the menu (e.g. when F10 is pressed).
+ * Unlike BasicMenuBarUI.TakeFocus, this Action will not show menu popup.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private static class TakeFocus extends AbstractAction {
+ public void actionPerformed(ActionEvent e) {
+ JMenuBar menuBar = (JMenuBar)e.getSource();
+ JMenu menu = menuBar.getMenu(0);
+ if (menu != null) {
+ MenuSelectionManager msm =
+ MenuSelectionManager.defaultManager();
+ MenuElement path[] = new MenuElement[2];
+ path[0] = (MenuElement)menuBar;
+ path[1] = (MenuElement)menu;
+ msm.setSelectedPath(path);
+
+ // show mnemonics
+ WindowsLookAndFeel.setMnemonicHidden(false);
+ WindowsLookAndFeel.repaintRootPane(menuBar);
+ }
+ }
+ }
+
+ @Override
+ public void paint(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ Skin skin;
+ skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
+ int width = c.getWidth();
+ int height = c.getHeight();
+ State state = isActive(c) ? State.ACTIVE : State.INACTIVE;
+ skin.paintSkin(g, 0, 0, width, height, state);
+ } else {
+ super.paint(g, c);
+ }
+ }
+
+ /**
+ * Checks if component belongs to an active window.
+ * @param c component to check
+ * @return true if component belongs to an active window
+ */
+ static boolean isActive(JComponent c) {
+ JRootPane rootPane = c.getRootPane();
+ if (rootPane != null) {
+ Component component = rootPane.getParent();
+ if (component instanceof Window) {
+ return ((Window) component).isActive();
+ }
+ }
+ return true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+import sun.swing.SwingUtilities2;
+
+import com.sun.java.swing.plaf.windows.TMSchema.*;
+import com.sun.java.swing.plaf.windows.XPStyle.*;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Igor Kushnirskiy
+ */
+
+public class WindowsMenuItemUI extends BasicMenuItemUI {
+ final WindowsMenuItemUIAccessor accessor =
+ new WindowsMenuItemUIAccessor() {
+
+ public JMenuItem getMenuItem() {
+ return menuItem;
+ }
+
+ public State getState(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getState(this, menuItem);
+ }
+
+ public Part getPart(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getPart(this, menuItem);
+ }
+ };
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsMenuItemUI();
+ }
+
+ /**
+ * Method which renders the text of the current menu item.
+ *
+ * @param g Graphics context
+ * @param menuItem Current menu item to render
+ * @param textRect Bounding rectangle to render the text.
+ * @param text String to render
+ */
+ protected void paintText(Graphics g, JMenuItem menuItem,
+ Rectangle textRect, String text) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
+ return;
+ }
+ ButtonModel model = menuItem.getModel();
+ Color oldColor = g.getColor();
+
+ if(model.isEnabled() &&
+ (model.isArmed() || (menuItem instanceof JMenu &&
+ model.isSelected()))) {
+ g.setColor(selectionForeground); // Uses protected field.
+ }
+
+ WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
+
+ g.setColor(oldColor);
+ }
+
+ @Override
+ protected void paintBackground(Graphics g, JMenuItem menuItem,
+ Color bgColor) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
+ return;
+ }
+ super.paintBackground(g, menuItem, bgColor);
+ }
+
+ static void paintBackground(WindowsMenuItemUIAccessor menuItemUI,
+ Graphics g, JMenuItem menuItem, Color bgColor) {
+ XPStyle xp = XPStyle.getXP();
+ assert isVistaPainting(xp);
+ if (isVistaPainting(xp)) {
+ int menuWidth = menuItem.getWidth();
+ int menuHeight = menuItem.getHeight();
+ if (menuItem.isOpaque()) {
+ Color oldColor = g.getColor();
+ g.setColor(menuItem.getBackground());
+ g.fillRect(0,0, menuWidth, menuHeight);
+ g.setColor(oldColor);
+ }
+ Part part = menuItemUI.getPart(menuItem);
+ Skin skin = xp.getSkin(menuItem, part);
+ skin.paintSkin(g, 0 , 0,
+ menuWidth,
+ menuHeight,
+ menuItemUI.getState(menuItem));
+ }
+ }
+
+ static void paintText(WindowsMenuItemUIAccessor menuItemUI, Graphics g,
+ JMenuItem menuItem, Rectangle textRect,
+ String text) {
+ assert isVistaPainting();
+ if (isVistaPainting()) {
+ State state = menuItemUI.getState(menuItem);
+
+ /* part of it copied from WindowsGraphicsUtils.java */
+ FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
+ int mnemIndex = menuItem.getDisplayedMnemonicIndex();
+ // W2K Feature: Check to see if the Underscore should be rendered.
+ if (WindowsLookAndFeel.isMnemonicHidden() == true) {
+ mnemIndex = -1;
+ }
+ WindowsGraphicsUtils.paintXPText(menuItem,
+ menuItemUI.getPart(menuItem), state,
+ g, textRect.x,
+ textRect.y + fm.getAscent(),
+ text, mnemIndex);
+ }
+ }
+
+ static State getState(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
+ State state;
+ ButtonModel model = menuItem.getModel();
+ if (model.isArmed()) {
+ state = (model.isEnabled()) ? State.HOT : State.DISABLEDHOT;
+ } else {
+ state = (model.isEnabled()) ? State.NORMAL : State.DISABLED;
+ }
+ return state;
+ }
+
+ static Part getPart(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
+ return Part.MP_POPUPITEM;
+ }
+
+ /*
+ * TODO idk can we use XPStyle.isVista?
+ * is it possible that in some theme some Vista parts are not defined while
+ * others are?
+ */
+ static boolean isVistaPainting(final XPStyle xp) {
+ return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM);
+ }
+
+ static boolean isVistaPainting() {
+ return isVistaPainting(XPStyle.getXP());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUIAccessor.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+import javax.swing.JMenuItem;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+
+/**
+ * Accessor interface for WindowsMenuItemUI to allow for "multiple implementation
+ * inheritance".
+ *
+ * @author Igor Kushnirskiy
+ */
+interface WindowsMenuItemUIAccessor {
+ JMenuItem getMenuItem();
+ State getState(JMenuItem menuItem);
+ Part getPart(JMenuItem menuItem);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicMenuUI;
+import javax.swing.event.MouseInputListener;
+import javax.swing.*;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsMenuUI extends BasicMenuUI {
+ protected Integer menuBarHeight;
+ protected boolean hotTrackingOn;
+
+ final WindowsMenuItemUIAccessor accessor =
+ new WindowsMenuItemUIAccessor() {
+
+ public JMenuItem getMenuItem() {
+ return menuItem;
+ }
+
+ public State getState(JMenuItem menu) {
+ State state = menu.isEnabled() ? State.NORMAL
+ : State.DISABLED;
+ ButtonModel model = menu.getModel();
+ if (model.isArmed() || model.isSelected()) {
+ state = (menu.isEnabled()) ? State.PUSHED
+ : State.DISABLEDPUSHED;
+ } else if (model.isRollover()
+ && ((JMenu) menu).isTopLevelMenu()) {
+ /*
+ * Only paint rollover if no other menu on menubar is
+ * selected
+ */
+ State stateTmp = state;
+ state = (menu.isEnabled()) ? State.HOT
+ : State.DISABLEDHOT;
+ for (MenuElement menuElement :
+ ((JMenuBar) menu.getParent()).getSubElements()) {
+ if (((JMenuItem) menuElement).isSelected()) {
+ state = stateTmp;
+ break;
+ }
+ }
+ }
+
+ //non top level menus have HOT state instead of PUSHED
+ if (!((JMenu) menu).isTopLevelMenu()) {
+ if (state == State.PUSHED) {
+ state = State.HOT;
+ } else if (state == State.DISABLEDPUSHED) {
+ state = State.DISABLEDHOT;
+ }
+ }
+
+ /*
+ * on Vista top level menu for non active frame looks disabled
+ */
+ if (((JMenu) menu).isTopLevelMenu() && WindowsMenuItemUI.isVistaPainting()) {
+ if (! WindowsMenuBarUI.isActive(menu)) {
+ state = State.DISABLED;
+ }
+ }
+ return state;
+ }
+
+ public Part getPart(JMenuItem menuItem) {
+ return ((JMenu) menuItem).isTopLevelMenu() ? Part.MP_BARITEM
+ : Part.MP_POPUPITEM;
+ }
+ };
+ public static ComponentUI createUI(JComponent x) {
+ return new WindowsMenuUI();
+ }
+
+ protected void installDefaults() {
+ super.installDefaults();
+ if (!WindowsLookAndFeel.isClassicWindows()) {
+ menuItem.setRolloverEnabled(true);
+ }
+
+ menuBarHeight = (Integer)UIManager.getInt("MenuBar.height");
+
+ Object obj = UIManager.get("MenuBar.rolloverEnabled");
+ hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
+ }
+
+ /**
+ * Draws the background of the menu.
+ * @since 1.4
+ */
+ protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
+ return;
+ }
+
+ JMenu menu = (JMenu)menuItem;
+ ButtonModel model = menu.getModel();
+
+ // Use superclass method for the old Windows LAF,
+ // for submenus, and for XP toplevel if selected or pressed
+ if (WindowsLookAndFeel.isClassicWindows() ||
+ !menu.isTopLevelMenu() ||
+ (XPStyle.getXP() != null && (model.isArmed() || model.isSelected()))) {
+
+ super.paintBackground(g, menu, bgColor);
+ return;
+ }
+
+ Color oldColor = g.getColor();
+ int menuWidth = menu.getWidth();
+ int menuHeight = menu.getHeight();
+
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+ Color highlight = table.getColor("controlLtHighlight");
+ Color shadow = table.getColor("controlShadow");
+
+ g.setColor(menu.getBackground());
+ g.fillRect(0,0, menuWidth, menuHeight);
+
+ if (menu.isOpaque()) {
+ if (model.isArmed() || model.isSelected()) {
+ // Draw a lowered bevel border
+ g.setColor(shadow);
+ g.drawLine(0,0, menuWidth - 1,0);
+ g.drawLine(0,0, 0,menuHeight - 2);
+
+ g.setColor(highlight);
+ g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
+ g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
+ } else if (model.isRollover() && model.isEnabled()) {
+ // Only paint rollover if no other menu on menubar is selected
+ boolean otherMenuSelected = false;
+ MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
+ for (int i = 0; i < menus.length; i++) {
+ if (((JMenuItem)menus[i]).isSelected()) {
+ otherMenuSelected = true;
+ break;
+ }
+ }
+ if (!otherMenuSelected) {
+ if (XPStyle.getXP() != null) {
+ g.setColor(selectionBackground); // Uses protected field.
+ g.fillRect(0, 0, menuWidth, menuHeight);
+ } else {
+ // Draw a raised bevel border
+ g.setColor(highlight);
+ g.drawLine(0,0, menuWidth - 1,0);
+ g.drawLine(0,0, 0,menuHeight - 2);
+
+ g.setColor(shadow);
+ g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
+ g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
+ }
+ }
+ }
+ }
+ g.setColor(oldColor);
+ }
+
+ /**
+ * Method which renders the text of the current menu item.
+ *
+ * @param g Graphics context
+ * @param menuItem Current menu item to render
+ * @param textRect Bounding rectangle to render the text.
+ * @param text String to render
+ * @since 1.4
+ */
+ protected void paintText(Graphics g, JMenuItem menuItem,
+ Rectangle textRect, String text) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
+ return;
+ }
+ JMenu menu = (JMenu)menuItem;
+ ButtonModel model = menuItem.getModel();
+ Color oldColor = g.getColor();
+
+ // Only paint rollover if no other menu on menubar is selected
+ boolean paintRollover = model.isRollover();
+ if (paintRollover && menu.isTopLevelMenu()) {
+ MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
+ for (int i = 0; i < menus.length; i++) {
+ if (((JMenuItem)menus[i]).isSelected()) {
+ paintRollover = false;
+ break;
+ }
+ }
+ }
+
+ if ((model.isSelected() && (WindowsLookAndFeel.isClassicWindows() ||
+ !menu.isTopLevelMenu())) ||
+ (XPStyle.getXP() != null && (paintRollover ||
+ model.isArmed() ||
+ model.isSelected()))) {
+ g.setColor(selectionForeground); // Uses protected field.
+ }
+
+ WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
+
+ g.setColor(oldColor);
+ }
+
+ protected MouseInputListener createMouseInputListener(JComponent c) {
+ return new WindowsMouseInputHandler();
+ }
+
+ /**
+ * This class implements a mouse handler that sets the rollover flag to
+ * true when the mouse enters the menu and false when it exits.
+ * @since 1.4
+ */
+ protected class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler {
+ public void mouseEntered(MouseEvent evt) {
+ super.mouseEntered(evt);
+
+ JMenu menu = (JMenu)evt.getSource();
+ if (hotTrackingOn && menu.isTopLevelMenu() && menu.isRolloverEnabled()) {
+ menu.getModel().setRollover(true);
+ menuItem.repaint();
+ }
+ }
+
+ public void mouseExited(MouseEvent evt) {
+ super.mouseExited(evt);
+
+ JMenu menu = (JMenu)evt.getSource();
+ ButtonModel model = menu.getModel();
+ if (menu.isRolloverEnabled()) {
+ model.setRollover(false);
+ menuItem.repaint();
+ }
+ }
+ }
+
+ protected Dimension getPreferredMenuItemSize(JComponent c,
+ Icon checkIcon,
+ Icon arrowIcon,
+ int defaultTextIconGap) {
+
+ Dimension d = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon,
+ defaultTextIconGap);
+
+ // Note: When toolbar containers (rebars) are implemented, only do
+ // this if the JMenuBar is not in a rebar (i.e. ignore the desktop
+ // property win.menu.height if in a rebar.)
+ if (c instanceof JMenu && ((JMenu)c).isTopLevelMenu() &&
+ menuBarHeight != null && d.height < menuBarHeight) {
+
+ d.height = menuBarHeight;
+ }
+
+ return d;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsOptionPaneUI extends BasicOptionPaneUI {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.text.Caret;
+
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsPasswordFieldUI extends BasicPasswordFieldUI {
+
+ /**
+ * Creates a UI for a JPasswordField
+ *
+ * @param c the password field
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsPasswordFieldUI();
+ }
+
+
+ /**
+ * Creates the object to use for a caret. By default an
+ * instance of WindowsCaret is created. This method
+ * can be redefined to provide something else that implements
+ * the InputPosition interface or a subclass of DefaultCaret.
+ *
+ * @return the caret object
+ */
+ protected Caret createCaret() {
+ return new WindowsTextUI.WindowsCaret();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI;
+import javax.swing.plaf.ComponentUI;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+import com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+/**
+ * Windows {@literal L&F} implementation of PopupMenuSeparatorUI.
+ *
+ * @author Leif Samuelsson
+ * @author Igor Kushnirskiy
+ */
+
+public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsPopupMenuSeparatorUI();
+ }
+
+ public void paint(Graphics g, JComponent c) {
+ Dimension s = c.getSize();
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ int x = 1;
+ Component parent = c.getParent();
+ if (parent instanceof JComponent) {
+ Object gutterOffsetObject =
+ ((JComponent) parent).getClientProperty(
+ WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
+ if (gutterOffsetObject instanceof Integer) {
+ /*
+ * gutter offset is in parent's coordinates.
+ * See comment in
+ * WindowsPopupMenuUI.getTextOffset(JComponent)
+ */
+ x = ((Integer) gutterOffsetObject).intValue() - c.getX();
+ x += WindowsPopupMenuUI.getGutterWidth();
+ }
+ }
+ Skin skin = xp.getSkin(c, Part.MP_POPUPSEPARATOR);
+ int skinHeight = skin.getHeight();
+ int y = (s.height - skinHeight) / 2;
+ skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
+ } else {
+ int y = s.height / 2;
+ g.setColor(c.getForeground());
+ g.drawLine(1, y - 1, s.width - 2, y - 1);
+
+ g.setColor(c.getBackground());
+ g.drawLine(1, y, s.width - 2, y);
+ }
+ }
+
+ public Dimension getPreferredSize(JComponent c) {
+ int fontHeight = 0;
+ Font font = c.getFont();
+ if (font != null) {
+ fontHeight = c.getFontMetrics(font).getHeight();
+ }
+
+ return new Dimension(0, fontHeight/2 + 2);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.KeyEventPostProcessor;
+import java.awt.KeyboardFocusManager;
+import java.awt.Window;
+import java.awt.event.KeyEvent;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+import sun.swing.StringUIClientPropertyKey;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+import com.sun.java.swing.plaf.windows.XPStyle.Skin;
+import static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Igor Kushnirskiy
+ */
+public class WindowsPopupMenuUI extends BasicPopupMenuUI {
+
+ static MnemonicListener mnemonicListener = null;
+ static final Object GUTTER_OFFSET_KEY =
+ new StringUIClientPropertyKey("GUTTER_OFFSET_KEY");
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsPopupMenuUI();
+ }
+
+ public void installListeners() {
+ super.installListeners();
+ if (! UIManager.getBoolean("Button.showMnemonics") &&
+ mnemonicListener == null) {
+
+ mnemonicListener = new MnemonicListener();
+ MenuSelectionManager.defaultManager().
+ addChangeListener(mnemonicListener);
+ }
+ }
+
+ /**
+ * Returns the <code>Popup</code> that will be responsible for
+ * displaying the <code>JPopupMenu</code>.
+ *
+ * @param popupMenu JPopupMenu requesting Popup
+ * @param x Screen x location Popup is to be shown at
+ * @param y Screen y location Popup is to be shown at.
+ * @return Popup that will show the JPopupMenu
+ * @since 1.4
+ */
+ public Popup getPopup(JPopupMenu popupMenu, int x, int y) {
+ PopupFactory popupFactory = PopupFactory.getSharedInstance();
+ return popupFactory.getPopup(popupMenu.getInvoker(), popupMenu, x, y);
+ }
+
+ static class MnemonicListener implements ChangeListener {
+ JRootPane repaintRoot = null;
+
+ public void stateChanged(ChangeEvent ev) {
+ MenuSelectionManager msm = (MenuSelectionManager)ev.getSource();
+ MenuElement[] path = msm.getSelectedPath();
+ if (path.length == 0) {
+ if(!WindowsLookAndFeel.isMnemonicHidden()) {
+ // menu was canceled -- hide mnemonics
+ WindowsLookAndFeel.setMnemonicHidden(true);
+ if (repaintRoot != null) {
+ Window win =
+ SwingUtilities.getWindowAncestor(repaintRoot);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(win);
+ }
+ }
+ } else {
+ Component c = (Component)path[0];
+ if (c instanceof JPopupMenu) c = ((JPopupMenu)c).getInvoker();
+ repaintRoot = SwingUtilities.getRootPane(c);
+ }
+ }
+ }
+
+ /**
+ * Returns offset for the text.
+ * BasicMenuItemUI sets max text offset on the JPopupMenuUI.
+ * @param c PopupMenu to return text offset for.
+ * @return text offset for the component
+ */
+ static int getTextOffset(JComponent c) {
+ int rv = -1;
+ Object maxTextOffset =
+ c.getClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET);
+ if (maxTextOffset instanceof Integer) {
+ /*
+ * this is in JMenuItem coordinates.
+ * Let's assume all the JMenuItem have the same offset along X.
+ */
+ rv = (Integer) maxTextOffset;
+ int menuItemOffset = 0;
+ Component component = c.getComponent(0);
+ if (component != null) {
+ menuItemOffset = component.getX();
+ }
+ rv += menuItemOffset;
+ }
+ return rv;
+ }
+
+ /**
+ * Returns span before gutter.
+ * used only on Vista.
+ * @return span before gutter
+ */
+ static int getSpanBeforeGutter() {
+ return 3;
+ }
+
+ /**
+ * Returns span after gutter.
+ * used only on Vista.
+ * @return span after gutter
+ */
+ static int getSpanAfterGutter() {
+ return 3;
+ }
+
+ /**
+ * Returns gutter width.
+ * used only on Vista.
+ * @return width of the gutter
+ */
+ static int getGutterWidth() {
+ int rv = 2;
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPGUTTER);
+ rv = skin.getWidth();
+ }
+ return rv;
+ }
+
+ /**
+ * Checks if PopupMenu is leftToRight
+ * The orientation is derived from the children of the component.
+ * It is leftToRight if all the children are leftToRight
+ *
+ * @param c component to return orientation for
+ * @return true if all the children are leftToRight
+ */
+ private static boolean isLeftToRight(JComponent c) {
+ boolean leftToRight = true;
+ for (int i = c.getComponentCount() - 1; i >=0 && leftToRight; i-- ) {
+ leftToRight =
+ c.getComponent(i).getComponentOrientation().isLeftToRight();
+ }
+ return leftToRight;
+ }
+
+ @Override
+ public void paint(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (WindowsMenuItemUI.isVistaPainting(xp)) {
+ Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND);
+ skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL);
+ int textOffset = getTextOffset(c);
+ if (textOffset >= 0
+ /* paint gutter only for leftToRight case */
+ && isLeftToRight(c)) {
+ skin = xp.getSkin(c, Part.MP_POPUPGUTTER);
+ int gutterWidth = getGutterWidth();
+ int gutterOffset =
+ textOffset - getSpanAfterGutter() - gutterWidth;
+ c.putClientProperty(GUTTER_OFFSET_KEY,
+ Integer.valueOf(gutterOffset));
+ Insets insets = c.getInsets();
+ skin.paintSkin(g, gutterOffset, insets.top,
+ gutterWidth, c.getHeight() - insets.bottom - insets.top,
+ State.NORMAL);
+ } else {
+ if (c.getClientProperty(GUTTER_OFFSET_KEY) != null) {
+ c.putClientProperty(GUTTER_OFFSET_KEY, null);
+ }
+ }
+ } else {
+ super.paint(g, c);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.JWindow;
+import java.awt.Window;
+import java.awt.Graphics;
+
+/**
+ * A class which tags a window with a particular semantic usage,
+ * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
+ * This is used as a temporary solution for getting native AWT support
+ * for transition effects in Windows 98 and Windows 2000. The native
+ * code will interpret the windowType property and automatically
+ * implement appropriate animation when the window is shown/hidden.
+ * <p>
+ * Note that support for transition effects may be supported with a
+ * different mechanism in the future and so this class is
+ * package-private and targeted for Swing implementation use only.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Amy Fowler
+ */
+@SuppressWarnings("serial") // Superclass is not serializable across versions
+class WindowsPopupWindow extends JWindow {
+
+ static final int UNDEFINED_WINDOW_TYPE = 0;
+ static final int TOOLTIP_WINDOW_TYPE = 1;
+ static final int MENU_WINDOW_TYPE = 2;
+ static final int SUBMENU_WINDOW_TYPE = 3;
+ static final int POPUPMENU_WINDOW_TYPE = 4;
+ static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
+
+ private int windowType;
+
+ WindowsPopupWindow(Window parent) {
+ super(parent);
+ setFocusableWindowState(false);
+ }
+
+ void setWindowType(int type) {
+ windowType = type;
+ }
+
+ int getWindowType() {
+ return windowType;
+ }
+
+ public void update(Graphics g) {
+ paint(g);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void hide() {
+ super.hide();
+ /** We need to call removeNotify() here because hide() does
+ * something only if Component.visible is true. When the app
+ * frame is miniaturized, the parent frame of this frame is
+ * invisible, causing AWT to believe that this frame
+ * is invisible and causing hide() to do nothing
+ */
+ removeNotify();
+ }
+
+ @SuppressWarnings("deprecation")
+ public void show() {
+ super.show();
+ this.pack();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.*;
+import javax.swing.*;
+import java.awt.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Michael C. Albers
+ */
+public class WindowsProgressBarUI extends BasicProgressBarUI
+{
+
+ private Rectangle previousFullBox;
+ private Insets indeterminateInsets;
+
+ public static ComponentUI createUI(JComponent x) {
+ return new WindowsProgressBarUI();
+ }
+
+
+ protected void installDefaults() {
+ super.installDefaults();
+
+ if (XPStyle.getXP() != null) {
+ LookAndFeel.installProperty(progressBar, "opaque", Boolean.FALSE);
+ progressBar.setBorder(null);
+ indeterminateInsets = UIManager.getInsets("ProgressBar.indeterminateInsets");
+ }
+ }
+
+ /**
+ * Returns the baseline.
+ *
+ * @throws NullPointerException {@inheritDoc}
+ * @throws IllegalArgumentException {@inheritDoc}
+ * @see javax.swing.JComponent#getBaseline(int, int)
+ * @since 1.6
+ */
+ public int getBaseline(JComponent c, int width, int height) {
+ int baseline = super.getBaseline(c, width, height);
+ if (XPStyle.getXP() != null && progressBar.isStringPainted() &&
+ progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
+ FontMetrics metrics = progressBar.
+ getFontMetrics(progressBar.getFont());
+ int y = progressBar.getInsets().top;
+ if (progressBar.isIndeterminate()) {
+ y = -1;
+ height--;
+ }
+ else {
+ y = 0;
+ height -= 3;
+ }
+ baseline = y + (height + metrics.getAscent() -
+ metrics.getLeading() -
+ metrics.getDescent()) / 2;
+ }
+ return baseline;
+ }
+
+ protected Dimension getPreferredInnerHorizontal() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(progressBar, Part.PP_BAR);
+ return new Dimension(
+ (int)super.getPreferredInnerHorizontal().getWidth(),
+ skin.getHeight());
+ }
+ return super.getPreferredInnerHorizontal();
+ }
+
+ protected Dimension getPreferredInnerVertical() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(progressBar, Part.PP_BARVERT);
+ return new Dimension(
+ skin.getWidth(),
+ (int)super.getPreferredInnerVertical().getHeight());
+ }
+ return super.getPreferredInnerVertical();
+ }
+
+ protected void paintDeterminate(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
+ boolean isLeftToRight = WindowsGraphicsUtils.isLeftToRight(c);
+ int barRectWidth = progressBar.getWidth();
+ int barRectHeight = progressBar.getHeight()-1;
+ // amount of progress to draw
+ int amountFull = getAmountFull(null, barRectWidth, barRectHeight);
+
+ paintXPBackground(g, vertical, barRectWidth, barRectHeight);
+ // Paint progress
+ if (progressBar.isStringPainted()) {
+ // Do not paint the standard stripes from the skin, because they obscure
+ // the text
+ g.setColor(progressBar.getForeground());
+ barRectHeight -= 2;
+ barRectWidth -= 2;
+
+ if (barRectWidth <= 0 || barRectHeight <= 0) {
+ return;
+ }
+
+ Graphics2D g2 = (Graphics2D)g;
+ g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
+ BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+ if (!vertical) {
+ if (isLeftToRight) {
+ g2.drawLine(2, barRectHeight / 2 + 1,
+ amountFull - 2, barRectHeight / 2 + 1);
+ } else {
+ g2.drawLine(2 + barRectWidth,
+ barRectHeight / 2 + 1,
+ 2 + barRectWidth - (amountFull - 2),
+ barRectHeight / 2 + 1);
+ }
+ paintString(g, 0, 0, barRectWidth, barRectHeight, amountFull, null);
+ } else {
+ g2.drawLine(barRectWidth/2 + 1, barRectHeight + 1,
+ barRectWidth/2 + 1, barRectHeight + 1 - amountFull + 2);
+ paintString(g, 2, 2, barRectWidth, barRectHeight, amountFull, null);
+ }
+
+ } else {
+ Skin skin = xp.getSkin(progressBar, vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK);
+ int thickness;
+ if (vertical) {
+ thickness = barRectWidth - 5;
+ } else {
+ thickness = barRectHeight - 5;
+ }
+
+ int chunkSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSCHUNKSIZE, 2);
+ int spaceSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSSPACESIZE, 0);
+ int nChunks = (amountFull-4) / (chunkSize + spaceSize);
+
+ // See if we can squeeze in an extra chunk without spacing after
+ if (spaceSize > 0 && (nChunks * (chunkSize + spaceSize) + chunkSize) < (amountFull-4)) {
+ nChunks++;
+ }
+
+ for (int i = 0; i < nChunks; i++) {
+ if (vertical) {
+ skin.paintSkin(g,
+ 3, barRectHeight - i * (chunkSize + spaceSize) - chunkSize - 2,
+ thickness, chunkSize, null);
+ } else {
+ if (isLeftToRight) {
+ skin.paintSkin(g,
+ 4 + i * (chunkSize + spaceSize), 2,
+ chunkSize, thickness, null);
+ } else {
+ skin.paintSkin(g,
+ barRectWidth - (2 + (i+1) * (chunkSize + spaceSize)), 2,
+ chunkSize, thickness, null);
+ }
+ }
+ }
+ }
+ } else {
+ super.paintDeterminate(g, c);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected void setAnimationIndex(int newValue) {
+ super.setAnimationIndex(newValue);
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ if (boxRect != null) {
+ // get the full repaint area and add it the
+ // previous one so we can erase it
+ Rectangle chunk = getFullChunkBounds(boxRect);
+ if (previousFullBox != null) {
+ chunk.add(previousFullBox);
+ }
+ progressBar.repaint(chunk);
+ } else {
+ progressBar.repaint();
+ }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected int getBoxLength(int availableLength, int otherDimension) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return 6; // an apparently hard coded value in Windows
+ }
+ return super.getBoxLength(availableLength, otherDimension);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected Rectangle getBox(Rectangle r) {
+ Rectangle rect = super.getBox(r);
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ boolean vertical = (progressBar.getOrientation()
+ == JProgressBar.VERTICAL);
+ Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
+ Insets ins = indeterminateInsets;
+
+ int currentFrame = getAnimationIndex();
+ int framecount = getFrameCount()/2;
+
+ int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
+ Prop.PROGRESSSPACESIZE, 0);
+ currentFrame = currentFrame % framecount;
+
+ // this code adjusts the chunk size to properly account for the
+ // size and gap specified in the XP style. It also does it's own
+ // box placement for the chunk animation. This is required because
+ // the inherited algorithm from BasicProgressBarUI goes back and
+ // forth whereas XP only goes in one direction. XP also has ghosted
+ // trailing chunks to create the illusion of speed. This code
+ // adjusts the pixel length of the animation to account for the
+ // trails.
+ if (!vertical) {
+ rect.y = rect.y + ins.top;
+ rect.height = progressBar.getHeight() - ins.top - ins.bottom;
+ int len = progressBar.getWidth() - ins.left - ins.right;
+ len += (rect.width+gap)*2; // add 2x for the trails
+ double delta = (double)(len) / (double)framecount;
+ rect.x = (int)(delta * currentFrame) + ins.left;
+ } else {
+ rect.x = rect.x + ins.left;
+ rect.width = progressBar.getWidth() - ins.left - ins.right;
+ int len = progressBar.getHeight() - ins.top - ins.bottom;
+ len += (rect.height+gap)*2; // add 2x for the trails
+ double delta = (double)(len) / (double)framecount;
+ rect.y = (int)(delta * currentFrame) + ins.top;
+ }
+ }
+ return rect;
+ }
+
+
+ protected void paintIndeterminate(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ boolean vertical = (progressBar.getOrientation()
+ == JProgressBar.VERTICAL);
+ int barRectWidth = progressBar.getWidth();
+ int barRectHeight = progressBar.getHeight();
+ paintXPBackground(g, vertical, barRectWidth, barRectHeight);
+
+ // Paint the bouncing box.
+ boxRect = getBox(boxRect);
+ if (boxRect != null) {
+ g.setColor(progressBar.getForeground());
+ if (!(g instanceof Graphics2D)) {
+ return;
+ }
+ paintIndeterminateFrame(boxRect, (Graphics2D)g, vertical,
+ barRectWidth, barRectHeight);
+ if (progressBar.isStringPainted()) {
+ if (!vertical) {
+ paintString(g, -1, -1, barRectWidth, barRectHeight, 0, null);
+ } else {
+ paintString(g, 1, 1, barRectWidth, barRectHeight, 0, null);
+ }
+ }
+ }
+ } else {
+ super.paintIndeterminate(g, c);
+ }
+ }
+
+ private Rectangle getFullChunkBounds(Rectangle box) {
+ boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
+ XPStyle xp = XPStyle.getXP();
+ int gap = (xp != null) ? xp.getInt(progressBar, Part.PP_PROGRESS,
+ null, Prop.PROGRESSSPACESIZE, 0)
+ : 0;
+
+ if (!vertical) {
+ int chunksize = box.width+gap;
+ return new Rectangle(box.x-chunksize*2, box.y, chunksize*3, box.height);
+ } else {
+ int chunksize = box.height+gap;
+ return new Rectangle(box.x, box.y-chunksize*2, box.width, chunksize*3);
+ }
+ }
+
+ private void paintIndeterminateFrame(Rectangle box, Graphics2D g,
+ boolean vertical,
+ int bgwidth, int bgheight) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
+
+ // create a new graphics to keep drawing surface state
+ Graphics2D gfx = (Graphics2D)g.create();
+
+ Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
+ Part chunk = vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK;
+
+ // calculate the chunk offsets
+ int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
+ Prop.PROGRESSSPACESIZE, 0);
+ int deltax = 0;
+ int deltay = 0;
+ if (!vertical) {
+ deltax = -box.width - gap;
+ deltay = 0;
+ } else {
+ deltax = 0;
+ deltay = -box.height - gap;
+ }
+
+ // Calculate the area of the chunks combined
+ Rectangle fullBox = getFullChunkBounds(box);
+
+ // save this box for the next time
+ previousFullBox = fullBox;
+
+ // this is the entire progress bar minus the track and borders
+ Insets ins = indeterminateInsets;
+ Rectangle progbarExtents = new Rectangle(ins.left, ins.top,
+ bgwidth - ins.left - ins.right,
+ bgheight - ins.top - ins.bottom);
+
+ // only paint where the chunks overlap with the progress bar drawing area
+ Rectangle repaintArea = progbarExtents.intersection(fullBox);
+
+ // adjust the cliprect to chop the chunks when they go off the end
+ gfx.clip(repaintArea);
+
+ // get the skin
+ XPStyle.Skin skin = xp.getSkin(progressBar, chunk);
+
+ // do the drawing
+ gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
+ skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
+ box.translate(deltax, deltay);
+ gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
+ skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
+ box.translate(deltax, deltay);
+ gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
+ skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
+
+ // get rid of our clip and composite changes
+ gfx.dispose();
+ }
+
+ private void paintXPBackground(Graphics g, boolean vertical,
+ int barRectWidth, int barRectHeight) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
+ Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
+ Skin skin = xp.getSkin(progressBar, part);
+
+ // Paint background
+ skin.paintSkin(g, 0, 0, barRectWidth, barRectHeight, null);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+import com.sun.java.swing.plaf.windows.TMSchema.Part;
+import com.sun.java.swing.plaf.windows.TMSchema.State;
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI {
+
+ final WindowsMenuItemUIAccessor accessor =
+ new WindowsMenuItemUIAccessor() {
+
+ public JMenuItem getMenuItem() {
+ return menuItem;
+ }
+
+ public State getState(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getState(this, menuItem);
+ }
+
+ public Part getPart(JMenuItem menuItem) {
+ return WindowsMenuItemUI.getPart(this, menuItem);
+ }
+ };
+ public static ComponentUI createUI(JComponent b) {
+ return new WindowsRadioButtonMenuItemUI();
+ }
+
+ @Override
+ protected void paintBackground(Graphics g, JMenuItem menuItem,
+ Color bgColor) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
+ return;
+ }
+ super.paintBackground(g, menuItem, bgColor);
+ }
+
+ /**
+ * Method which renders the text of the current menu item.
+ *
+ * @param g Graphics context
+ * @param menuItem Current menu item to render
+ * @param textRect Bounding rectangle to render the text.
+ * @param text String to render
+ * @since 1.4
+ */
+ protected void paintText(Graphics g, JMenuItem menuItem,
+ Rectangle textRect, String text) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
+ return;
+ }
+ ButtonModel model = menuItem.getModel();
+ Color oldColor = g.getColor();
+
+ if(model.isEnabled() && model.isArmed()) {
+ g.setColor(selectionForeground); // Uses protected field.
+ }
+
+ WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
+
+ g.setColor(oldColor);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.awt.AppContext;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+import java.awt.*;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsRadioButtonUI extends BasicRadioButtonUI
+{
+ private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object();
+
+ protected int dashedRectGapX;
+ protected int dashedRectGapY;
+ protected int dashedRectGapWidth;
+ protected int dashedRectGapHeight;
+
+ protected Color focusColor;
+
+ private boolean initialized = false;
+
+ // ********************************
+ // Create PLAF
+ // ********************************
+ public static ComponentUI createUI(JComponent c) {
+ AppContext appContext = AppContext.getAppContext();
+ WindowsRadioButtonUI windowsRadioButtonUI =
+ (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
+ if (windowsRadioButtonUI == null) {
+ windowsRadioButtonUI = new WindowsRadioButtonUI();
+ appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
+ }
+ return windowsRadioButtonUI;
+ }
+
+ // ********************************
+ // Defaults
+ // ********************************
+ public void installDefaults(AbstractButton b) {
+ super.installDefaults(b);
+ if(!initialized) {
+ dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
+ dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
+ dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
+ dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ initialized = true;
+ }
+ if (XPStyle.getXP() != null) {
+ LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
+ }
+ }
+
+ protected void uninstallDefaults(AbstractButton b) {
+ super.uninstallDefaults(b);
+ initialized = false;
+ }
+
+ protected Color getFocusColor() {
+ return focusColor;
+ }
+
+ // ********************************
+ // Paint Methods
+ // ********************************
+
+ /**
+ * Overridden method to render the text without the mnemonic
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
+ WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
+ }
+
+
+ protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
+ g.setColor(getFocusColor());
+ BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
+ }
+
+ // ********************************
+ // Layout Methods
+ // ********************************
+ public Dimension getPreferredSize(JComponent c) {
+ Dimension d = super.getPreferredSize(c);
+
+ /* Ensure that the width and height of the button is odd,
+ * to allow for the focus line if focus is painted
+ */
+ AbstractButton b = (AbstractButton)c;
+ if (d != null && b.isFocusPainted()) {
+ if(d.width % 2 == 0) { d.width += 1; }
+ if(d.height % 2 == 0) { d.height += 1; }
+ }
+ return d;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Event;
+import java.awt.KeyEventPostProcessor;
+import java.awt.Window;
+import java.awt.Toolkit;
+
+import sun.awt.AWTAccessor;
+import sun.awt.SunToolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JRootPane;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.AbstractButton;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+
+import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InputMapUIResource;
+
+import javax.swing.plaf.basic.BasicRootPaneUI;
+import javax.swing.plaf.basic.ComboPopup;
+
+/**
+ * Windows implementation of RootPaneUI, there is one shared between all
+ * JRootPane instances.
+ *
+ * @author Mark Davidson
+ * @since 1.4
+ */
+public class WindowsRootPaneUI extends BasicRootPaneUI {
+
+ private static final WindowsRootPaneUI windowsRootPaneUI = new WindowsRootPaneUI();
+ static final AltProcessor altProcessor = new AltProcessor();
+
+ public static ComponentUI createUI(JComponent c) {
+ return windowsRootPaneUI;
+ }
+
+ static class AltProcessor implements KeyEventPostProcessor {
+ static boolean altKeyPressed = false;
+ static boolean menuCanceledOnPress = false;
+ static JRootPane root = null;
+ static Window winAncestor = null;
+
+ void altPressed(KeyEvent ev) {
+ MenuSelectionManager msm =
+ MenuSelectionManager.defaultManager();
+ MenuElement[] path = msm.getSelectedPath();
+ if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
+ msm.clearSelectedPath();
+ menuCanceledOnPress = true;
+ ev.consume();
+ } else if(path.length > 0) { // We are in ComboBox
+ menuCanceledOnPress = false;
+ WindowsLookAndFeel.setMnemonicHidden(false);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ ev.consume();
+ } else {
+ menuCanceledOnPress = false;
+ WindowsLookAndFeel.setMnemonicHidden(false);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ JMenuBar mbar = root != null ? root.getJMenuBar() : null;
+ if(mbar == null && winAncestor instanceof JFrame) {
+ mbar = ((JFrame)winAncestor).getJMenuBar();
+ }
+ JMenu menu = mbar != null ? mbar.getMenu(0) : null;
+ if(menu != null) {
+ ev.consume();
+ }
+ }
+ }
+
+ void altReleased(KeyEvent ev) {
+ if (menuCanceledOnPress) {
+ WindowsLookAndFeel.setMnemonicHidden(true);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ return;
+ }
+
+ MenuSelectionManager msm =
+ MenuSelectionManager.defaultManager();
+ if (msm.getSelectedPath().length == 0) {
+ // if no menu is active, we try activating the menubar
+
+ JMenuBar mbar = root != null ? root.getJMenuBar() : null;
+ if(mbar == null && winAncestor instanceof JFrame) {
+ mbar = ((JFrame)winAncestor).getJMenuBar();
+ }
+ JMenu menu = mbar != null ? mbar.getMenu(0) : null;
+
+ // It might happen that the altRelease event is processed
+ // with a reasonable delay since it has been generated.
+ // Here we check the last deactivation time of the containing
+ // window. If this time appears to be greater than the altRelease
+ // event time the event is skipped to avoid unexpected menu
+ // activation. See 7121442.
+ // Also we must ensure that original source of key event belongs
+ // to the same window object as winAncestor. See 8001633.
+ boolean skip = false;
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ if (tk instanceof SunToolkit) {
+ Component originalSource = AWTAccessor.getKeyEventAccessor()
+ .getOriginalSource(ev);
+ skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
+ ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
+ }
+
+ if (menu != null && !skip) {
+ MenuElement[] path = new MenuElement[2];
+ path[0] = mbar;
+ path[1] = menu;
+ msm.setSelectedPath(path);
+ } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
+ WindowsLookAndFeel.setMnemonicHidden(true);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ }
+ } else {
+ if((msm.getSelectedPath())[0] instanceof ComboPopup) {
+ WindowsLookAndFeel.setMnemonicHidden(true);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ }
+ }
+
+ }
+
+ public boolean postProcessKeyEvent(KeyEvent ev) {
+ if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
+ // mnemonic combination, it's consumed, but we need
+ // set altKeyPressed to false, otherwise after selection
+ // component by mnemonic combination a menu will be open
+ altKeyPressed = false;
+ return false;
+ }
+ if (ev.getKeyCode() == KeyEvent.VK_ALT) {
+ root = SwingUtilities.getRootPane(ev.getComponent());
+ winAncestor = (root == null ? null :
+ SwingUtilities.getWindowAncestor(root));
+
+ if (ev.getID() == KeyEvent.KEY_PRESSED) {
+ if (!altKeyPressed) {
+ altPressed(ev);
+ }
+ altKeyPressed = true;
+ return true;
+ } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
+ if (altKeyPressed) {
+ altReleased(ev);
+ } else {
+ MenuSelectionManager msm =
+ MenuSelectionManager.defaultManager();
+ MenuElement[] path = msm.getSelectedPath();
+ if (path.length <= 0) {
+ WindowsLookAndFeel.setMnemonicHidden(true);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ }
+ }
+ altKeyPressed = false;
+ }
+ root = null;
+ winAncestor = null;
+ } else {
+ if (WindowsLookAndFeel.isMnemonicHidden() && ev.isAltDown()) {
+ WindowsLookAndFeel.setMnemonicHidden(false);
+ WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
+ }
+ altKeyPressed = false;
+ }
+ return false;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,503 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import java.lang.ref.*;
+import java.util.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.ComponentUI;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsScrollBarUI extends BasicScrollBarUI {
+ private Grid thumbGrid;
+ private Grid highlightGrid;
+ private Dimension horizontalThumbSize;
+ private Dimension verticalThumbSize;
+
+ /**
+ * Creates a UI for a JScrollBar.
+ *
+ * @param c the text field
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsScrollBarUI();
+ }
+
+ protected void installDefaults() {
+ super.installDefaults();
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ scrollbar.setBorder(null);
+ horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
+ verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
+ } else {
+ horizontalThumbSize = null;
+ verticalThumbSize = null;
+ }
+ }
+
+ private static Dimension getSize(Component component, XPStyle xp, Part part) {
+ Skin skin = xp.getSkin(component, part);
+ return new Dimension(skin.getWidth(), skin.getHeight());
+ }
+
+ @Override
+ protected Dimension getMinimumThumbSize() {
+ if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
+ return super.getMinimumThumbSize();
+ }
+ return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
+ ? horizontalThumbSize
+ : verticalThumbSize;
+ }
+
+ public void uninstallUI(JComponent c) {
+ super.uninstallUI(c);
+ thumbGrid = highlightGrid = null;
+ }
+
+ protected void configureScrollBarColors() {
+ super.configureScrollBarColors();
+ Color color = UIManager.getColor("ScrollBar.trackForeground");
+ if (color != null && trackColor != null) {
+ thumbGrid = Grid.getGrid(color, trackColor);
+ }
+
+ color = UIManager.getColor("ScrollBar.trackHighlightForeground");
+ if (color != null && trackHighlightColor != null) {
+ highlightGrid = Grid.getGrid(color, trackHighlightColor);
+ }
+ }
+
+ protected JButton createDecreaseButton(int orientation) {
+ return new WindowsArrowButton(orientation,
+ UIManager.getColor("ScrollBar.thumb"),
+ UIManager.getColor("ScrollBar.thumbShadow"),
+ UIManager.getColor("ScrollBar.thumbDarkShadow"),
+ UIManager.getColor("ScrollBar.thumbHighlight"));
+ }
+
+ protected JButton createIncreaseButton(int orientation) {
+ return new WindowsArrowButton(orientation,
+ UIManager.getColor("ScrollBar.thumb"),
+ UIManager.getColor("ScrollBar.thumbShadow"),
+ UIManager.getColor("ScrollBar.thumbDarkShadow"),
+ UIManager.getColor("ScrollBar.thumbHighlight"));
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ @Override
+ protected ArrowButtonListener createArrowButtonListener(){
+ // we need to repaint the entire scrollbar because state change for each
+ // button causes a state change for the thumb and other button on Vista
+ if(XPStyle.isVista()) {
+ return new ArrowButtonListener() {
+ public void mouseEntered(MouseEvent evt) {
+ repaint();
+ super.mouseEntered(evt);
+ }
+ public void mouseExited(MouseEvent evt) {
+ repaint();
+ super.mouseExited(evt);
+ }
+ private void repaint() {
+ scrollbar.repaint();
+ }
+ };
+ } else {
+ return super.createArrowButtonListener();
+ }
+ }
+
+ protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds){
+ boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ JScrollBar sb = (JScrollBar)c;
+ State state = State.NORMAL;
+ // Pending: Implement rollover (hot) and pressed
+ if (!sb.isEnabled()) {
+ state = State.DISABLED;
+ }
+ Part part = v ? Part.SBP_LOWERTRACKVERT : Part.SBP_LOWERTRACKHORZ;
+ xp.getSkin(sb, part).paintSkin(g, trackBounds, state);
+ } else if (thumbGrid == null) {
+ super.paintTrack(g, c, trackBounds);
+ }
+ else {
+ thumbGrid.paint(g, trackBounds.x, trackBounds.y, trackBounds.width,
+ trackBounds.height);
+ if (trackHighlight == DECREASE_HIGHLIGHT) {
+ paintDecreaseHighlight(g);
+ }
+ else if (trackHighlight == INCREASE_HIGHLIGHT) {
+ paintIncreaseHighlight(g);
+ }
+ }
+ }
+
+ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
+ boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ JScrollBar sb = (JScrollBar)c;
+ State state = State.NORMAL;
+ if (!sb.isEnabled()) {
+ state = State.DISABLED;
+ } else if (isDragging) {
+ state = State.PRESSED;
+ } else if (isThumbRollover()) {
+ state = State.HOT;
+ } else if (XPStyle.isVista()) {
+ if ((incrButton != null && incrButton.getModel().isRollover()) ||
+ (decrButton != null && decrButton.getModel().isRollover())) {
+ state = State.HOVER;
+ }
+ }
+ // Paint thumb
+ Part thumbPart = v ? Part.SBP_THUMBBTNVERT : Part.SBP_THUMBBTNHORZ;
+ xp.getSkin(sb, thumbPart).paintSkin(g, thumbBounds, state);
+ // Paint gripper
+ Part gripperPart = v ? Part.SBP_GRIPPERVERT : Part.SBP_GRIPPERHORZ;
+ Skin skin = xp.getSkin(sb, gripperPart);
+ Insets gripperInsets = xp.getMargin(c, thumbPart, null, Prop.CONTENTMARGINS);
+ if (gripperInsets == null ||
+ (v && (thumbBounds.height - gripperInsets.top -
+ gripperInsets.bottom >= skin.getHeight())) ||
+ (!v && (thumbBounds.width - gripperInsets.left -
+ gripperInsets.right >= skin.getWidth()))) {
+ skin.paintSkin(g,
+ thumbBounds.x + (thumbBounds.width - skin.getWidth()) / 2,
+ thumbBounds.y + (thumbBounds.height - skin.getHeight()) / 2,
+ skin.getWidth(), skin.getHeight(), state);
+ }
+ } else {
+ super.paintThumb(g, c, thumbBounds);
+ }
+ }
+
+
+ protected void paintDecreaseHighlight(Graphics g) {
+ if (highlightGrid == null) {
+ super.paintDecreaseHighlight(g);
+ }
+ else {
+ Insets insets = scrollbar.getInsets();
+ Rectangle thumbR = getThumbBounds();
+ int x, y, w, h;
+
+ if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
+ x = insets.left;
+ y = decrButton.getY() + decrButton.getHeight();
+ w = scrollbar.getWidth() - (insets.left + insets.right);
+ h = thumbR.y - y;
+ }
+ else {
+ x = decrButton.getX() + decrButton.getHeight();
+ y = insets.top;
+ w = thumbR.x - x;
+ h = scrollbar.getHeight() - (insets.top + insets.bottom);
+ }
+ highlightGrid.paint(g, x, y, w, h);
+ }
+ }
+
+
+ protected void paintIncreaseHighlight(Graphics g) {
+ if (highlightGrid == null) {
+ super.paintDecreaseHighlight(g);
+ }
+ else {
+ Insets insets = scrollbar.getInsets();
+ Rectangle thumbR = getThumbBounds();
+ int x, y, w, h;
+
+ if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
+ x = insets.left;
+ y = thumbR.y + thumbR.height;
+ w = scrollbar.getWidth() - (insets.left + insets.right);
+ h = incrButton.getY() - y;
+ }
+ else {
+ x = thumbR.x + thumbR.width;
+ y = insets.top;
+ w = incrButton.getX() - x;
+ h = scrollbar.getHeight() - (insets.top + insets.bottom);
+ }
+ highlightGrid.paint(g, x, y, w, h);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ @Override
+ protected void setThumbRollover(boolean active) {
+ boolean old = isThumbRollover();
+ super.setThumbRollover(active);
+ // we need to repaint the entire scrollbar because state change for thumb
+ // causes state change for incr and decr buttons on Vista
+ if(XPStyle.isVista() && active != old) {
+ scrollbar.repaint();
+ }
+ }
+
+ /**
+ * WindowsArrowButton is used for the buttons to position the
+ * document up/down. It differs from BasicArrowButton in that the
+ * preferred size is always a square.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class WindowsArrowButton extends BasicArrowButton {
+
+ public WindowsArrowButton(int direction, Color background, Color shadow,
+ Color darkShadow, Color highlight) {
+ super(direction, background, shadow, darkShadow, highlight);
+ }
+
+ public WindowsArrowButton(int direction) {
+ super(direction);
+ }
+
+ public void paint(Graphics g) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ ButtonModel model = getModel();
+ Skin skin = xp.getSkin(this, Part.SBP_ARROWBTN);
+ State state = null;
+
+ boolean jointRollover = XPStyle.isVista() && (isThumbRollover() ||
+ (this == incrButton && decrButton.getModel().isRollover()) ||
+ (this == decrButton && incrButton.getModel().isRollover()));
+
+ // normal, rollover, pressed, disabled
+ if (model.isArmed() && model.isPressed()) {
+ switch (direction) {
+ case NORTH: state = State.UPPRESSED; break;
+ case SOUTH: state = State.DOWNPRESSED; break;
+ case WEST: state = State.LEFTPRESSED; break;
+ case EAST: state = State.RIGHTPRESSED; break;
+ }
+ } else if (!model.isEnabled()) {
+ switch (direction) {
+ case NORTH: state = State.UPDISABLED; break;
+ case SOUTH: state = State.DOWNDISABLED; break;
+ case WEST: state = State.LEFTDISABLED; break;
+ case EAST: state = State.RIGHTDISABLED; break;
+ }
+ } else if (model.isRollover() || model.isPressed()) {
+ switch (direction) {
+ case NORTH: state = State.UPHOT; break;
+ case SOUTH: state = State.DOWNHOT; break;
+ case WEST: state = State.LEFTHOT; break;
+ case EAST: state = State.RIGHTHOT; break;
+ }
+ } else if (jointRollover) {
+ switch (direction) {
+ case NORTH: state = State.UPHOVER; break;
+ case SOUTH: state = State.DOWNHOVER; break;
+ case WEST: state = State.LEFTHOVER; break;
+ case EAST: state = State.RIGHTHOVER; break;
+ }
+ } else {
+ switch (direction) {
+ case NORTH: state = State.UPNORMAL; break;
+ case SOUTH: state = State.DOWNNORMAL; break;
+ case WEST: state = State.LEFTNORMAL; break;
+ case EAST: state = State.RIGHTNORMAL; break;
+ }
+ }
+
+ skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
+ } else {
+ super.paint(g);
+ }
+ }
+
+ public Dimension getPreferredSize() {
+ int size = 16;
+ if (scrollbar != null) {
+ switch (scrollbar.getOrientation()) {
+ case JScrollBar.VERTICAL:
+ size = scrollbar.getWidth();
+ break;
+ case JScrollBar.HORIZONTAL:
+ size = scrollbar.getHeight();
+ break;
+ }
+ size = Math.max(size, 5);
+ }
+ return new Dimension(size, size);
+ }
+ }
+
+
+ /**
+ * This should be pulled out into its own class if more classes need to
+ * use it.
+ * <p>
+ * Grid is used to draw the track for windows scrollbars. Grids
+ * are cached in a HashMap, with the key being the rgb components
+ * of the foreground/background colors. Further the Grid is held through
+ * a WeakRef so that it can be freed when no longer needed. As the
+ * Grid is rather expensive to draw, it is drawn in a BufferedImage.
+ */
+ private static class Grid {
+ private static final int BUFFER_SIZE = 64;
+ private static HashMap<String, WeakReference<Grid>> map;
+
+ private BufferedImage image;
+
+ static {
+ map = new HashMap<String, WeakReference<Grid>>();
+ }
+
+ public static Grid getGrid(Color fg, Color bg) {
+ String key = fg.getRGB() + " " + bg.getRGB();
+ WeakReference<Grid> ref = map.get(key);
+ Grid grid = (ref == null) ? null : ref.get();
+ if (grid == null) {
+ grid = new Grid(fg, bg);
+ map.put(key, new WeakReference<Grid>(grid));
+ }
+ return grid;
+ }
+
+ public Grid(Color fg, Color bg) {
+ int cmap[] = { fg.getRGB(), bg.getRGB() };
+ IndexColorModel icm = new IndexColorModel(8, 2, cmap, 0, false, -1,
+ DataBuffer.TYPE_BYTE);
+ image = new BufferedImage(BUFFER_SIZE, BUFFER_SIZE,
+ BufferedImage.TYPE_BYTE_INDEXED, icm);
+ Graphics g = image.getGraphics();
+ try {
+ g.setClip(0, 0, BUFFER_SIZE, BUFFER_SIZE);
+ paintGrid(g, fg, bg);
+ }
+ finally {
+ g.dispose();
+ }
+ }
+
+ /**
+ * Paints the grid into the specified Graphics at the specified
+ * location.
+ */
+ public void paint(Graphics g, int x, int y, int w, int h) {
+ Rectangle clipRect = g.getClipBounds();
+ int minX = Math.max(x, clipRect.x);
+ int minY = Math.max(y, clipRect.y);
+ int maxX = Math.min(clipRect.x + clipRect.width, x + w);
+ int maxY = Math.min(clipRect.y + clipRect.height, y + h);
+
+ if (maxX <= minX || maxY <= minY) {
+ return;
+ }
+ int xOffset = (minX - x) % 2;
+ for (int xCounter = minX; xCounter < maxX;
+ xCounter += BUFFER_SIZE) {
+ int yOffset = (minY - y) % 2;
+ int width = Math.min(BUFFER_SIZE - xOffset,
+ maxX - xCounter);
+
+ for (int yCounter = minY; yCounter < maxY;
+ yCounter += BUFFER_SIZE) {
+ int height = Math.min(BUFFER_SIZE - yOffset,
+ maxY - yCounter);
+
+ g.drawImage(image, xCounter, yCounter,
+ xCounter + width, yCounter + height,
+ xOffset, yOffset,
+ xOffset + width, yOffset + height, null);
+ if (yOffset != 0) {
+ yCounter -= yOffset;
+ yOffset = 0;
+ }
+ }
+ if (xOffset != 0) {
+ xCounter -= xOffset;
+ xOffset = 0;
+ }
+ }
+ }
+
+ /**
+ * Actually renders the grid into the Graphics <code>g</code>.
+ */
+ private void paintGrid(Graphics g, Color fg, Color bg) {
+ Rectangle clipRect = g.getClipBounds();
+ g.setColor(bg);
+ g.fillRect(clipRect.x, clipRect.y, clipRect.width,
+ clipRect.height);
+ g.setColor(fg);
+ g.translate(clipRect.x, clipRect.y);
+ int width = clipRect.width;
+ int height = clipRect.height;
+ int xCounter = clipRect.x % 2;
+ for (int end = width - height; xCounter < end; xCounter += 2) {
+ g.drawLine(xCounter, 0, xCounter + height, height);
+ }
+ for (int end = width; xCounter < end; xCounter += 2) {
+ g.drawLine(xCounter, 0, width, width - xCounter);
+ }
+
+ int yCounter = ((clipRect.x % 2) == 0) ? 2 : 1;
+ for (int end = height - width; yCounter < end; yCounter += 2) {
+ g.drawLine(0, yCounter, width, yCounter + width);
+ }
+ for (int end = height; yCounter < end; yCounter += 2) {
+ g.drawLine(0, yCounter, height - yCounter, height);
+ }
+ g.translate(-clipRect.x, -clipRect.y);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsScrollPaneUI extends BasicScrollPaneUI
+{}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+
+/**
+ * Windows Separator.
+ */
+public class WindowsSeparatorUI extends BasicSeparatorUI { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsSliderUI extends BasicSliderUI
+{
+ private boolean rollover = false;
+ private boolean pressed = false;
+
+ public WindowsSliderUI(JSlider b){
+ super(b);
+ }
+
+ public static ComponentUI createUI(JComponent b) {
+ return new WindowsSliderUI((JSlider)b);
+ }
+
+
+ /**
+ * Overrides to return a private track listener subclass which handles
+ * the HOT, PRESSED, and FOCUSED states.
+ * @since 1.6
+ */
+ protected TrackListener createTrackListener(JSlider slider) {
+ return new WindowsTrackListener();
+ }
+
+ private class WindowsTrackListener extends TrackListener {
+
+ public void mouseMoved(MouseEvent e) {
+ updateRollover(thumbRect.contains(e.getX(), e.getY()));
+ super.mouseMoved(e);
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ updateRollover(thumbRect.contains(e.getX(), e.getY()));
+ super.mouseEntered(e);
+ }
+
+ public void mouseExited(MouseEvent e) {
+ updateRollover(false);
+ super.mouseExited(e);
+ }
+
+ public void mousePressed(MouseEvent e) {
+ updatePressed(thumbRect.contains(e.getX(), e.getY()));
+ super.mousePressed(e);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ updatePressed(false);
+ super.mouseReleased(e);
+ }
+
+ public void updatePressed(boolean newPressed) {
+ // You can't press a disabled slider
+ if (!slider.isEnabled()) {
+ return;
+ }
+ if (pressed != newPressed) {
+ pressed = newPressed;
+ slider.repaint(thumbRect);
+ }
+ }
+
+ public void updateRollover(boolean newRollover) {
+ // You can't have a rollover on a disabled slider
+ if (!slider.isEnabled()) {
+ return;
+ }
+ if (rollover != newRollover) {
+ rollover = newRollover;
+ slider.repaint(thumbRect);
+ }
+ }
+
+ }
+
+
+ public void paintTrack(Graphics g) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
+ Part part = vertical ? Part.TKP_TRACKVERT : Part.TKP_TRACK;
+ Skin skin = xp.getSkin(slider, part);
+
+ if (vertical) {
+ int x = (trackRect.width - skin.getWidth()) / 2;
+ skin.paintSkin(g, trackRect.x + x, trackRect.y,
+ skin.getWidth(), trackRect.height, null);
+ } else {
+ int y = (trackRect.height - skin.getHeight()) / 2;
+ skin.paintSkin(g, trackRect.x, trackRect.y + y,
+ trackRect.width, skin.getHeight(), null);
+ }
+ } else {
+ super.paintTrack(g);
+ }
+ }
+
+
+ protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
+ }
+ super.paintMinorTickForHorizSlider(g, tickBounds, x);
+ }
+
+ protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
+ }
+ super.paintMajorTickForHorizSlider(g, tickBounds, x);
+ }
+
+ protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
+ }
+ super.paintMinorTickForVertSlider(g, tickBounds, y);
+ }
+
+ protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
+ }
+ super.paintMajorTickForVertSlider(g, tickBounds, y);
+ }
+
+
+ public void paintThumb(Graphics g) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Part part = getXPThumbPart();
+ State state = State.NORMAL;
+
+ if (slider.hasFocus()) {
+ state = State.FOCUSED;
+ }
+ if (rollover) {
+ state = State.HOT;
+ }
+ if (pressed) {
+ state = State.PRESSED;
+ }
+ if(!slider.isEnabled()) {
+ state = State.DISABLED;
+ }
+
+ xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
+ } else {
+ super.paintThumb(g);
+ }
+ }
+
+ protected Dimension getThumbSize() {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Dimension size = new Dimension();
+ Skin s = xp.getSkin(slider, getXPThumbPart());
+ size.width = s.getWidth();
+ size.height = s.getHeight();
+ return size;
+ } else {
+ return super.getThumbSize();
+ }
+ }
+
+ private Part getXPThumbPart() {
+ Part part;
+ boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
+ boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
+ Boolean paintThumbArrowShape =
+ (Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
+ if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
+ paintThumbArrowShape == Boolean.FALSE) {
+ part = vertical ? Part.TKP_THUMBVERT
+ : Part.TKP_THUMB;
+ } else {
+ part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
+ : Part.TKP_THUMBBOTTOM;
+ }
+ return part;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.*;
+import javax.swing.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.Part;
+import static com.sun.java.swing.plaf.windows.TMSchema.State;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+public class WindowsSpinnerUI extends BasicSpinnerUI {
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsSpinnerUI();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ public void paint(Graphics g, JComponent c) {
+ if (XPStyle.getXP() != null) {
+ paintXPBackground(g, c);
+ }
+ super.paint(g,c);
+ }
+
+ private State getXPState(JComponent c) {
+ State state = State.NORMAL;
+ if (!c.isEnabled()) {
+ state = State.DISABLED;
+ }
+ return state;
+ }
+
+ private void paintXPBackground(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
+ Skin skin = xp.getSkin(c, Part.EP_EDIT);
+ State state = getXPState(c);
+ skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
+ }
+
+ protected Component createPreviousButton() {
+ if (XPStyle.getXP() != null) {
+ JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_DOWN);
+ Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
+ xpButton.setPreferredSize(size);
+ xpButton.setRequestFocusEnabled(false);
+ installPreviousButtonListeners(xpButton);
+ return xpButton;
+ }
+ return super.createPreviousButton();
+ }
+
+ protected Component createNextButton() {
+ if (XPStyle.getXP() != null) {
+ JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_UP);
+ Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
+ xpButton.setPreferredSize(size);
+ xpButton.setRequestFocusEnabled(false);
+ installNextButtonListeners(xpButton);
+ return xpButton;
+ }
+ return super.createNextButton();
+ }
+
+ private UIResource getUIResource(Object[] listeners) {
+ for (int counter = 0; counter < listeners.length; counter++) {
+ if (listeners[counter] instanceof UIResource) {
+ return (UIResource)listeners[counter];
+ }
+ }
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.JSplitPane;
+import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
+
+
+/**
+ * Divider used for Windows split pane.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Jeff Dinkins
+ */
+@SuppressWarnings("serial") // Superclass is not serializable across versions
+public class WindowsSplitPaneDivider extends BasicSplitPaneDivider
+{
+
+ /**
+ * Creates a new Windows SplitPaneDivider
+ */
+ public WindowsSplitPaneDivider(BasicSplitPaneUI ui) {
+ super(ui);
+ }
+
+ /**
+ * Paints the divider.
+ */
+ public void paint(Graphics g) {
+ Color bgColor = (splitPane.hasFocus()) ?
+ UIManager.getColor("SplitPane.shadow") :
+ getBackground();
+ Dimension size = getSize();
+
+ if(bgColor != null) {
+ g.setColor(bgColor);
+ g.fillRect(0, 0, size.width, size.height);
+ }
+ super.paint(g);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
+import javax.swing.plaf.*;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsSplitPaneUI extends BasicSplitPaneUI
+{
+
+ public WindowsSplitPaneUI() {
+ super();
+ }
+
+ /**
+ * Creates a new WindowsSplitPaneUI instance
+ */
+ public static ComponentUI createUI(JComponent x) {
+ return new WindowsSplitPaneUI();
+ }
+
+ /**
+ * Creates the default divider.
+ */
+ public BasicSplitPaneDivider createDefaultDivider() {
+ return new WindowsSplitPaneDivider(this);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.*;
+import javax.swing.*;
+import java.util.Set;
+import java.util.HashSet;
+import java.awt.event.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
+ /**
+ * Keys to use for forward focus traversal when the JComponent is
+ * managing focus.
+ */
+ private static Set<KeyStroke> managingFocusForwardTraversalKeys;
+
+ /**
+ * Keys to use for backward focus traversal when the JComponent is
+ * managing focus.
+ */
+ private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
+
+ private boolean contentOpaque = true;
+
+ @SuppressWarnings("deprecation")
+ protected void installDefaults() {
+ super.installDefaults();
+ contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
+
+ // focus forward traversal key
+ if (managingFocusForwardTraversalKeys==null) {
+ managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
+ managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+ }
+ tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
+ // focus backward traversal key
+ if (managingFocusBackwardTraversalKeys==null) {
+ managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
+ managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
+ }
+ tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
+ }
+
+ protected void uninstallDefaults() {
+ // sets the focus forward and backward traversal keys to null
+ // to restore the defaults
+ tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
+ tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
+ super.uninstallDefaults();
+ }
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsTabbedPaneUI();
+ }
+
+ protected void setRolloverTab(int index) {
+ // Rollover is only supported on XP
+ if (XPStyle.getXP() != null) {
+ int oldRolloverTab = getRolloverTab();
+ super.setRolloverTab(index);
+ Rectangle r1 = null;
+ Rectangle r2 = null;
+ if ( (oldRolloverTab >= 0) && (oldRolloverTab < tabPane.getTabCount()) ) {
+ r1 = getTabBounds(tabPane, oldRolloverTab);
+ }
+ if (index >= 0) {
+ r2 = getTabBounds(tabPane, index);
+ }
+ if (r1 != null) {
+ if (r2 != null) {
+ tabPane.repaint(r1.union(r2));
+ } else {
+ tabPane.repaint(r1);
+ }
+ } else if (r2 != null) {
+ tabPane.repaint(r2);
+ }
+ }
+ }
+
+ protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null && (contentOpaque || tabPane.isOpaque())) {
+ Skin skin = xp.getSkin(tabPane, Part.TABP_PANE);
+ if (skin != null) {
+ Insets insets = tabPane.getInsets();
+ // Note: don't call getTabAreaInsets(), because it causes rotation.
+ // Make sure "TabbedPane.tabsOverlapBorder" is set to true in WindowsLookAndFeel
+ Insets tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
+ int x = insets.left;
+ int y = insets.top;
+ int w = tabPane.getWidth() - insets.right - insets.left;
+ int h = tabPane.getHeight() - insets.top - insets.bottom;
+
+ // Expand area by tabAreaInsets.bottom to allow tabs to overlap onto the border.
+ if (tabPlacement == LEFT || tabPlacement == RIGHT) {
+ int tabWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
+ if (tabPlacement == LEFT) {
+ x += (tabWidth - tabAreaInsets.bottom);
+ }
+ w -= (tabWidth - tabAreaInsets.bottom);
+ } else {
+ int tabHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
+ if (tabPlacement == TOP) {
+ y += (tabHeight - tabAreaInsets.bottom);
+ }
+ h -= (tabHeight - tabAreaInsets.bottom);
+ }
+
+ paintRotatedSkin(g, skin, tabPlacement, x, y, w, h, null);
+ return;
+ }
+ }
+ super.paintContentBorder(g, tabPlacement, selectedIndex);
+ }
+
+ protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex,
+ int x, int y, int w, int h, boolean isSelected ) {
+ if (XPStyle.getXP() == null) {
+ super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
+ }
+ }
+
+ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
+ int x, int y, int w, int h, boolean isSelected ) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Part part;
+
+ int tabCount = tabPane.getTabCount();
+ int tabRun = getRunForTab(tabCount, tabIndex);
+ if (tabRuns[tabRun] == tabIndex) {
+ part = Part.TABP_TABITEMLEFTEDGE;
+ } else if (tabCount > 1 && lastTabInRun(tabCount, tabRun) == tabIndex) {
+ part = Part.TABP_TABITEMRIGHTEDGE;
+ if (isSelected) {
+ // Align with right edge
+ if (tabPlacement == TOP || tabPlacement == BOTTOM) {
+ w++;
+ } else {
+ h++;
+ }
+ }
+ } else {
+ part = Part.TABP_TABITEM;
+ }
+
+ State state = State.NORMAL;
+ if (isSelected) {
+ state = State.SELECTED;
+ } else if (tabIndex == getRolloverTab()) {
+ state = State.HOT;
+ }
+
+ paintRotatedSkin(g, xp.getSkin(tabPane, part), tabPlacement, x, y, w, h, state);
+ } else {
+ super.paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
+ }
+ }
+
+ private void paintRotatedSkin(Graphics g, Skin skin, int tabPlacement,
+ int x, int y, int w, int h, State state) {
+ Graphics2D g2d = (Graphics2D)g.create();
+ g2d.translate(x, y);
+ switch (tabPlacement) {
+ case RIGHT: g2d.translate(w, 0);
+ g2d.rotate(Math.toRadians(90.0));
+ skin.paintSkin(g2d, 0, 0, h, w, state);
+ break;
+
+ case LEFT: g2d.scale(-1.0, 1.0);
+ g2d.rotate(Math.toRadians(90.0));
+ skin.paintSkin(g2d, 0, 0, h, w, state);
+ break;
+
+ case BOTTOM: g2d.translate(0, h);
+ g2d.scale(-1.0, 1.0);
+ g2d.rotate(Math.toRadians(180.0));
+ skin.paintSkin(g2d, 0, 0, w, h, state);
+ break;
+
+ case TOP:
+ default: skin.paintSkin(g2d, 0, 0, w, h, state);
+ }
+ g2d.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.table.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.*;
+import sun.swing.table.*;
+import sun.swing.SwingUtilities2;
+
+
+public class WindowsTableHeaderUI extends BasicTableHeaderUI {
+ private TableCellRenderer originalHeaderRenderer;
+
+ public static ComponentUI createUI(JComponent h) {
+ return new WindowsTableHeaderUI();
+ }
+
+ public void installUI(JComponent c) {
+ super.installUI(c);
+
+ if (XPStyle.getXP() != null) {
+ originalHeaderRenderer = header.getDefaultRenderer();
+ if (originalHeaderRenderer instanceof UIResource) {
+ header.setDefaultRenderer(new XPDefaultRenderer());
+ }
+ }
+ }
+
+ public void uninstallUI(JComponent c) {
+ if (header.getDefaultRenderer() instanceof XPDefaultRenderer) {
+ header.setDefaultRenderer(originalHeaderRenderer);
+ }
+ super.uninstallUI(c);
+ }
+
+ @Override
+ protected void rolloverColumnUpdated(int oldColumn, int newColumn) {
+ if (XPStyle.getXP() != null) {
+ header.repaint(header.getHeaderRect(oldColumn));
+ header.repaint(header.getHeaderRect(newColumn));
+ }
+ }
+
+ @SuppressWarnings("serial") // JDK-implementation class
+ private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer {
+ Skin skin;
+ boolean isSelected, hasFocus, hasRollover;
+ int column;
+
+ XPDefaultRenderer() {
+ setHorizontalAlignment(LEADING);
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus,
+ int row, int column) {
+ super.getTableCellRendererComponent(table, value, isSelected,
+ hasFocus, row, column);
+ this.isSelected = isSelected;
+ this.hasFocus = hasFocus;
+ this.column = column;
+ this.hasRollover = (column == getRolloverColumn());
+ if (skin == null) {
+ XPStyle xp = XPStyle.getXP();
+ skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null;
+ }
+ Insets margins = (skin != null) ? skin.getContentMargin() : null;
+ Border border = null;
+ int contentTop = 0;
+ int contentLeft = 0;
+ int contentBottom = 0;
+ int contentRight = 0;
+ if (margins != null) {
+ contentTop = margins.top;
+ contentLeft = margins.left;
+ contentBottom = margins.bottom;
+ contentRight = margins.right;
+ }
+ /* idk:
+ * Both on Vista and XP there is some offset to the
+ * HP_HEADERITEM content. It does not seem to come from
+ * Prop.CONTENTMARGINS. Do not know where it is defined.
+ * using some hardcoded values.
+ */
+ contentLeft += 5;
+ contentBottom += 4;
+ contentRight += 5;
+
+ /* On Vista sortIcon is painted above the header's text.
+ * We use border to paint it.
+ */
+ Icon sortIcon;
+ if (WindowsLookAndFeel.isOnVista()
+ && ((sortIcon = getIcon()) instanceof javax.swing.plaf.UIResource
+ || sortIcon == null)) {
+ contentTop += 1;
+ setIcon(null);
+ sortIcon = null;
+ SortOrder sortOrder =
+ getColumnSortOrder(table, column);
+ if (sortOrder != null) {
+ switch (sortOrder) {
+ case ASCENDING:
+ sortIcon =
+ UIManager.getIcon("Table.ascendingSortIcon");
+ break;
+ case DESCENDING:
+ sortIcon =
+ UIManager.getIcon("Table.descendingSortIcon");
+ break;
+ }
+ }
+ if (sortIcon != null) {
+ contentBottom = sortIcon.getIconHeight();
+ border = new IconBorder(sortIcon, contentTop, contentLeft,
+ contentBottom, contentRight);
+ } else {
+ sortIcon =
+ UIManager.getIcon("Table.ascendingSortIcon");
+ int sortIconHeight =
+ (sortIcon != null) ? sortIcon.getIconHeight() : 0;
+ if (sortIconHeight != 0) {
+ contentBottom = sortIconHeight;
+ }
+ border =
+ new EmptyBorder(
+ sortIconHeight + contentTop, contentLeft,
+ contentBottom, contentRight);
+ }
+ } else {
+ contentTop += 3;
+ border = new EmptyBorder(contentTop, contentLeft,
+ contentBottom, contentRight);
+ }
+ setBorder(border);
+ return this;
+ }
+
+ public void paint(Graphics g) {
+ Dimension size = getSize();
+ State state = State.NORMAL;
+ TableColumn draggedColumn = header.getDraggedColumn();
+ if (draggedColumn != null &&
+ column == SwingUtilities2.convertColumnIndexToView(
+ header.getColumnModel(), draggedColumn.getModelIndex())) {
+ state = State.PRESSED;
+ } else if (isSelected || hasFocus || hasRollover) {
+ state = State.HOT;
+ }
+ /* on Vista there are more states for sorted columns */
+ if (WindowsLookAndFeel.isOnVista()) {
+ SortOrder sortOrder = getColumnSortOrder(header.getTable(), column);
+ if (sortOrder != null) {
+ switch(sortOrder) {
+ case ASCENDING:
+ case DESCENDING:
+ switch (state) {
+ case NORMAL:
+ state = State.SORTEDNORMAL;
+ break;
+ case PRESSED:
+ state = State.SORTEDPRESSED;
+ break;
+ case HOT:
+ state = State.SORTEDHOT;
+ break;
+ default:
+ /* do nothing */
+ }
+ break;
+ default :
+ /* do nothing */
+ }
+ }
+ }
+ skin.paintSkin(g, 0, 0, size.width-1, size.height-1, state);
+ super.paint(g);
+ }
+ }
+
+ /**
+ * A border with an Icon at the middle of the top side.
+ * Outer insets can be provided for this border.
+ */
+ private static class IconBorder implements Border, UIResource{
+ private final Icon icon;
+ private final int top;
+ private final int left;
+ private final int bottom;
+ private final int right;
+ /**
+ * Creates this border;
+ * @param icon - icon to paint for this border
+ * @param top, left, bottom, right - outer insets for this border
+ */
+ public IconBorder(Icon icon, int top, int left,
+ int bottom, int right) {
+ this.icon = icon;
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+ public Insets getBorderInsets(Component c) {
+ return new Insets(icon.getIconHeight() + top, left, bottom, right);
+ }
+ public boolean isBorderOpaque() {
+ return false;
+ }
+ public void paintBorder(Component c, Graphics g, int x, int y,
+ int width, int height) {
+ icon.paintIcon(c, g,
+ x + left + (width - left - right - icon.getIconWidth()) / 2,
+ y + top);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.text.Caret;
+
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsTextAreaUI extends BasicTextAreaUI {
+ /**
+ * Creates the object to use for a caret. By default an
+ * instance of WindowsCaret is created. This method
+ * can be redefined to provide something else that implements
+ * the InputPosition interface or a subclass of DefaultCaret.
+ *
+ * @return the caret object
+ */
+ protected Caret createCaret() {
+ return new WindowsTextUI.WindowsCaret();
+ }
+
+ /**
+ * Creates a UI for a JTextField.
+ *
+ * @param c the text field
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsTextAreaUI();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.BasicTextFieldUI;
+import javax.swing.text.*;
+import javax.swing.*;
+import javax.swing.plaf.UIResource;
+import sun.swing.DefaultLookup;
+
+
+
+/**
+ * Provides the Windows look and feel for a text field. This
+ * is basically the following customizations to the default
+ * look-and-feel.
+ * <ul>
+ * <li>The border is beveled (using the standard control color).
+ * <li>The background is white by default.
+ * <li>The highlight color is a dark color, blue by default.
+ * <li>The foreground color is high contrast in the selected
+ * area, white by default. The unselected foreground is black.
+ * <li>The cursor blinks at about 1/2 second intervals.
+ * <li>The entire value is selected when focus is gained.
+ * <li>Shift-left-arrow and shift-right-arrow extend selection
+ * <li>Ctrl-left-arrow and ctrl-right-arrow act like home and
+ * end respectively.
+ * </ul>
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Timothy Prinzing
+ */
+public class WindowsTextFieldUI extends BasicTextFieldUI
+{
+ /**
+ * Creates a UI for a JTextField.
+ *
+ * @param c the text field
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsTextFieldUI();
+ }
+
+ /**
+ * Paints a background for the view. This will only be
+ * called if isOpaque() on the associated component is
+ * true. The default is to paint the background color
+ * of the component.
+ *
+ * @param g the graphics context
+ */
+ protected void paintBackground(Graphics g) {
+ super.paintBackground(g);
+ }
+
+ /**
+ * Creates the caret for a field.
+ *
+ * @return the caret
+ */
+ protected Caret createCaret() {
+ return new WindowsFieldCaret();
+ }
+
+ /**
+ * WindowsFieldCaret has different scrolling behavior than
+ * DefaultCaret.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ static class WindowsFieldCaret extends DefaultCaret implements UIResource {
+
+ public WindowsFieldCaret() {
+ super();
+ }
+
+ /**
+ * Adjusts the visibility of the caret according to
+ * the windows feel which seems to be to move the
+ * caret out into the field by about a quarter of
+ * a field length if not visible.
+ */
+ protected void adjustVisibility(Rectangle r) {
+ SwingUtilities.invokeLater(new SafeScroller(r));
+ }
+
+ /**
+ * Gets the painter for the Highlighter.
+ *
+ * @return the painter
+ */
+ protected Highlighter.HighlightPainter getSelectionPainter() {
+ return WindowsTextUI.WindowsPainter;
+ }
+
+
+ private class SafeScroller implements Runnable {
+ SafeScroller(Rectangle r) {
+ this.r = r;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void run() {
+ JTextField field = (JTextField) getComponent();
+ if (field != null) {
+ TextUI ui = field.getUI();
+ int dot = getDot();
+ // PENDING: We need to expose the bias in DefaultCaret.
+ Position.Bias bias = Position.Bias.Forward;
+ Rectangle startRect = null;
+ try {
+ startRect = ui.modelToView(field, dot, bias);
+ } catch (BadLocationException ble) {}
+
+ Insets i = field.getInsets();
+ BoundedRangeModel vis = field.getHorizontalVisibility();
+ int x = r.x + vis.getValue() - i.left;
+ int quarterSpan = vis.getExtent() / 4;
+ if (r.x < i.left) {
+ vis.setValue(x - quarterSpan);
+ } else if (r.x + r.width > i.left + vis.getExtent()) {
+ vis.setValue(x - (3 * quarterSpan));
+ }
+ // If we scroll, our visual location will have changed,
+ // but we won't have updated our internal location as
+ // the model hasn't changed. This checks for the change,
+ // and if necessary, resets the internal location.
+ if (startRect != null) {
+ try {
+ Rectangle endRect;
+ endRect = ui.modelToView(field, dot, bias);
+ if (endRect != null && !endRect.equals(startRect)){
+ damage(endRect);
+ }
+ } catch (BadLocationException ble) {}
+ }
+ }
+ }
+
+ private Rectangle r;
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.text.Caret;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsTextPaneUI extends BasicTextPaneUI
+{
+ /**
+ * Creates a UI for a JTextPane.
+ *
+ * @param c the styled text component
+ * @return the UI
+ */
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsTextPaneUI();
+ }
+
+ /**
+ * Creates the object to use for a caret. By default an
+ * instance of WindowsCaret is created. This method
+ * can be redefined to provide something else that implements
+ * the InputPosition interface or a subclass of DefaultCaret.
+ *
+ * @return the caret object
+ */
+ protected Caret createCaret() {
+ return new WindowsTextUI.WindowsCaret();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.TextUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.text.*;
+
+/**
+ * Windows text rendering.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public abstract class WindowsTextUI extends BasicTextUI {
+ /**
+ * Creates the object to use for a caret. By default an
+ * instance of WindowsCaret is created. This method
+ * can be redefined to provide something else that implements
+ * the InputPosition interface or a subclass of DefaultCaret.
+ *
+ * @return the caret object
+ */
+ protected Caret createCaret() {
+ return new WindowsCaret();
+ }
+
+ /* public */
+ static LayeredHighlighter.LayerPainter WindowsPainter = new WindowsHighlightPainter(null);
+
+ /* public */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ static class WindowsCaret extends DefaultCaret
+ implements UIResource {
+ /**
+ * Gets the painter for the Highlighter.
+ *
+ * @return the painter
+ */
+ protected Highlighter.HighlightPainter getSelectionPainter() {
+ return WindowsTextUI.WindowsPainter;
+ }
+ }
+
+ /* public */
+ static class WindowsHighlightPainter extends
+ DefaultHighlighter.DefaultHighlightPainter {
+ WindowsHighlightPainter(Color c) {
+ super(c);
+ }
+
+ // --- HighlightPainter methods ---------------------------------------
+
+ /**
+ * Paints a highlight.
+ *
+ * @param g the graphics context
+ * @param offs0 the starting model offset >= 0
+ * @param offs1 the ending model offset >= offs1
+ * @param bounds the bounding box for the highlight
+ * @param c the editor
+ */
+ @SuppressWarnings("deprecation")
+ public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
+ Rectangle alloc = bounds.getBounds();
+ try {
+ // --- determine locations ---
+ TextUI mapper = c.getUI();
+ Rectangle p0 = mapper.modelToView(c, offs0);
+ Rectangle p1 = mapper.modelToView(c, offs1);
+
+ // --- render ---
+ Color color = getColor();
+
+ if (color == null) {
+ g.setColor(c.getSelectionColor());
+ }
+ else {
+ g.setColor(color);
+ }
+ boolean firstIsDot = false;
+ boolean secondIsDot = false;
+ if (c.isEditable()) {
+ int dot = c.getCaretPosition();
+ firstIsDot = (offs0 == dot);
+ secondIsDot = (offs1 == dot);
+ }
+ if (p0.y == p1.y) {
+ // same line, render a rectangle
+ Rectangle r = p0.union(p1);
+ if (r.width > 0) {
+ if (firstIsDot) {
+ r.x++;
+ r.width--;
+ }
+ else if (secondIsDot) {
+ r.width--;
+ }
+ }
+ g.fillRect(r.x, r.y, r.width, r.height);
+ } else {
+ // different lines
+ int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
+ if (firstIsDot && p0ToMarginWidth > 0) {
+ p0.x++;
+ p0ToMarginWidth--;
+ }
+ g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
+ if ((p0.y + p0.height) != p1.y) {
+ g.fillRect(alloc.x, p0.y + p0.height, alloc.width,
+ p1.y - (p0.y + p0.height));
+ }
+ if (secondIsDot && p1.x > alloc.x) {
+ p1.x--;
+ }
+ g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
+ }
+ } catch (BadLocationException e) {
+ // can't render
+ }
+ }
+
+ // --- LayerPainter methods ----------------------------
+ /**
+ * Paints a portion of a highlight.
+ *
+ * @param g the graphics context
+ * @param offs0 the starting model offset >= 0
+ * @param offs1 the ending model offset >= offs1
+ * @param bounds the bounding box of the view, which is not
+ * necessarily the region to paint.
+ * @param c the editor
+ * @param view View painting for
+ * @return region drawing occurred in
+ */
+ public Shape paintLayer(Graphics g, int offs0, int offs1,
+ Shape bounds, JTextComponent c, View view) {
+ Color color = getColor();
+
+ if (color == null) {
+ g.setColor(c.getSelectionColor());
+ }
+ else {
+ g.setColor(color);
+ }
+ boolean firstIsDot = false;
+ boolean secondIsDot = false;
+ if (c.isEditable()) {
+ int dot = c.getCaretPosition();
+ firstIsDot = (offs0 == dot);
+ secondIsDot = (offs1 == dot);
+ }
+ if (offs0 == view.getStartOffset() &&
+ offs1 == view.getEndOffset()) {
+ // Contained in view, can just use bounds.
+ Rectangle alloc;
+ if (bounds instanceof Rectangle) {
+ alloc = (Rectangle)bounds;
+ }
+ else {
+ alloc = bounds.getBounds();
+ }
+ if (firstIsDot && alloc.width > 0) {
+ g.fillRect(alloc.x + 1, alloc.y, alloc.width - 1,
+ alloc.height);
+ }
+ else if (secondIsDot && alloc.width > 0) {
+ g.fillRect(alloc.x, alloc.y, alloc.width - 1,
+ alloc.height);
+ }
+ else {
+ g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
+ }
+ return alloc;
+ }
+ else {
+ // Should only render part of View.
+ try {
+ // --- determine locations ---
+ Shape shape = view.modelToView(offs0, Position.Bias.Forward,
+ offs1,Position.Bias.Backward,
+ bounds);
+ Rectangle r = (shape instanceof Rectangle) ?
+ (Rectangle)shape : shape.getBounds();
+ if (firstIsDot && r.width > 0) {
+ g.fillRect(r.x + 1, r.y, r.width - 1, r.height);
+ }
+ else if (secondIsDot && r.width > 0) {
+ g.fillRect(r.x, r.y, r.width - 1, r.height);
+ }
+ else {
+ g.fillRect(r.x, r.y, r.width, r.height);
+ }
+ return r;
+ } catch (BadLocationException e) {
+ // can't render
+ }
+ }
+ // Only if exception
+ return null;
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import sun.awt.AppContext;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.border.*;
+import javax.swing.plaf.*;
+import javax.swing.*;
+
+import java.awt.*;
+import java.beans.PropertyChangeEvent;
+
+
+
+/**
+ * A Windows toggle button.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Jeff Dinkins
+ */
+public class WindowsToggleButtonUI extends BasicToggleButtonUI
+{
+ protected int dashedRectGapX;
+ protected int dashedRectGapY;
+ protected int dashedRectGapWidth;
+ protected int dashedRectGapHeight;
+
+ protected Color focusColor;
+
+ private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object();
+
+ private boolean defaults_initialized = false;
+
+ public static ComponentUI createUI(JComponent b) {
+ AppContext appContext = AppContext.getAppContext();
+ WindowsToggleButtonUI windowsToggleButtonUI =
+ (WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
+ if (windowsToggleButtonUI == null) {
+ windowsToggleButtonUI = new WindowsToggleButtonUI();
+ appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
+ }
+ return windowsToggleButtonUI;
+ }
+
+
+ // ********************************
+ // Defaults
+ // ********************************
+ protected void installDefaults(AbstractButton b) {
+ super.installDefaults(b);
+ if(!defaults_initialized) {
+ String pp = getPropertyPrefix();
+ dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
+ dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
+ dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
+ dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
+ focusColor = UIManager.getColor(pp + "focus");
+ defaults_initialized = true;
+ }
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ b.setBorder(xp.getBorder(b, WindowsButtonUI.getXPButtonType(b)));
+ LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
+ LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
+ }
+ }
+
+ protected void uninstallDefaults(AbstractButton b) {
+ super.uninstallDefaults(b);
+ defaults_initialized = false;
+ }
+
+
+ protected Color getFocusColor() {
+ return focusColor;
+ }
+
+
+ // ********************************
+ // Paint Methods
+ // ********************************
+
+ private transient Color cachedSelectedColor = null;
+ private transient Color cachedBackgroundColor = null;
+ private transient Color cachedHighlightColor = null;
+
+ protected void paintButtonPressed(Graphics g, AbstractButton b) {
+ if (XPStyle.getXP() == null && b.isContentAreaFilled()) {
+ Color oldColor = g.getColor();
+ Color c1 = b.getBackground();
+ Color c2 = UIManager.getColor("ToggleButton.highlight");
+ if (c1 != cachedBackgroundColor || c2 != cachedHighlightColor) {
+ int r1 = c1.getRed(), r2 = c2.getRed();
+ int g1 = c1.getGreen(), g2 = c2.getGreen();
+ int b1 = c1.getBlue(), b2 = c2.getBlue();
+ cachedSelectedColor = new Color(
+ Math.min(r1, r2) + Math.abs(r1 - r2) / 2,
+ Math.min(g1, g2) + Math.abs(g1 - g2) / 2,
+ Math.min(b1, b2) + Math.abs(b1 - b2) / 2
+ );
+ cachedBackgroundColor = c1;
+ cachedHighlightColor = c2;
+ }
+ g.setColor(cachedSelectedColor);
+ g.fillRect(0, 0, b.getWidth(), b.getHeight());
+ g.setColor(oldColor);
+ }
+ }
+
+ public void paint(Graphics g, JComponent c) {
+ if (XPStyle.getXP() != null) {
+ WindowsButtonUI.paintXPButtonBackground(g, c);
+ }
+ super.paint(g, c);
+ }
+
+
+ /**
+ * Overridden method to render the text without the mnemonic
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
+ WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
+ }
+
+ protected void paintFocus(Graphics g, AbstractButton b,
+ Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
+ g.setColor(getFocusColor());
+ BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
+ b.getWidth() - dashedRectGapWidth,
+ b.getHeight() - dashedRectGapHeight);
+ }
+
+ // ********************************
+ // Layout Methods
+ // ********************************
+ public Dimension getPreferredSize(JComponent c) {
+ Dimension d = super.getPreferredSize(c);
+
+ /* Ensure that the width and height of the button is odd,
+ * to allow for the focus line if focus is painted
+ */
+ AbstractButton b = (AbstractButton)c;
+ if (d != null && b.isFocusPainted()) {
+ if(d.width % 2 == 0) { d.width += 1; }
+ if(d.height % 2 == 0) { d.height += 1; }
+ }
+ return d;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.Part;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * Draws Windows toolbar separators.
+ *
+ * @author Mark Davidson
+ */
+public class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI {
+
+ public static ComponentUI createUI( JComponent c ) {
+ return new WindowsToolBarSeparatorUI();
+ }
+
+ public Dimension getPreferredSize(JComponent c) {
+ Dimension size = ((JToolBar.Separator)c).getSeparatorSize();
+
+ if (size != null) {
+ size = size.getSize();
+ } else {
+ size = new Dimension(6, 6);
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
+ Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
+ Skin skin = xp.getSkin(c, part);
+ size.width = skin.getWidth();
+ size.height = skin.getHeight();
+ }
+
+ if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
+ size.height = 0;
+ } else {
+ size.width = 0;
+ }
+ }
+ return size;
+ }
+
+ public Dimension getMaximumSize(JComponent c) {
+ Dimension pref = getPreferredSize(c);
+ if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
+ return new Dimension(pref.width, Short.MAX_VALUE);
+ } else {
+ return new Dimension(Short.MAX_VALUE, pref.height);
+ }
+ }
+
+ public void paint( Graphics g, JComponent c ) {
+ boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
+ Dimension size = c.getSize();
+
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
+ Skin skin = xp.getSkin(c, part);
+
+ int dx = vertical ? (size.width - skin.getWidth()) / 2 : 0;
+ int dy = vertical ? 0 : (size.height - skin.getHeight()) / 2;
+ int dw = vertical ? skin.getWidth() : size.width;
+ int dh = vertical ? size.height : skin.getHeight();
+ skin.paintSkin(g, dx, dy, dw, dh, null);
+ } else {
+
+ Color temp = g.getColor();
+
+ UIDefaults table = UIManager.getLookAndFeelDefaults();
+
+ Color shadow = table.getColor("ToolBar.shadow");
+ Color highlight = table.getColor("ToolBar.highlight");
+
+ if (vertical) {
+ int x = (size.width / 2) - 1;
+ g.setColor(shadow);
+ g.drawLine(x, 2, x, size.height - 2);
+
+ g.setColor(highlight);
+ g.drawLine(x + 1, 2, x + 1, size.height - 2);
+ } else {
+ int y = (size.height / 2) - 1;
+ g.setColor(shadow);
+ g.drawLine(2, y, size.width - 2, y);
+ g.setColor(highlight);
+ g.drawLine(2, y + 1, size.width - 2, y + 1);
+ }
+ g.setColor(temp);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.JToggleButton;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+
+import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+
+import javax.swing.plaf.*;
+
+import javax.swing.plaf.basic.BasicBorders;
+import javax.swing.plaf.basic.BasicToolBarUI;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.Part;
+
+
+public class WindowsToolBarUI extends BasicToolBarUI {
+
+ public static ComponentUI createUI(JComponent c) {
+ return new WindowsToolBarUI();
+ }
+
+ protected void installDefaults() {
+ if (XPStyle.getXP() != null) {
+ setRolloverBorders(true);
+ }
+ super.installDefaults();
+ }
+
+ protected Border createRolloverBorder() {
+ if (XPStyle.getXP() != null) {
+ return new EmptyBorder(3, 3, 3, 3);
+ } else {
+ return super.createRolloverBorder();
+ }
+ }
+
+ protected Border createNonRolloverBorder() {
+ if (XPStyle.getXP() != null) {
+ return new EmptyBorder(3, 3, 3, 3);
+ } else {
+ return super.createNonRolloverBorder();
+ }
+ }
+
+ public void paint(Graphics g, JComponent c) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ xp.getSkin(c, Part.TP_TOOLBAR).paintSkin(g, 0, 0,
+ c.getWidth(), c.getHeight(), null, true);
+ } else {
+ super.paint(g, c);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.6
+ */
+ protected Border getRolloverBorder(AbstractButton b) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return xp.getBorder(b, WindowsButtonUI.getXPButtonType(b));
+ } else {
+ return super.getRolloverBorder(b);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import java.io.*;
+import java.util.*;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+import javax.swing.tree.*;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
+
+/**
+ * A Windows tree.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @author Scott Violet
+ */
+public class WindowsTreeUI extends BasicTreeUI {
+
+ public static ComponentUI createUI( JComponent c )
+ {
+ return new WindowsTreeUI();
+ }
+
+
+ /**
+ * Ensures that the rows identified by beginRow through endRow are
+ * visible.
+ */
+ protected void ensureRowsAreVisible(int beginRow, int endRow) {
+ if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) {
+ Rectangle visRect = tree.getVisibleRect();
+ if(beginRow == endRow) {
+ Rectangle scrollBounds = getPathBounds(tree, getPathForRow
+ (tree, beginRow));
+
+ if(scrollBounds != null) {
+ scrollBounds.x = visRect.x;
+ scrollBounds.width = visRect.width;
+ tree.scrollRectToVisible(scrollBounds);
+ }
+ }
+ else {
+ Rectangle beginRect = getPathBounds(tree, getPathForRow
+ (tree, beginRow));
+ if (beginRect != null) {
+ Rectangle testRect = beginRect;
+ int beginY = beginRect.y;
+ int maxY = beginY + visRect.height;
+
+ for(int counter = beginRow + 1; counter <= endRow; counter++) {
+ testRect = getPathBounds(tree,
+ getPathForRow(tree, counter));
+ if(testRect != null && (testRect.y + testRect.height) > maxY) {
+ counter = endRow;
+ }
+ }
+
+ if (testRect == null) {
+ return;
+ }
+
+ tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
+ testRect.y + testRect.height-
+ beginY));
+ }
+ }
+ }
+ }
+
+ protected static final int HALF_SIZE = 4;
+ protected static final int SIZE = 9;
+
+ /**
+ * Returns the default cell renderer that is used to do the
+ * stamping of each node.
+ */
+ protected TreeCellRenderer createDefaultCellRenderer() {
+ return new WindowsTreeCellRenderer();
+ }
+
+ /**
+ * The minus sign button icon
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+ @SuppressWarnings("serial") // Same-version serialization only
+ public static class ExpandedIcon implements Icon, Serializable {
+
+ public static Icon createExpandedIcon() {
+ return new ExpandedIcon();
+ }
+
+ Skin getSkin(Component c) {
+ XPStyle xp = XPStyle.getXP();
+ return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Skin skin = getSkin(c);
+ if (skin != null) {
+ skin.paintSkin(g, x, y, State.OPENED);
+ return;
+ }
+
+ Color backgroundColor = c.getBackground();
+
+ if(backgroundColor != null)
+ g.setColor(backgroundColor);
+ else
+ g.setColor(Color.white);
+ g.fillRect(x, y, SIZE-1, SIZE-1);
+ g.setColor(Color.gray);
+ g.drawRect(x, y, SIZE-1, SIZE-1);
+ g.setColor(Color.black);
+ g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
+ }
+
+ public int getIconWidth() {
+ Skin skin = getSkin(null);
+ return (skin != null) ? skin.getWidth() : SIZE;
+ }
+
+ public int getIconHeight() {
+ Skin skin = getSkin(null);
+ return (skin != null) ? skin.getHeight() : SIZE;
+ }
+ }
+
+ /**
+ * The plus sign button icon
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public static class CollapsedIcon extends ExpandedIcon {
+ public static Icon createCollapsedIcon() {
+ return new CollapsedIcon();
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Skin skin = getSkin(c);
+ if (skin != null) {
+ skin.paintSkin(g, x, y, State.CLOSED);
+ } else {
+ super.paintIcon(c, g, x, y);
+ g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
+ }
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
+
+ /**
+ * Configures the renderer based on the passed in components.
+ * The value is set from messaging the tree with
+ * <code>convertValueToText</code>, which ultimately invokes
+ * <code>toString</code> on <code>value</code>.
+ * The foreground color is set based on the selection and the icon
+ * is set based on on leaf and expanded.
+ */
+ public Component getTreeCellRendererComponent(JTree tree, Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf, int row,
+ boolean hasFocus) {
+ super.getTreeCellRendererComponent(tree, value, sel,
+ expanded, leaf, row,
+ hasFocus);
+ // Windows displays the open icon when the tree item selected.
+ if (!tree.isEnabled()) {
+ setEnabled(false);
+ if (leaf) {
+ setDisabledIcon(getLeafIcon());
+ } else if (sel) {
+ setDisabledIcon(getOpenIcon());
+ } else {
+ setDisabledIcon(getClosedIcon());
+ }
+ }
+ else {
+ setEnabled(true);
+ if (leaf) {
+ setIcon(getLeafIcon());
+ } else if (sel) {
+ setIcon(getOpenIcon());
+ } else {
+ setIcon(getClosedIcon());
+ }
+ }
+ return this;
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,774 @@
+/*
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * <p>These classes are designed to be used while the
+ * corresponding <code>LookAndFeel</code> class has been installed
+ * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
+ * Using them while a different <code>LookAndFeel</code> is installed
+ * may produce unexpected results, including exceptions.
+ * Additionally, changing the <code>LookAndFeel</code>
+ * maintained by the <code>UIManager</code> without updating the
+ * corresponding <code>ComponentUI</code> of any
+ * <code>JComponent</code>s may also produce unexpected results,
+ * such as the wrong colors showing up, and is generally not
+ * encouraged.
+ *
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import java.awt.*;
+import java.awt.image.*;
+import java.security.AccessController;
+import java.util.*;
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.plaf.*;
+import javax.swing.text.JTextComponent;
+
+import sun.awt.image.SunWritableRaster;
+import sun.awt.windows.ThemeReader;
+import sun.security.action.GetPropertyAction;
+import sun.swing.CachedPainter;
+
+import static com.sun.java.swing.plaf.windows.TMSchema.*;
+
+
+/**
+ * Implements Windows XP Styles for the Windows Look and Feel.
+ *
+ * @author Leif Samuelsson
+ */
+class XPStyle {
+ // Singleton instance of this class
+ private static XPStyle xp;
+
+ // Singleton instance of SkinPainter
+ private static SkinPainter skinPainter = new SkinPainter();
+
+ private static Boolean themeActive = null;
+
+ private HashMap<String, Border> borderMap;
+ private HashMap<String, Color> colorMap;
+
+ private boolean flatMenus;
+
+ static {
+ invalidateStyle();
+ }
+
+ /** Static method for clearing the hashmap and loading the
+ * current XP style and theme
+ */
+ static synchronized void invalidateStyle() {
+ xp = null;
+ themeActive = null;
+ skinPainter.flush();
+ }
+
+ /** Get the singleton instance of this class
+ *
+ * @return the singleton instance of this class or null if XP styles
+ * are not active or if this is not Windows XP
+ */
+ static synchronized XPStyle getXP() {
+ if (themeActive == null) {
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ themeActive =
+ (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
+ if (themeActive == null) {
+ themeActive = Boolean.FALSE;
+ }
+ if (themeActive.booleanValue()) {
+ GetPropertyAction propertyAction =
+ new GetPropertyAction("swing.noxp");
+ if (AccessController.doPrivileged(propertyAction) == null &&
+ ThemeReader.isThemed() &&
+ !(UIManager.getLookAndFeel()
+ instanceof WindowsClassicLookAndFeel)) {
+
+ xp = new XPStyle();
+ }
+ }
+ }
+ return ThemeReader.isXPStyleEnabled() ? xp : null;
+ }
+
+ static boolean isVista() {
+ XPStyle xp = XPStyle.getXP();
+ return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
+ }
+
+ /** Get a named <code>String</code> value from the current style
+ *
+ * @param part a <code>Part</code>
+ * @param state a <code>String</code>
+ * @param prop a <code>String</code>
+ * @return a <code>String</code> or null if key is not found
+ * in the current style
+ *
+ * This is currently only used by WindowsInternalFrameTitlePane for painting
+ * title foregound and can be removed when no longer needed
+ */
+ String getString(Component c, Part part, State state, Prop prop) {
+ return getTypeEnumName(c, part, state, prop);
+ }
+
+ TypeEnum getTypeEnum(Component c, Part part, State state, Prop prop) {
+ int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ return TypeEnum.getTypeEnum(prop, enumValue);
+ }
+
+ private static String getTypeEnumName(Component c, Part part, State state, Prop prop) {
+ int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ if (enumValue == -1) {
+ return null;
+ }
+ return TypeEnum.getTypeEnum(prop, enumValue).getName();
+ }
+
+
+
+
+ /** Get a named <code>int</code> value from the current style
+ *
+ * @param part a <code>Part</code>
+ * @return an <code>int</code> or null if key is not found
+ * in the current style
+ */
+ int getInt(Component c, Part part, State state, Prop prop, int fallback) {
+ return ThemeReader.getInt(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ }
+
+ /** Get a named <code>Dimension</code> value from the current style
+ *
+ * @return a <code>Dimension</code> or null if key is not found
+ * in the current style
+ *
+ * This is currently only used by WindowsProgressBarUI and the value
+ * should probably be cached there instead of here.
+ */
+ Dimension getDimension(Component c, Part part, State state, Prop prop) {
+ Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ return (d != null) ? d : new Dimension();
+ }
+
+ /** Get a named <code>Point</code> (e.g. a location or an offset) value
+ * from the current style
+ *
+ * @return a <code>Point</code> or null if key is not found
+ * in the current style
+ *
+ * This is currently only used by WindowsInternalFrameTitlePane for painting
+ * title foregound and can be removed when no longer needed
+ */
+ Point getPoint(Component c, Part part, State state, Prop prop) {
+ Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ return (d != null) ? new Point(d.width, d.height) : new Point();
+ }
+
+ /** Get a named <code>Insets</code> value from the current style
+ *
+ * @return an <code>Insets</code> object or null if key is not found
+ * in the current style
+ *
+ * This is currently only used to create borders and by
+ * WindowsInternalFrameTitlePane for painting title foregound.
+ * The return value is already cached in those places.
+ */
+ Insets getMargin(Component c, Part part, State state, Prop prop) {
+ Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ return (insets != null) ? insets : new Insets(0, 0, 0, 0);
+ }
+
+
+ /** Get a named <code>Color</code> value from the current style
+ *
+ * @return a <code>Color</code> or null if key is not found
+ * in the current style
+ */
+ synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
+ String key = skin.toString() + "." + prop.name();
+ Part part = skin.part;
+ Color color = colorMap.get(key);
+ if (color == null) {
+ color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
+ State.getValue(part, skin.state),
+ prop.getValue());
+ if (color != null) {
+ color = new ColorUIResource(color);
+ colorMap.put(key, color);
+ }
+ }
+ return (color != null) ? color : fallback;
+ }
+
+ Color getColor(Component c, Part part, State state, Prop prop, Color fallback) {
+ return getColor(new Skin(c, part, state), prop, fallback);
+ }
+
+
+
+ /** Get a named <code>Border</code> value from the current style
+ *
+ * @param part a <code>Part</code>
+ * @return a <code>Border</code> or null if key is not found
+ * in the current style or if the style for the particular
+ * part is not defined as "borderfill".
+ */
+ synchronized Border getBorder(Component c, Part part) {
+ if (part == Part.MENU) {
+ // Special case because XP has no skin for menus
+ if (flatMenus) {
+ // TODO: The classic border uses this color, but we should
+ // create a new UI property called "PopupMenu.borderColor"
+ // instead.
+ return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"),
+ 1);
+ } else {
+ return null; // Will cause L&F to use classic border
+ }
+ }
+ Skin skin = new Skin(c, part, null);
+ Border border = borderMap.get(skin.string);
+ if (border == null) {
+ String bgType = getTypeEnumName(c, part, null, Prop.BGTYPE);
+ if ("borderfill".equalsIgnoreCase(bgType)) {
+ int thickness = getInt(c, part, null, Prop.BORDERSIZE, 1);
+ Color color = getColor(skin, Prop.BORDERCOLOR, Color.black);
+ border = new XPFillBorder(color, thickness);
+ if (part == Part.CP_COMBOBOX) {
+ border = new XPStatefulFillBorder(color, thickness, part, Prop.BORDERCOLOR);
+ }
+ } else if ("imagefile".equalsIgnoreCase(bgType)) {
+ Insets m = getMargin(c, part, null, Prop.SIZINGMARGINS);
+ if (m != null) {
+ if (getBoolean(c, part, null, Prop.BORDERONLY)) {
+ border = new XPImageBorder(c, part);
+ } else if (part == Part.CP_COMBOBOX) {
+ border = new EmptyBorder(1, 1, 1, 1);
+ } else {
+ if(part == Part.TP_BUTTON) {
+ border = new XPEmptyBorder(new Insets(3,3,3,3));
+ } else {
+ border = new XPEmptyBorder(m);
+ }
+ }
+ }
+ }
+ if (border != null) {
+ borderMap.put(skin.string, border);
+ }
+ }
+ return border;
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPFillBorder extends LineBorder implements UIResource {
+ XPFillBorder(Color color, int thickness) {
+ super(color, thickness);
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ Insets margin = null;
+ //
+ // Ideally we'd have an interface defined for classes which
+ // support margins (to avoid this hackery), but we've
+ // decided against it for simplicity
+ //
+ if (c instanceof AbstractButton) {
+ margin = ((AbstractButton)c).getMargin();
+ } else if (c instanceof JToolBar) {
+ margin = ((JToolBar)c).getMargin();
+ } else if (c instanceof JTextComponent) {
+ margin = ((JTextComponent)c).getMargin();
+ }
+ insets.top = (margin != null? margin.top : 0) + thickness;
+ insets.left = (margin != null? margin.left : 0) + thickness;
+ insets.bottom = (margin != null? margin.bottom : 0) + thickness;
+ insets.right = (margin != null? margin.right : 0) + thickness;
+
+ return insets;
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPStatefulFillBorder extends XPFillBorder {
+ private final Part part;
+ private final Prop prop;
+ XPStatefulFillBorder(Color color, int thickness, Part part, Prop prop) {
+ super(color, thickness);
+ this.part = part;
+ this.prop = prop;
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ State state = State.NORMAL;
+ // special casing for comboboxes.
+ // there may be more special cases in the future
+ if(c instanceof JComboBox) {
+ JComboBox<?> cb = (JComboBox)c;
+ // note. in the future this should be replaced with a call
+ // to BasicLookAndFeel.getUIOfType()
+ if(cb.getUI() instanceof WindowsComboBoxUI) {
+ WindowsComboBoxUI wcb = (WindowsComboBoxUI)cb.getUI();
+ state = wcb.getXPComboBoxState(cb);
+ }
+ }
+ lineColor = getColor(c, part, state, prop, Color.black);
+ super.paintBorder(c, g, x, y, width, height);
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPImageBorder extends AbstractBorder implements UIResource {
+ Skin skin;
+
+ XPImageBorder(Component c, Part part) {
+ this.skin = getSkin(c, part);
+ }
+
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height) {
+ skin.paintSkin(g, x, y, width, height, null);
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ Insets margin = null;
+ Insets borderInsets = skin.getContentMargin();
+ if(borderInsets == null) {
+ borderInsets = new Insets(0, 0, 0, 0);
+ }
+ //
+ // Ideally we'd have an interface defined for classes which
+ // support margins (to avoid this hackery), but we've
+ // decided against it for simplicity
+ //
+ if (c instanceof AbstractButton) {
+ margin = ((AbstractButton)c).getMargin();
+ } else if (c instanceof JToolBar) {
+ margin = ((JToolBar)c).getMargin();
+ } else if (c instanceof JTextComponent) {
+ margin = ((JTextComponent)c).getMargin();
+ }
+ insets.top = (margin != null? margin.top : 0) + borderInsets.top;
+ insets.left = (margin != null? margin.left : 0) + borderInsets.left;
+ insets.bottom = (margin != null? margin.bottom : 0) + borderInsets.bottom;
+ insets.right = (margin != null? margin.right : 0) + borderInsets.right;
+
+ return insets;
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ private class XPEmptyBorder extends EmptyBorder implements UIResource {
+ XPEmptyBorder(Insets m) {
+ super(m.top+2, m.left+2, m.bottom+2, m.right+2);
+ }
+
+ public Insets getBorderInsets(Component c, Insets insets) {
+ insets = super.getBorderInsets(c, insets);
+
+ Insets margin = null;
+ if (c instanceof AbstractButton) {
+ Insets m = ((AbstractButton)c).getMargin();
+ // if this is a toolbar button then ignore getMargin()
+ // and subtract the padding added by the constructor
+ if(c.getParent() instanceof JToolBar
+ && ! (c instanceof JRadioButton)
+ && ! (c instanceof JCheckBox)
+ && m instanceof InsetsUIResource) {
+ insets.top -= 2;
+ insets.left -= 2;
+ insets.bottom -= 2;
+ insets.right -= 2;
+ } else {
+ margin = m;
+ }
+ } else if (c instanceof JToolBar) {
+ margin = ((JToolBar)c).getMargin();
+ } else if (c instanceof JTextComponent) {
+ margin = ((JTextComponent)c).getMargin();
+ }
+ if (margin != null) {
+ insets.top = margin.top + 2;
+ insets.left = margin.left + 2;
+ insets.bottom = margin.bottom + 2;
+ insets.right = margin.right + 2;
+ }
+ return insets;
+ }
+ }
+ boolean isSkinDefined(Component c, Part part) {
+ return (part.getValue() == 0)
+ || ThemeReader.isThemePartDefined(
+ part.getControlName(c), part.getValue(), 0);
+ }
+
+
+ /** Get a <code>Skin</code> object from the current style
+ * for a named part (component type)
+ *
+ * @param part a <code>Part</code>
+ * @return a <code>Skin</code> object
+ */
+ synchronized Skin getSkin(Component c, Part part) {
+ assert isSkinDefined(c, part) : "part " + part + " is not defined";
+ return new Skin(c, part, null);
+ }
+
+
+ long getThemeTransitionDuration(Component c, Part part, State stateFrom,
+ State stateTo, Prop prop) {
+ return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
+ part.getValue(),
+ State.getValue(part, stateFrom),
+ State.getValue(part, stateTo),
+ (prop != null) ? prop.getValue() : 0);
+ }
+
+
+ /** A class which encapsulates attributes for a given part
+ * (component type) and which provides methods for painting backgrounds
+ * and glyphs
+ */
+ static class Skin {
+ final Component component;
+ final Part part;
+ final State state;
+
+ private final String string;
+ private Dimension size = null;
+ private boolean switchStates = false;
+
+ Skin(Component component, Part part) {
+ this(component, part, null);
+ }
+
+ Skin(Part part, State state) {
+ this(null, part, state);
+ }
+
+ Skin(Component component, Part part, State state) {
+ this.component = component;
+ this.part = part;
+ this.state = state;
+
+ String str = part.getControlName(component) +"." + part.name();
+ if (state != null) {
+ str += "("+state.name()+")";
+ }
+ string = str;
+ }
+
+ Insets getContentMargin() {
+ /* idk: it seems margins are the same for all 'big enough'
+ * bounding rectangles.
+ */
+ int boundingWidth = 100;
+ int boundingHeight = 100;
+
+ Insets insets = ThemeReader.getThemeBackgroundContentMargins(
+ part.getControlName(null), part.getValue(),
+ 0, boundingWidth, boundingHeight);
+ return (insets != null) ? insets : new Insets(0, 0, 0, 0);
+ }
+
+ boolean haveToSwitchStates() {
+ return switchStates;
+ }
+
+ void switchStates(boolean b) {
+ switchStates = b;
+ }
+
+ private int getWidth(State state) {
+ if (size == null) {
+ size = getPartSize(part, state);
+ }
+ return (size != null) ? size.width : 0;
+ }
+
+ int getWidth() {
+ return getWidth((state != null) ? state : State.NORMAL);
+ }
+
+ private int getHeight(State state) {
+ if (size == null) {
+ size = getPartSize(part, state);
+ }
+ return (size != null) ? size.height : 0;
+ }
+
+ int getHeight() {
+ return getHeight((state != null) ? state : State.NORMAL);
+ }
+
+ public String toString() {
+ return string;
+ }
+
+ public boolean equals(Object obj) {
+ return (obj instanceof Skin && ((Skin)obj).string.equals(string));
+ }
+
+ public int hashCode() {
+ return string.hashCode();
+ }
+
+ /** Paint a skin at x, y.
+ *
+ * @param g the graphics context to use for painting
+ * @param dx the destination <i>x</i> coordinate
+ * @param dy the destination <i>y</i> coordinate
+ * @param state which state to paint
+ */
+ void paintSkin(Graphics g, int dx, int dy, State state) {
+ if (state == null) {
+ state = this.state;
+ }
+ paintSkin(g, dx, dy, getWidth(state), getHeight(state), state);
+ }
+
+ /** Paint a skin in an area defined by a rectangle.
+ *
+ * @param g the graphics context to use for painting
+ * @param r a <code>Rectangle</code> defining the area to fill,
+ * may cause the image to be stretched or tiled
+ * @param state which state to paint
+ */
+ void paintSkin(Graphics g, Rectangle r, State state) {
+ paintSkin(g, r.x, r.y, r.width, r.height, state);
+ }
+
+ /** Paint a skin at a defined position and size
+ * This method supports animation.
+ *
+ * @param g the graphics context to use for painting
+ * @param dx the destination <i>x</i> coordinate
+ * @param dy the destination <i>y</i> coordinate
+ * @param dw the width of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param dh the height of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param state which state to paint
+ */
+ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
+ if (ThemeReader.isGetThemeTransitionDurationDefined()
+ && component instanceof JComponent
+ && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
+ component) == null) {
+ AnimationController.paintSkin((JComponent) component, this,
+ g, dx, dy, dw, dh, state);
+ } else {
+ paintSkinRaw(g, dx, dy, dw, dh, state);
+ }
+ }
+
+ /** Paint a skin at a defined position and size. This method
+ * does not trigger animation. It is needed for the animation
+ * support.
+ *
+ * @param g the graphics context to use for painting
+ * @param dx the destination <i>x</i> coordinate.
+ * @param dy the destination <i>y</i> coordinate.
+ * @param dw the width of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param dh the height of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param state which state to paint
+ */
+ void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
+ skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
+ }
+
+ /** Paint a skin at a defined position and size
+ *
+ * @param g the graphics context to use for painting
+ * @param dx the destination <i>x</i> coordinate
+ * @param dy the destination <i>y</i> coordinate
+ * @param dw the width of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param dh the height of the area to fill, may cause
+ * the image to be stretched or tiled
+ * @param state which state to paint
+ * @param borderFill should test if the component uses a border fill
+ and skip painting if it is
+ */
+ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
+ boolean borderFill) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
+ if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
+ state, Prop.BGTYPE))) {
+ return;
+ }
+ skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
+ }
+ }
+
+ private static class SkinPainter extends CachedPainter {
+ SkinPainter() {
+ super(30);
+ flush();
+ }
+
+ public void flush() {
+ super.flush();
+ }
+
+ protected void paintToImage(Component c, Image image, Graphics g,
+ int w, int h, Object[] args) {
+ Skin skin = (Skin)args[0];
+ Part part = skin.part;
+ State state = (State)args[1];
+ if (state == null) {
+ state = skin.state;
+ }
+ if (c == null) {
+ c = skin.component;
+ }
+ BufferedImage bi = (BufferedImage)image;
+ w = bi.getWidth();
+ h = bi.getHeight();
+
+ WritableRaster raster = bi.getRaster();
+ DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
+ // Note that stealData() requires a markDirty() afterwards
+ // since we modify the data in it.
+ ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
+ part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ 0, 0, w, h, w);
+ SunWritableRaster.markDirty(dbi);
+ }
+
+ protected Image createImage(Component c, int w, int h,
+ GraphicsConfiguration config, Object[] args) {
+ return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ }
+ }
+
+ @SuppressWarnings("serial") // Superclass is not serializable across versions
+ static class GlyphButton extends JButton {
+ protected Skin skin;
+
+ public GlyphButton(Component parent, Part part) {
+ XPStyle xp = getXP();
+ skin = xp != null ? xp.getSkin(parent, part) : null;
+ setBorder(null);
+ setContentAreaFilled(false);
+ setMinimumSize(new Dimension(5, 5));
+ setPreferredSize(new Dimension(16, 16));
+ setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isFocusTraversable() {
+ return false;
+ }
+
+ protected State getState() {
+ State state = State.NORMAL;
+ if (!isEnabled()) {
+ state = State.DISABLED;
+ } else if (getModel().isPressed()) {
+ state = State.PRESSED;
+ } else if (getModel().isRollover()) {
+ state = State.HOT;
+ }
+ return state;
+ }
+
+ public void paintComponent(Graphics g) {
+ if (XPStyle.getXP() == null || skin == null) {
+ return;
+ }
+ Dimension d = getSize();
+ skin.paintSkin(g, 0, 0, d.width, d.height, getState());
+ }
+
+ public void setPart(Component parent, Part part) {
+ XPStyle xp = getXP();
+ skin = xp != null ? xp.getSkin(parent, part) : null;
+ revalidate();
+ repaint();
+ }
+
+ protected void paintBorder(Graphics g) {
+ }
+
+
+ }
+
+ // Private constructor
+ private XPStyle() {
+ flatMenus = getSysBoolean(Prop.FLATMENUS);
+
+ colorMap = new HashMap<String, Color>();
+ borderMap = new HashMap<String, Border>();
+ // Note: All further access to the maps must be synchronized
+ }
+
+
+ private boolean getBoolean(Component c, Part part, State state, Prop prop) {
+ return ThemeReader.getBoolean(part.getControlName(c), part.getValue(),
+ State.getValue(part, state),
+ prop.getValue());
+ }
+
+
+
+ static Dimension getPartSize(Part part, State state) {
+ return ThemeReader.getPartSize(part.getControlName(null), part.getValue(),
+ State.getValue(part, state));
+ }
+
+ private static boolean getSysBoolean(Prop prop) {
+ // We can use any widget name here, I guess.
+ return ThemeReader.getSysBoolean("window", prop.getValue());
+ }
+}
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Computer.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/DetailsView.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Directory.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Error.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/File.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/FloppyDrive.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/HardDrive.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/HomeFolder.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Inform.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/JavaCup32.png has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/ListView.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/NewFolder.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Question.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/TreeClosed.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/TreeLeaf.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/TreeOpen.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/UpFolder.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/Warn.gif has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/image-delayed.png has changed
Binary file src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/icons/image-failed.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Look &in:
+FileChooser.saveInLabel.textAndMnemonic=Save in:
+FileChooser.fileNameLabel.textAndMnemonic=File &name:
+FileChooser.folderNameLabel.textAndMnemonic=Folder &name:
+FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &type:
+FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
+FileChooser.upFolderAccessibleName=Up
+FileChooser.homeFolderToolTip.textAndMnemonic=Home
+FileChooser.homeFolderAccessibleName=Home
+FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
+FileChooser.newFolderAccessibleName=New Folder
+FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
+FileChooser.listViewButtonToolTip.textAndMnemonic=List
+FileChooser.listViewButtonAccessibleName=List
+FileChooser.listViewActionLabel.textAndMnemonic=List
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
+FileChooser.detailsViewButtonAccessibleName=Details
+FileChooser.viewMenuButtonToolTipText = View Menu
+FileChooser.viewMenuButtonAccessibleName = View Menu
+FileChooser.detailsViewActionLabel.textAndMnemonic=Details
+FileChooser.refreshActionLabel.textAndMnemonic=Refresh
+FileChooser.viewMenuLabel.textAndMnemonic=View
+FileChooser.fileNameHeader.textAndMnemonic=Name
+FileChooser.fileSizeHeader.textAndMnemonic=Size
+FileChooser.fileTypeHeader.textAndMnemonic=Type
+FileChooser.fileDateHeader.textAndMnemonic=Modified
+FileChooser.fileAttrHeader.textAndMnemonic=Attributes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_de.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Suchen &in:
+FileChooser.saveInLabel.textAndMnemonic=Speichern in:
+FileChooser.fileNameLabel.textAndMnemonic=&Dateiname:
+FileChooser.folderNameLabel.textAndMnemonic=Ordner&name:
+FileChooser.filesOfTypeLabel.textAndMnemonic=Datei&typ:
+FileChooser.upFolderToolTip.textAndMnemonic=Eine Ebene h\u00F6her
+FileChooser.upFolderAccessibleName=Nach oben
+FileChooser.homeFolderToolTip.textAndMnemonic=Home
+FileChooser.homeFolderAccessibleName=Home
+FileChooser.newFolderToolTip.textAndMnemonic=Neuen Ordner erstellen
+FileChooser.newFolderAccessibleName=Neuer Ordner
+FileChooser.newFolderActionLabel.textAndMnemonic=Neuer Ordner
+FileChooser.listViewButtonToolTip.textAndMnemonic=Liste
+FileChooser.listViewButtonAccessibleName=Liste
+FileChooser.listViewActionLabel.textAndMnemonic=Liste
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
+FileChooser.detailsViewButtonAccessibleName=Details
+FileChooser.viewMenuButtonToolTipText = Ansichtsmen\u00FC
+FileChooser.viewMenuButtonAccessibleName = Ansichtsmen\u00FC
+FileChooser.detailsViewActionLabel.textAndMnemonic=Details
+FileChooser.refreshActionLabel.textAndMnemonic=Aktualisieren
+FileChooser.viewMenuLabel.textAndMnemonic=Ansicht
+FileChooser.fileNameHeader.textAndMnemonic=Name
+FileChooser.fileSizeHeader.textAndMnemonic=Gr\u00F6\u00DFe
+FileChooser.fileTypeHeader.textAndMnemonic=Typ
+FileChooser.fileDateHeader.textAndMnemonic=Ge\u00E4ndert
+FileChooser.fileAttrHeader.textAndMnemonic=Attribute
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_es.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=&Buscar en:
+FileChooser.saveInLabel.textAndMnemonic=Guardar en:
+FileChooser.fileNameLabel.textAndMnemonic=&Nombre de archivo:
+FileChooser.folderNameLabel.textAndMnemonic=&Nombre de carpeta:
+FileChooser.filesOfTypeLabel.textAndMnemonic=Archivos de &tipo:
+FileChooser.upFolderToolTip.textAndMnemonic=Subir un Nivel
+FileChooser.upFolderAccessibleName=Arriba
+FileChooser.homeFolderToolTip.textAndMnemonic=Inicio
+FileChooser.homeFolderAccessibleName=Inicio
+FileChooser.newFolderToolTip.textAndMnemonic=Crear Nueva Carpeta
+FileChooser.newFolderAccessibleName=Nueva Carpeta
+FileChooser.newFolderActionLabel.textAndMnemonic=Nueva Carpeta
+FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
+FileChooser.listViewButtonAccessibleName=Lista
+FileChooser.listViewActionLabel.textAndMnemonic=Lista
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detalles
+FileChooser.detailsViewButtonAccessibleName=Detalles
+FileChooser.viewMenuButtonToolTipText = Men\u00FA Ver
+FileChooser.viewMenuButtonAccessibleName = Men\u00FA Ver
+FileChooser.detailsViewActionLabel.textAndMnemonic=Detalles
+FileChooser.refreshActionLabel.textAndMnemonic=Refrescar
+FileChooser.viewMenuLabel.textAndMnemonic=Ver
+FileChooser.fileNameHeader.textAndMnemonic=Nombre
+FileChooser.fileSizeHeader.textAndMnemonic=Tama\u00F1o
+FileChooser.fileTypeHeader.textAndMnemonic=Tipo
+FileChooser.fileDateHeader.textAndMnemonic=Modificado
+FileChooser.fileAttrHeader.textAndMnemonic=Atributos
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_fr.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Rechercher &dans :
+FileChooser.saveInLabel.textAndMnemonic=Enregistrer dans :
+FileChooser.fileNameLabel.textAndMnemonic=&Nom du fichier :
+FileChooser.folderNameLabel.textAndMnemonic=&Nom du dossier :
+FileChooser.filesOfTypeLabel.textAndMnemonic=&Type de fichier :
+FileChooser.upFolderToolTip.textAndMnemonic=Remonte d'un niveau.
+FileChooser.upFolderAccessibleName=Monter
+FileChooser.homeFolderToolTip.textAndMnemonic=R\u00E9pertoire de base
+FileChooser.homeFolderAccessibleName=R\u00E9pertoire de base
+FileChooser.newFolderToolTip.textAndMnemonic=Cr\u00E9e un dossier.
+FileChooser.newFolderAccessibleName=Nouveau dossier
+FileChooser.newFolderActionLabel.textAndMnemonic=Nouveau dossier
+FileChooser.listViewButtonToolTip.textAndMnemonic=Liste
+FileChooser.listViewButtonAccessibleName=Liste
+FileChooser.listViewActionLabel.textAndMnemonic=Liste
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=D\u00E9tails
+FileChooser.detailsViewButtonAccessibleName=D\u00E9tails
+FileChooser.viewMenuButtonToolTipText = Menu Affichage
+FileChooser.viewMenuButtonAccessibleName = Menu Affichage
+FileChooser.detailsViewActionLabel.textAndMnemonic=D\u00E9tails
+FileChooser.refreshActionLabel.textAndMnemonic=Actualiser
+FileChooser.viewMenuLabel.textAndMnemonic=Affichage
+FileChooser.fileNameHeader.textAndMnemonic=Nom
+FileChooser.fileSizeHeader.textAndMnemonic=Taille
+FileChooser.fileTypeHeader.textAndMnemonic=Type
+FileChooser.fileDateHeader.textAndMnemonic=Modifi\u00E9
+FileChooser.fileAttrHeader.textAndMnemonic=Attributs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_it.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Cerca &in:
+FileChooser.saveInLabel.textAndMnemonic=Salva in:
+FileChooser.fileNameLabel.textAndMnemonic=&Nome file:
+FileChooser.folderNameLabel.textAndMnemonic=&Nome cartella:
+FileChooser.filesOfTypeLabel.textAndMnemonic=&Tipo file:
+FileChooser.upFolderToolTip.textAndMnemonic=Cartella superiore
+FileChooser.upFolderAccessibleName=Superiore
+FileChooser.homeFolderToolTip.textAndMnemonic=Home
+FileChooser.homeFolderAccessibleName=Home
+FileChooser.newFolderToolTip.textAndMnemonic=Crea nuova cartella
+FileChooser.newFolderAccessibleName=Nuova cartella
+FileChooser.newFolderActionLabel.textAndMnemonic=Nuova cartella
+FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
+FileChooser.listViewButtonAccessibleName=Lista
+FileChooser.listViewActionLabel.textAndMnemonic=Lista
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Dettagli
+FileChooser.detailsViewButtonAccessibleName=Dettagli
+FileChooser.viewMenuButtonToolTipText = Visualizza menu
+FileChooser.viewMenuButtonAccessibleName = Visualizza menu
+FileChooser.detailsViewActionLabel.textAndMnemonic=Dettagli
+FileChooser.refreshActionLabel.textAndMnemonic=Aggiorna
+FileChooser.viewMenuLabel.textAndMnemonic=Visualizza
+FileChooser.fileNameHeader.textAndMnemonic=Nome
+FileChooser.fileSizeHeader.textAndMnemonic=Dimensioni
+FileChooser.fileTypeHeader.textAndMnemonic=Tipo
+FileChooser.fileDateHeader.textAndMnemonic=Modificato
+FileChooser.fileAttrHeader.textAndMnemonic=Attributi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_ja.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240(&I):
+FileChooser.saveInLabel.textAndMnemonic=\u4FDD\u5B58:
+FileChooser.fileNameLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u540D(&N):
+FileChooser.folderNameLabel.textAndMnemonic=\u30D5\u30A9\u30EB\u30C0\u540D(&N):
+FileChooser.filesOfTypeLabel.textAndMnemonic=\u30D5\u30A1\u30A4\u30EB\u306E\u30BF\u30A4\u30D7(&T):
+FileChooser.upFolderToolTip.textAndMnemonic=1\u30EC\u30D9\u30EB\u4E0A\u3078
+FileChooser.upFolderAccessibleName=\u4E0A\u3078
+FileChooser.homeFolderToolTip.textAndMnemonic=\u30DB\u30FC\u30E0
+FileChooser.homeFolderAccessibleName=\u30DB\u30FC\u30E0
+FileChooser.newFolderToolTip.textAndMnemonic=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0\u306E\u4F5C\u6210
+FileChooser.newFolderAccessibleName=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0
+FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0
+FileChooser.listViewButtonToolTip.textAndMnemonic=\u30EA\u30B9\u30C8
+FileChooser.listViewButtonAccessibleName=\u30EA\u30B9\u30C8
+FileChooser.listViewActionLabel.textAndMnemonic=\u30EA\u30B9\u30C8
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8A73\u7D30
+FileChooser.detailsViewButtonAccessibleName=\u8A73\u7D30
+FileChooser.viewMenuButtonToolTipText = \u8868\u793A\u30E1\u30CB\u30E5\u30FC
+FileChooser.viewMenuButtonAccessibleName = \u8868\u793A\u30E1\u30CB\u30E5\u30FC
+FileChooser.detailsViewActionLabel.textAndMnemonic=\u8A73\u7D30
+FileChooser.refreshActionLabel.textAndMnemonic=\u30EA\u30D5\u30EC\u30C3\u30B7\u30E5
+FileChooser.viewMenuLabel.textAndMnemonic=\u8868\u793A
+FileChooser.fileNameHeader.textAndMnemonic=\u540D\u524D
+FileChooser.fileSizeHeader.textAndMnemonic=\u30B5\u30A4\u30BA
+FileChooser.fileTypeHeader.textAndMnemonic=\u30BF\u30A4\u30D7
+FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6B63\u65E5
+FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=\uCC3E\uB294 \uC704\uCE58(&I):
+FileChooser.saveInLabel.textAndMnemonic=\uC800\uC7A5 \uC704\uCE58:
+FileChooser.fileNameLabel.textAndMnemonic=\uD30C\uC77C \uC774\uB984(&N):
+FileChooser.folderNameLabel.textAndMnemonic=\uD3F4\uB354 \uC774\uB984(&N):
+FileChooser.filesOfTypeLabel.textAndMnemonic=\uD30C\uC77C \uC720\uD615(&T):
+FileChooser.upFolderToolTip.textAndMnemonic=\uD55C \uB808\uBCA8 \uC704\uB85C
+FileChooser.upFolderAccessibleName=\uC704\uB85C
+FileChooser.homeFolderToolTip.textAndMnemonic=\uD648
+FileChooser.homeFolderAccessibleName=\uD648
+FileChooser.newFolderToolTip.textAndMnemonic=\uC0C8 \uD3F4\uB354 \uC0DD\uC131
+FileChooser.newFolderAccessibleName=\uC0C8 \uD3F4\uB354
+FileChooser.newFolderActionLabel.textAndMnemonic=\uC0C8 \uD3F4\uB354
+FileChooser.listViewButtonToolTip.textAndMnemonic=\uBAA9\uB85D
+FileChooser.listViewButtonAccessibleName=\uBAA9\uB85D
+FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
+FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
+FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274
+FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274
+FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
+FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
+FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
+FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
+FileChooser.fileTypeHeader.textAndMnemonic=\uC720\uD615
+FileChooser.fileDateHeader.textAndMnemonic=\uC218\uC815 \uB0A0\uC9DC
+FileChooser.fileAttrHeader.textAndMnemonic=\uC18D\uC131
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_pt_BR.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Pesquisar &em:
+FileChooser.saveInLabel.textAndMnemonic=Salvar em:
+FileChooser.fileNameLabel.textAndMnemonic=&Nome do arquivo:
+FileChooser.folderNameLabel.textAndMnemonic=&Nome da pasta:
+FileChooser.filesOfTypeLabel.textAndMnemonic=Arquivos do &tipo:
+FileChooser.upFolderToolTip.textAndMnemonic=Um N\u00EDvel Acima
+FileChooser.upFolderAccessibleName=Acima
+FileChooser.homeFolderToolTip.textAndMnemonic=In\u00EDcio
+FileChooser.homeFolderAccessibleName=In\u00EDcio
+FileChooser.newFolderToolTip.textAndMnemonic=Criar Nova Pasta
+FileChooser.newFolderAccessibleName=Nova Pasta
+FileChooser.newFolderActionLabel.textAndMnemonic=Nova Pasta
+FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
+FileChooser.listViewButtonAccessibleName=Lista
+FileChooser.listViewActionLabel.textAndMnemonic=Lista
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detalhes
+FileChooser.detailsViewButtonAccessibleName=Detalhes
+FileChooser.viewMenuButtonToolTipText = Exibir Menu
+FileChooser.viewMenuButtonAccessibleName = Exibir Menu
+FileChooser.detailsViewActionLabel.textAndMnemonic=Detalhes
+FileChooser.refreshActionLabel.textAndMnemonic=Atualizar
+FileChooser.viewMenuLabel.textAndMnemonic=Exibir
+FileChooser.fileNameHeader.textAndMnemonic=Nome
+FileChooser.fileSizeHeader.textAndMnemonic=Tamanho
+FileChooser.fileTypeHeader.textAndMnemonic=Tipo
+FileChooser.fileDateHeader.textAndMnemonic=Modificado
+FileChooser.fileAttrHeader.textAndMnemonic=Atributos
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_sv.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=Leta &i:
+FileChooser.saveInLabel.textAndMnemonic=Spara i:
+FileChooser.fileNameLabel.textAndMnemonic=Fil&namn:
+FileChooser.folderNameLabel.textAndMnemonic=Mapp&namn:
+FileChooser.filesOfTypeLabel.textAndMnemonic=Filer av &typen:
+FileChooser.upFolderToolTip.textAndMnemonic=Upp en niv\u00E5
+FileChooser.upFolderAccessibleName=Upp
+FileChooser.homeFolderToolTip.textAndMnemonic=Hem
+FileChooser.homeFolderAccessibleName=Hem
+FileChooser.newFolderToolTip.textAndMnemonic=Skapa ny mapp
+FileChooser.newFolderAccessibleName=Ny mapp
+FileChooser.newFolderActionLabel.textAndMnemonic=Ny mapp
+FileChooser.listViewButtonToolTip.textAndMnemonic=Lista
+FileChooser.listViewButtonAccessibleName=Lista
+FileChooser.listViewActionLabel.textAndMnemonic=Lista
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=Detaljer
+FileChooser.detailsViewButtonAccessibleName=Detaljer
+FileChooser.viewMenuButtonToolTipText = Menyn Visa
+FileChooser.viewMenuButtonAccessibleName = Menyn Visa
+FileChooser.detailsViewActionLabel.textAndMnemonic=Detaljer
+FileChooser.refreshActionLabel.textAndMnemonic=F\u00F6rnya
+FileChooser.viewMenuLabel.textAndMnemonic=Vy
+FileChooser.fileNameHeader.textAndMnemonic=Namn
+FileChooser.fileSizeHeader.textAndMnemonic=Storlek
+FileChooser.fileTypeHeader.textAndMnemonic=Typ
+FileChooser.fileDateHeader.textAndMnemonic=\u00C4ndrad
+FileChooser.fileAttrHeader.textAndMnemonic=Attribut
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_CN.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=\u67E5\u627E(&I):
+FileChooser.saveInLabel.textAndMnemonic=\u4FDD\u5B58:
+FileChooser.fileNameLabel.textAndMnemonic=\u6587\u4EF6\u540D(&N):
+FileChooser.folderNameLabel.textAndMnemonic=\u6587\u4EF6\u5939\u540D(&N):
+FileChooser.filesOfTypeLabel.textAndMnemonic=\u6587\u4EF6\u7C7B\u578B(&T):
+FileChooser.upFolderToolTip.textAndMnemonic=\u5411\u4E0A\u4E00\u7EA7
+FileChooser.upFolderAccessibleName=\u5411\u4E0A
+FileChooser.homeFolderToolTip.textAndMnemonic=\u4E3B\u76EE\u5F55
+FileChooser.homeFolderAccessibleName=\u4E3B\u76EE\u5F55
+FileChooser.newFolderToolTip.textAndMnemonic=\u521B\u5EFA\u65B0\u6587\u4EF6\u5939
+FileChooser.newFolderAccessibleName=\u65B0\u5EFA\u6587\u4EF6\u5939
+FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u5EFA\u6587\u4EF6\u5939
+FileChooser.listViewButtonToolTip.textAndMnemonic=\u5217\u8868
+FileChooser.listViewButtonAccessibleName=\u5217\u8868
+FileChooser.listViewActionLabel.textAndMnemonic=\u5217\u8868
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8BE6\u7EC6\u4FE1\u606F
+FileChooser.detailsViewButtonAccessibleName=\u8BE6\u7EC6\u4FE1\u606F
+FileChooser.viewMenuButtonToolTipText = \u67E5\u770B\u83DC\u5355
+FileChooser.viewMenuButtonAccessibleName = \u67E5\u770B\u83DC\u5355
+FileChooser.detailsViewActionLabel.textAndMnemonic=\u8BE6\u7EC6\u4FE1\u606F
+FileChooser.refreshActionLabel.textAndMnemonic=\u5237\u65B0
+FileChooser.viewMenuLabel.textAndMnemonic=\u89C6\u56FE
+FileChooser.fileNameHeader.textAndMnemonic=\u540D\u79F0
+FileChooser.fileSizeHeader.textAndMnemonic=\u5927\u5C0F
+FileChooser.fileTypeHeader.textAndMnemonic=\u7C7B\u578B
+FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F
+FileChooser.fileAttrHeader.textAndMnemonic=\u5C5E\u6027
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_TW.properties Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,47 @@
+# This properties file is used to create a PropertyResourceBundle
+# It contains Locale specific strings used be the Windows Look and Feel.
+# Currently, the following components need this for support:
+#
+# FileChooser
+#
+# When this file is read in, the strings are put into the
+# defaults table. This is an implementation detail of the current
+# workings of Swing. DO NOT DEPEND ON THIS.
+# This may change in future versions of Swing as we improve localization
+# support.
+#
+# Refer to the note in basic.properties for a description as to what
+# the mnemonics correspond to and how to calculate them.
+#
+# @author Steve Wilson
+
+
+############ FILE CHOOSER STRINGS #############
+
+FileChooser.lookInLabel.textAndMnemonic=\u67E5\u8A62(&I):
+FileChooser.saveInLabel.textAndMnemonic=\u5132\u5B58\u65BC:
+FileChooser.fileNameLabel.textAndMnemonic=\u6A94\u6848\u540D\u7A31(&N):
+FileChooser.folderNameLabel.textAndMnemonic=\u8CC7\u6599\u593E\u540D\u7A31(&N):
+FileChooser.filesOfTypeLabel.textAndMnemonic=\u6A94\u6848\u985E\u578B(&T):
+FileChooser.upFolderToolTip.textAndMnemonic=\u5F80\u4E0A\u4E00\u5C64
+FileChooser.upFolderAccessibleName=\u5F80\u4E0A
+FileChooser.homeFolderToolTip.textAndMnemonic=\u4E3B\u76EE\u9304
+FileChooser.homeFolderAccessibleName=\u4E3B\u76EE\u9304
+FileChooser.newFolderToolTip.textAndMnemonic=\u5EFA\u7ACB\u65B0\u8CC7\u6599\u593E
+FileChooser.newFolderAccessibleName=\u65B0\u8CC7\u6599\u593E
+FileChooser.newFolderActionLabel.textAndMnemonic=\u65B0\u8CC7\u6599\u593E
+FileChooser.listViewButtonToolTip.textAndMnemonic=\u6E05\u55AE
+FileChooser.listViewButtonAccessibleName=\u6E05\u55AE
+FileChooser.listViewActionLabel.textAndMnemonic=\u6E05\u55AE
+FileChooser.detailsViewButtonToolTip.textAndMnemonic=\u8A73\u7D30\u8CC7\u8A0A
+FileChooser.detailsViewButtonAccessibleName=\u8A73\u7D30\u8CC7\u8A0A
+FileChooser.viewMenuButtonToolTipText = \u6AA2\u8996\u529F\u80FD\u8868
+FileChooser.viewMenuButtonAccessibleName = \u6AA2\u8996\u529F\u80FD\u8868
+FileChooser.detailsViewActionLabel.textAndMnemonic=\u8A73\u7D30\u8CC7\u8A0A
+FileChooser.refreshActionLabel.textAndMnemonic=\u91CD\u65B0\u6574\u7406
+FileChooser.viewMenuLabel.textAndMnemonic=\u6AA2\u8996
+FileChooser.fileNameHeader.textAndMnemonic=\u540D\u7A31
+FileChooser.fileSizeHeader.textAndMnemonic=\u5927\u5C0F
+FileChooser.fileTypeHeader.textAndMnemonic=\u985E\u578B
+FileChooser.fileDateHeader.textAndMnemonic=\u4FEE\u6539\u65E5\u671F
+FileChooser.fileAttrHeader.textAndMnemonic=\u5C6C\u6027
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/module-info.java.extra Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+opens com.sun.java.swing.plaf.windows to jdk.jconsole;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/windows/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java Mon Dec 04 16:14:29 2017 -0800
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.swing.plaf.windows;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+import javax.swing.Icon;
+import javax.swing.UIManager;
+import javax.swing.plaf.UIResource;
+
+/**
+ * Classic sort icons.
+ *
+ */
+@SuppressWarnings("serial") // JDK-implementation class
+public class ClassicSortArrowIcon implements Icon, UIResource, Serializable{
+ private static final int X_OFFSET = 9;
+ private boolean ascending;
+
+ public ClassicSortArrowIcon(boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ x += X_OFFSET;
+ if (ascending) {
+ g.setColor(UIManager.getColor("Table.sortIconHighlight"));
+ drawSide(g, x + 3, y, -1);
+
+ g.setColor(UIManager.getColor("Table.sortIconLight"));
+ drawSide(g, x + 4, y, 1);
+
+ g.fillRect(x + 1, y + 6, 6, 1);
+ }
+ else {
+ g.setColor(UIManager.getColor("Table.sortIconHighlight"));
+ drawSide(g, x + 3, y + 6, -1);
+ g.fillRect(x + 1, y, 6, 1);
+
+ g.setColor(UIManager.getColor("Table.sortIconLight"));
+ drawSide(g, x + 4, y + 6, 1);
+ }
+ }
+
+ private void drawSide(Graphics g, int x, int y, int xIncrement) {
+ int yIncrement = 2;
+ if (ascending) {
+ g.fillRect(x, y, 1, 2);
+ y++;
+ }
+ else {
+ g.fillRect(x, --y, 1, 2);
+ yIncrement = -2;
+ y -= 2;
+ }
+ x += xIncrement;
+ for (int i = 0; i < 2; i++) {
+ g.fillRect(x, y, 1, 3);
+ x += xIncrement;
+ y += yIncrement;
+ }
+ if (!ascending) {
+ y++;
+ }
+ g.fillRect(x, y, 1, 2);
+ }
+
+ public int getIconWidth() {
+ return X_OFFSET + 8;
+ }
+ public int getIconHeight() {
+ return 9;
+ }
+}
--- a/test/jdk/com/sun/java/swing/plaf/windows/Test8173145.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/com/sun/java/swing/plaf/windows/Test8173145.java Mon Dec 04 16:14:29 2017 -0800
@@ -23,6 +23,7 @@
/* @test
@bug 8173145
+ @requires (os.family == "windows")
@summary Menu is activated after using mnemonic Alt/Key combination
@modules java.desktop/com.sun.java.swing.plaf.windows
@run main Test8173145
--- a/test/jdk/javax/swing/JButton/4796987/bug4796987.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JButton/4796987/bug4796987.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4796987
+ * @requires (os.family == "windows")
* @summary XP Only: JButton.setBorderPainted() does not work with XP L&F
* @author Alexander Scherbatiy
* @library ../../regtesthelpers
--- a/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
@test
@key headful
@bug 4199622
+ @requires (os.family == "windows")
@summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
@author Vladislav Karnaukhov
@library ../../../../lib/testlibrary
--- a/test/jdk/javax/swing/JComboBox/8015300/Test8015300.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JComboBox/8015300/Test8015300.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,7 @@
* @test
* @key headful
* @bug 8015300
+ @requires (os.family == "windows")
* @summary Tests that editable combobox selects all text.
* @author Sergey Malenkov
* @library ../../../../lib/testlibrary/
--- a/test/jdk/javax/swing/JFileChooser/4847375/bug4847375.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JFileChooser/4847375/bug4847375.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4847375 8171363
+ * @requires (os.family == "windows")
* @summary JFileChooser Create New Folder button is disabled incorrectly
* @author Pavel Porvatov
* @modules java.desktop/sun.awt
--- a/test/jdk/javax/swing/JFileChooser/8046391/bug8046391.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JFileChooser/8046391/bug8046391.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 8046391
+ * @requires (os.family == "windows")
* @summary JFileChooser hangs if displayed in Windows L&F
* @author Alexey Ivanov
* @library ../../../../lib/testlibrary
--- a/test/jdk/javax/swing/JInternalFrame/6725409/bug6725409.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JInternalFrame/6725409/bug6725409.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/* @test
* @key headful
* @bug 6725409
+ * @requires (os.family == "windows")
* @summary Checks that JInternalFrame's system menu
* can be localized during run-time
* @author Mikhail Lapshin
--- a/test/jdk/javax/swing/JProgressBar/7141573/bug7141573.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JProgressBar/7141573/bug7141573.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/* @test
@bug 7141573
+ @requires (os.family == "windows")
@summary JProgressBar resize exception, if setStringPainted in Windows LAF
@author Pavel Porvatov
*/
--- a/test/jdk/javax/swing/JSlider/6524424/bug6524424.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JSlider/6524424/bug6524424.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/* @test
* @bug 6524424
+ * @requires (os.family == "windows")
* @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings
* @author Pavel Porvatov
* @modules java.desktop/com.sun.java.swing.plaf.windows
--- a/test/jdk/javax/swing/JSlider/6579827/bug6579827.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JSlider/6579827/bug6579827.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/* @test
* @bug 6579827
+ * @requires (os.family == "windows")
* @summary vista : JSlider on JColorchooser is not properly render or can't be seen completely
* @author Pavel Porvatov
* @library ../../../../lib/testlibrary
--- a/test/jdk/javax/swing/JTree/8004298/bug8004298.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/JTree/8004298/bug8004298.java Mon Dec 04 16:14:29 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @key headful
* @bug 8004298
+ * @requires (os.family == "windows")
* @summary NPE in WindowsTreeUI.ensureRowsAreVisible
* @author Alexander Scherbatiy
* @library ../../regtesthelpers
--- a/test/jdk/javax/swing/border/Test4856008.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/border/Test4856008.java Mon Dec 04 16:14:29 2017 -0800
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4856008 7025987
+ * @requires (os.family == "windows")
* @summary Tests border insets
* @author Sergey Malenkov
* @modules java.desktop/com.sun.java.swing.plaf.motif
--- a/test/jdk/javax/swing/border/Test6978482.java Mon Dec 04 10:12:46 2017 -0800
+++ b/test/jdk/javax/swing/border/Test6978482.java Mon Dec 04 16:14:29 2017 -0800
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6978482 7025987
+ * @requires (os.family == "windows")
* @summary Tests unchecked casts
* @author Sergey Malenkov
* @modules java.desktop/com.sun.java.swing.plaf.motif