< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java

Print this page

        

*** 33,42 **** --- 33,44 ---- 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 static java.lang.Boolean.FALSE; + import static java.lang.Boolean.TRUE; import sun.awt.AppContext; /** * Windows button.
*** 159,182 **** --- 161,215 ---- * 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) { + AbstractButton b = (AbstractButton)c; + + if(isStateChangeAnimated(b)) { + boolean rollover = b.getModel().isRollover(); + AnimationController anim = AnimationController.getAnimationController(); + boolean wasRollover = b.getClientProperty("WindowsButtonUI.wasRollover") == TRUE; + + if(rollover != wasRollover) { + State currentState = wasRollover?State.HOT:State.NORMAL; + State targetState = rollover?State.HOT:State.NORMAL; + anim.startAnimation(c, getXPButtonType(b), currentState, targetState, 250); + } + + b.putClientProperty("WindowsButtonUI.animateToNullState", !rollover); + b.putClientProperty("WindowsButtonUI.wasRollover", rollover); + } + if (XPStyle.getXP() != null) { WindowsButtonUI.paintXPButtonBackground(g, c); } super.paint(g, c); } + private static boolean isStateChangeAnimated(AbstractButton button) { + final String propName = "WindowsButtonUI.animateStateChange"; + + if(button.getParent() instanceof JToolBar) { + JToolBar toolBar = (JToolBar)button.getParent(); + if(toolBar.getClientProperty(propName)==TRUE) + return true; + } + + return button.getClientProperty(propName)==TRUE; + } + 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); + if(b.getClientProperty("WindowsButtonUI.displayAsInToolbar") == TRUE) + toolbar = true; return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON; } static State getXPButtonState(AbstractButton b) { Part part = getXPButtonType(b);
*** 276,286 **** 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 --- 309,323 ---- dx += insets.left; dy += insets.top; dw -= (insets.left + insets.right); dh -= (insets.top + insets.bottom); } ! ! if(c.getClientProperty("WindowsButtonUI.animateToNullState") == TRUE) ! state = null; ! ! AnimationController.paintSkin(c, skin, g, dx, dy, dw, dh, state); } } /** * returns - b.getBorderInsets(c) if border is opaque
< prev index next >