/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
/**
* BasicButton implementation
*
* @author Jeff Dinkins
*/
// Visual constants
// NOTE: This is not used or set any where. Were we allowed to remove
// fields, this would be removed.
protected int defaultTextIconGap;
// Amount to offset text, the value of this comes from
// defaultTextShiftOffset once setTextShiftOffset has been invoked.
// Value that is set in shiftOffset once setTextShiftOffset has been
// invoked. The value of this comes from the defaults table.
protected int defaultTextShiftOffset;
// ********************************
// Create PLAF
// ********************************
buttonUI = new BasicButtonUI();
}
return buttonUI;
}
return propertyPrefix;
}
// ********************************
// Install PLAF
// ********************************
}
// load shared instance defaults
// set the following defaults on the button
if (b.isContentAreaFilled()) {
} else {
}
}
}
}
}
}
}
}
// ********************************
// Uninstall PLAF
// ********************************
}
}
}
}
}
}
// ********************************
// Create Listeners
// ********************************
return new BasicButtonListener(b);
}
return defaultTextIconGap;
}
/* 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.
*/
// ********************************
// Paint Methods
// ********************************
{
AbstractButton b = (AbstractButton) c;
// perform UI specific press action, e.g. Windows L&F shifts text
paintButtonPressed(g,b);
}
// Paint the Icon
}
if (v != null) {
} else {
}
}
if (b.isFocusPainted() && b.hasFocus()) {
// paint UI specific focus
}
}
AbstractButton b = (AbstractButton) c;
return;
}
/* the fallback icon should be based on the selected state */
if (model.isSelected()) {
selectedIcon = b.getSelectedIcon();
if (selectedIcon != null) {
icon = selectedIcon;
}
}
if(model.isSelected()) {
tmpIcon = b.getDisabledSelectedIcon();
}
}
tmpIcon = b.getDisabledIcon();
}
tmpIcon = b.getPressedIcon();
// revert back to 0 offset
}
if(model.isSelected()) {
tmpIcon = b.getRolloverSelectedIcon();
}
}
tmpIcon = b.getRolloverIcon();
}
}
}
iconRect.y + getTextShiftOffset());
} else {
}
}
/**
* As of Java 2 platform v 1.4 this method should not be used or overriden.
* Use the paintText method which takes the AbstractButton argument.
*/
AbstractButton b = (AbstractButton) c;
int mnemonicIndex = b.getDisplayedMnemonicIndex();
/* Draw the Text */
/*** paint the text normally */
g.setColor(b.getForeground());
textRect.x + getTextShiftOffset(),
}
else {
/*** paint the text disabled ***/
}
}
/**
* Method which renders the text of the current button.
* <p>
* @param g Graphics context
* @param b Current button to render
* @param textRect Bounding rectangle to render the text.
* @param text String to render
* @since 1.4
*/
}
// Method signature defined here overriden in subclasses.
// Perhaps this class should be abstract?
}
}
protected void clearTextShiftOffset(){
this.shiftOffset = 0;
}
protected void setTextShiftOffset(){
this.shiftOffset = defaultTextShiftOffset;
}
protected int getTextShiftOffset() {
return shiftOffset;
}
// ********************************
// Layout Methods
// ********************************
Dimension d = getPreferredSize(c);
if (v != null) {
}
return d;
}
AbstractButton b = (AbstractButton)c;
}
Dimension d = getPreferredSize(c);
if (v != null) {
}
return d;
}
/**
* Returns the baseline.
*
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
AbstractButton b = (AbstractButton)c;
return -1;
}
}
/**
* Returns an enum indicating how the baseline of the component
* changes as the size changes.
*
* @throws NullPointerException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
JComponent c) {
super.getBaselineResizeBehavior(c);
}
switch(((AbstractButton)c).getVerticalAlignment()) {
case AbstractButton.TOP:
case AbstractButton.BOTTOM:
case AbstractButton.CENTER:
}
}
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b.getVerticalAlignment(), b.getHorizontalAlignment(),
}
/**
* Returns the ButtonListener for the passed in Button, or null if one
* could not be found.
*/
if (listener instanceof BasicButtonListener) {
return (BasicButtonListener) listener;
}
}
}
return null;
}
}