001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Substance Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance.scroll;
031:
032: import java.awt.Insets;
033:
034: import javax.swing.JButton;
035: import javax.swing.SwingConstants;
036: import javax.swing.plaf.UIResource;
037:
038: import org.jvnet.lafwidget.animation.FadeConfigurationManager;
039: import org.jvnet.lafwidget.animation.FadeKind;
040: import org.jvnet.substance.SubstanceLookAndFeel;
041: import org.jvnet.substance.utils.Sideable;
042: import org.jvnet.substance.utils.SubstanceConstants;
043:
044: /**
045: * Scroll bar button in <b>Substance</b> look and feel.
046: *
047: * @author Kirill Grouchnikov
048: */
049: public class SubstanceScrollButton extends JButton implements
050: UIResource, Sideable {
051: static {
052: FadeConfigurationManager.getInstance().disallowFades(
053: FadeKind.GHOSTING_BUTTON_PRESS,
054: SubstanceScrollButton.class);
055: FadeConfigurationManager.getInstance().disallowFades(
056: FadeKind.GHOSTING_ICON_ROLLOVER,
057: SubstanceScrollButton.class);
058: }
059: /**
060: * Button orientation.
061: */
062: private int orientation;
063:
064: /**
065: * Simple constructor.
066: *
067: * @param scrollBarIcon
068: * The icon.
069: * @param orientation
070: * The button icon arrow orientation.
071: */
072: public SubstanceScrollButton(int orientation) {
073: // super(0, 0, false);
074: super ();
075: // setModel(new DefaultButtonModel() {
076: // @Override
077: // public void setArmed(boolean armed) {
078: // super.setArmed(isPressed() || armed);
079: // }
080: // });
081: // this.setEnabled(scrollBar.isEnabled());
082: // this.setFocusable(false);
083: this .setRequestFocusEnabled(false);
084: this .setMargin(new Insets(0, 0, 0, 2));
085: this .orientation = orientation;
086: // scrollBarIcon);
087: this .putClientProperty(
088: SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS,
089: Boolean.FALSE);
090: }
091:
092: /*
093: * (non-Javadoc)
094: *
095: * @see java.awt.Component#isFocusable()
096: */
097: @Override
098: public boolean isFocusable() {
099: return false;
100: }
101:
102: /*
103: * (non-Javadoc)
104: *
105: * @see org.jvnet.substance.utils.Sideable#getSide()
106: */
107: public SubstanceConstants.Side getSide() {
108: switch (this.orientation) {
109: case SwingConstants.NORTH:
110: return SubstanceConstants.Side.BOTTOM;
111: case SwingConstants.WEST:
112: return SubstanceConstants.Side.RIGHT;
113: case SwingConstants.SOUTH:
114: return SubstanceConstants.Side.TOP;
115: case SwingConstants.EAST:
116: return SubstanceConstants.Side.LEFT;
117: default:
118: return null;
119: }
120: }
121: }
|