ImageButton.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) ImageButton.java 1.16 - last change made 07/23/97
*/
/**
* An image button (a 3D rect around an image.) It greys itself out
* when disabled and inverts the 3D rect and
* moves its image when depressed.
*
* @(#) @(#) ImageButton.java 1.16 - last change made 07/23/97
*/
public class ImageButton extends ImageLabel {
// when button pressed
protected boolean depressed;
}
super(img, w, h);
depressed = false;
}
public void setPadWidth(int w) {
super.setPadWidth(w + lineWidth);
}
public int getPadWidth() {
return (super.getPadWidth() - lineWidth);
}
public void setLineWidth(int w) {
int oldPadWidth = getPadWidth();
lineWidth = w;
}
public int getLineWidth() {
return (lineWidth);
}
public void setPressMovement(int p) {
if (p != pressMovement) {
pressMovement = p;
if (depressed) {
Graphics g = getGraphics();
if (g != null) {
g.setColor(getBackground());
repaint();
}
}
}
}
public int getPressMovement() {
return (pressMovement);
}
/**
* Paint the image button with a 3D border
*/
synchronized (DesignerAccess.mutex) {
if (pressMovement != 0) {
// clear the area needed to accomodate press movement
for (int i = 0; i < pressMovement * m; i++)
y + i * m + (m < 0 ? -1 : 0),
}
// draw the image and the 3D border
// Bug workaround: If a SystemColor
// is used as the background color
// then Win32 JDK code loses the reference
// and the bg of a
// transparent gif will be black.
if (bg instanceof SystemColor)
}
for (int i = 0; i < lineWidth; i++) {
g.draw3DRect(i, i,
!depressed);
}
}
}
}
depressed = true;
repaint();
return true;
}
repaint();
}
return true;
}
if (depressed) {
action();
depressed = false;
repaint();
}
return true;
}
public void action() {
}
}