|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--com.equitysoft.components.IEButton
IEButton is a 'hot' button of the type found in Internet browsers such as Netscape
Navigator Version 4. When the cursor passes over the button it's border appears and the
image 'lights-up'. The button can have a text label or a tooltip but not both. If no
image is specified then the button is a text-only button. If 'setOpaque(true)
'
is not invoked then the button is 'transparent' and a background image will show through.
A button can be made 'sticky' which means the button will stayed depressed when pushed, until
it is pushed again. A sticky button can also be added to IEButton's 'group' which means
only one button in the group can be depressed at one time. Whether a button is sticky or not
it informs any registered actionListener
if it is pushed. By using
setRepeat
a button will continuously generate actionEvent
's while
the button is held down.
Any border thickness can be drawn and various label/image positions are supported. IEButton can be extended to change the way the border is drawn or how the image is grayed-out.
Field Summary | |
static int |
LABEL_EAST
The text position constant that places text as a label to the right of the button's image. |
static int |
LABEL_NORTH
The text position constant that places text as a label above the button's image or in the case of the tooltip position, above the button. |
static int |
LABEL_SOUTH
The text position constant that places text as a label underneath the button's image or in the case of the tooltip position, below the button. |
static int |
LABEL_WEST
The text position constant that places text as a label to the left of the button's image. |
static int |
TOOLTIP
The text position constant that designates that the button's text be used as a tooltip. |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
IEButton()
Constructs an instance of IEButton with no image , no text, with positioning of LABEL_SOUTH and a preferred size of 36 by 36. |
|
IEButton(java.awt.Image image)
Constructs an instance of IEButton with the specified image but without any associated text. |
|
IEButton(java.awt.Image image,
java.lang.String text)
Constructs an instance of IEButton with the given image and text and an implied text position of LABEL_SOUTH . |
|
IEButton(java.awt.Image image,
java.lang.String text,
int position)
Constructs an instance of IEButton with the specified image and textual label or tooltip. |
|
IEButton(java.lang.String text)
Constructs an instance which is text only. |
Method Summary | |
void |
addActionListener(java.awt.event.ActionListener target)
Causes the specified ActionListener's actionPerformed method to
be invoked each time the button is clicked. |
void |
addEnterExitListener(java.lang.Object target)
Causes the specified EnterExitListener's buttonStateChanged method to
be invoked each time the cursor enters or exits the button. |
void |
buttonStateChanged(EnterExitEvent eee)
Invoked by another instance of IEButton with which the current instance is registered as a EnterExitEvent listener. |
void |
fireAction()
Invoking this method is equivalent to clicking the mouse over the button. |
void |
fireEnterExit(boolean state)
This method is not normally invoked directly. |
java.lang.String |
getActionCommand()
Returns the value for the actionCommand String. |
java.awt.Image |
getAlternateImage(java.awt.Image original)
This method fetches the 'grayed-out' image for the button. |
int |
getBorderInset()
Returns the current border inset. |
int |
getBorderWidth()
Returns the current border width being used to draw the button. |
java.awt.Color |
getButtonBackground()
Returns the background color of the button. |
static IEButton |
getDepressedButton()
This method returns the currently depressed button instance if any. |
java.awt.Font |
getFont(java.awt.Font ft)
Returns the current font used to display the text associated with the button. |
java.lang.String |
getImageFile()
This method is invoked by JavaBean tools. |
java.awt.Dimension |
getMinimumSize()
Returns the same value as getPreferredSize() |
java.awt.Dimension |
getPreferredSize()
Returns The current preferred size dimension. |
long |
getRepeatInterval()
Gets the current value of the repeat interval. |
java.lang.String |
getText()
Returns the buttons text string. |
java.awt.Color |
getTextColor()
Returns the color with which the text is drawn. |
int |
getTextPosition()
Returns a value indicating how the text associated with the button is currently being displayed. |
java.awt.Color |
getTooltipBackground()
Returns the color used for the tooltip background. |
int |
getTooltipPosition()
Returns the current position of the tooltip if tooltips are being used for the button |
long |
getTooltipTimeDelay()
Returns The current delay before a tooltip is shown as a long value. |
void |
invalidate()
Overidden so that calls to Component.setBounds cause IEButton to recalculate positions |
boolean |
isDepressed()
Returns a boolean indicating if the button is depressed. |
boolean |
isDownDarkened()
Indicates if the image is darkened when the button is pushed. |
boolean |
isEnabled()
Indicates if the button is enabled or not. |
boolean |
isFocusTraversable()
Indicates to the AWT if the focus can be transferred to the button and also taken away. |
boolean |
isGrayOutInverted()
Indicates how the image is currently grayed. |
boolean |
isImageGrayOutEnabled()
Returns a boolean value indicating if graying out is enabled. |
boolean |
isInGroup()
Returns a value to indicate if the button is part of a group or not |
boolean |
isLitup()
Returns a boolean to indicate if permanent highlighting is on (a true value). |
boolean |
isOpaque()
Indicates if the button is to be drawn with an opaque background. |
boolean |
isOutlineDrawn()
Returns a boolean value indicating if an outline is to be drawn around the button. |
boolean |
isSlidingTooltip()
Indicates if the tooltip is set to slide. |
boolean |
isSticky()
Returns a boolean value indicating if toggling is enabled. |
void |
paint(java.awt.Graphics G)
Invoked by update , not usually invoked directly |
void |
paintBorder(java.awt.Graphics G,
int width,
int height,
boolean up,
java.awt.Color background,
int width_of_border,
boolean draw_outline,
java.awt.Color outline_color)
A method that paints the button border. |
void |
removeActionListener(java.awt.event.ActionListener target)
Remove this ActionListener from the buttons list of ActionListeners. |
void |
removeEnterExitListener(java.lang.Object target)
Remove this EnterExitListener from the buttons list of EnterExitListeners. |
void |
setActionCommand(java.lang.String command)
Sets the actionCommand of the ActionEvent delivered when the
button is pushed. |
void |
setBorderInset(int borderinset)
Sets the button's border inset in pixels. |
void |
setBorderWidth(int border_width)
Sets the width of the raised border around the button's edge |
void |
setButtonBackground(java.awt.Color background)
Sets the background color of the button. |
void |
setDepressed(boolean state)
Sets a sticky button to be depressed or to be released from a depressed state. |
void |
setDownDarkened(boolean darkened)
Decides if the image is to darkened or not when the button is pushed. |
void |
setEnabled(boolean enabled)
Invoked to enable or disable the button. |
void |
setFocusTraversable(boolean state)
Sets the value which is returned by isFocusTraversable() . |
void |
setFont(java.awt.Font font)
Sets the font of the text. |
void |
setGrayOutInverted(boolean inverted)
Changes the way the image is grayed-out. |
void |
setImage(java.awt.Image img)
Changes the image at runtime. |
void |
setImageFile(java.lang.String imgfile)
This method invoked by JavaBean manipulation tools to set the image. |
void |
setImageGrayOutEnabled(boolean grayed_out)
Enables or disables the graying out of the image on a button. |
void |
setInGroup(boolean state)
Designates a sticky button to be part of a single mutually exclusive group of IEButton instances that are all sticky. |
void |
setLitup(boolean on)
Turns on or off permanent highlighting. |
void |
setOpaque(boolean opaque)
Sets the button background to be opaque in which case the background is filled by a single color. |
void |
setOutlineDrawn(boolean outline)
Turns on or off the drawing of an outline around the button. |
void |
setPreferredSize(java.awt.Dimension dim)
Sets the preferred size of the button. |
void |
setRepeat(boolean repeat)
Causes the ActionEvent to be fired repeatedly if the button is held down. |
void |
setRepeatInterval(long interval)
Sets the repeat interval of ActionEvent firings when the button is held down
and willRepeat() returns a value of true. |
void |
setSlidingTooltip(boolean sliding)
Sets the way in which the tooltip appears if it is used. |
void |
setSticky(boolean sticky)
Turns on or off button toggling. |
void |
setText(java.lang.String text)
Sets the text used for the button's text label or tooltip depending on the boolean value in the constructor. |
void |
setTextColor(java.awt.Color col)
Sets the color with which the text is drawn. |
void |
setTextPosition(int position)
Sets the position of the text relative to the image. |
void |
setTooltipBackground(java.awt.Color col)
Sets the color used for the background of the tooltip. |
void |
setTooltipPosition(int position)
Sets the position of the tooltip. |
void |
setTooltipTimeDelay(long boxwait)
Sets the delay (in MilliSeconds) before a tooltip appears after the cursor is moved over the button. |
void |
update(java.awt.Graphics G)
Invoked by Component.repaint() - not usually invoked directly |
boolean |
willRepeat()
Indicates if the button will repeatedly fire the ActionEvent if the button
is held down. |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addNotify,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
contains,
contains,
createImage,
createImage,
deliverEvent,
disable,
dispatchEvent,
doLayout,
enable,
enable,
enableInputMethods,
getAlignmentX,
getAlignmentY,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentAt,
getComponentAt,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getMaximumSize,
getName,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isLightweight,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
layout,
list,
list,
list,
list,
list,
locate,
location,
lostFocus,
minimumSize,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
postEvent,
preferredSize,
prepareImage,
prepareImage,
print,
printAll,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removeNotify,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus,
validate |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int TOOLTIP
public static final int LABEL_SOUTH
public static final int LABEL_EAST
public static final int LABEL_NORTH
public static final int LABEL_WEST
Constructor Detail |
public IEButton()
public IEButton(java.lang.String text)
text
- A String which is the label of the button.public IEButton(java.awt.Image image)
setText()
. The preferred size of the button will be the image dimension plus
the default border inset (the default inset is 8 pixels).image
- The image to be displayed on the button.public IEButton(java.awt.Image image, java.lang.String text)
LABEL_SOUTH
.image
- The Image to be displayed in the button above the text.text
- The String to be displayed below the image.public IEButton(java.awt.Image image, java.lang.String text, int position)
tooltip
specifies if the text is to be used as a tooltip or used
as a label in the button.image
- The Image to be displayed in the button. If null no image is displayed and the
button is treated as a text-only button.text
- The String for the tooltip or label text of the button.
If null
then no text will be displayed.toolip
- A boolean value indicating if the button has a tooltip or text label.
true
if the button has a text tooltip, false
if the button has a text label.
The tooltip is a box of text that appears if the cursor remains over the
button for a preset period of time. The text label is text that appears
below the image. It is not possible to have both in the same button.Method Detail |
public void buttonStateChanged(EnterExitEvent eee)
public java.awt.Image getAlternateImage(java.awt.Image original)
original
- The original image which is displayed when the cursor is over the buttonsetGrayOutInverted(boolean)
public void setGrayOutInverted(boolean inverted)
inverted
- A boolean value to indicate how the image should be grayed out.
A true
value indicates that an inversion filter should be used
to produce the grayed-out image.isGrayOutInverted()
public boolean isGrayOutInverted()
true
indicates an inversion filter is being used.setGrayOutInverted(boolean)
public void setDownDarkened(boolean darkened)
darkened
- A boolean value to indicate if the image is darkened on pushing the button.
A true
value indicates that the image should be darkened.isDownDarkened()
public boolean isDownDarkened()
true
indicates that the image is darkened.setDownDarkened(boolean)
public void addEnterExitListener(java.lang.Object target)
buttonStateChanged
method to
be invoked each time the cursor enters or exits the button. The EnterExitListener
object is added to a list of EnterExitListeners managed by
this button, it can be removed with removeEnterExitListener.
target
- The EnterExitListener
to be added.removeEnterExitListener(java.lang.Object)
public void removeEnterExitListener(java.lang.Object target)
target
- The EnterExitListener to be removed.addEnterExitListener(java.lang.Object)
public void fireEnterExit(boolean state)
buttonStateChanged
methods
of all registered EnterExitListeners are invoked.state
- true
indicates the cursor has entered the button. false
indicates that the cursor has exited the button.addActionListener(java.awt.event.ActionListener)
public void setImageFile(java.lang.String imgfile)
public java.lang.String getImageFile()
public void setImage(java.awt.Image img)
img
- The Image
which is to be the new button imagepublic void setTooltipPosition(int position)
LABEL_NORTH
or LABEL_SOUTH
.
The default is LABEL_SOUTH
.position
- An int
value to indicate the tooltip positiongetTooltipPosition()
public int getTooltipPosition()
setTooltipPosition(int)
public void setSlidingTooltip(boolean sliding)
true
the tooltip will
slide into view rather than just appearing. This results in a slicker GUI depending on your
point of view. The default is for sliding to be turned off (ie. false
).enabled
- A boolean value to indicate if the tooltip is to slideisSlidingTooltip()
public boolean isSlidingTooltip()
true
if the tooltip slides into view.setSlidingTooltip(boolean)
public void setEnabled(boolean enabled)
enabled
- A boolean value to indicate if the button is to be enabledisEnabled()
public boolean isEnabled()
true
if the button is enabled.setEnabled(boolean)
public void invalidate()
Component.setBounds
cause IEButton to recalculate positionspublic void update(java.awt.Graphics G)
Component.repaint()
- not usually invoked directlypublic void paint(java.awt.Graphics G)
update
, not usually invoked directlypublic void paintBorder(java.awt.Graphics G, int width, int height, boolean up, java.awt.Color background, int width_of_border, boolean draw_outline, java.awt.Color outline_color)
G
- The GraphicsContext used to paint the border.width
- The width of the button in which the border can be painted.height
- The height of the button in which the border can be painted.up
- A boolean value that is true
if the button is up.background
- The Color that should be lightened or darkened to achieve an up/down effect.width_of_border
- An int value indicating the pixel width of the border.draw_outline
- A boolean value indicating if the outline should be drawn.outline_color
- A Color instance to be used for drawing the outline.public void setTextPosition(int position)
TOOLTIP, LABEL_SOUTH, LABEL_EAST, LABEL_NORTH, LABEL_WEST
.position
- An int
value indicating how the text associated with this button
is to be used.getTextPosition()
public int getTextPosition()
TOOLTIP, LABEL_SOUTH, LABEL_EAST, LABEL_NORTH,
LABEL_WEST
.setTextPosition(int)
,
IEButton(Image,String,int)
public void setOutlineDrawn(boolean outline)
outline
- A boolean value of true
indicates that an outline should be drawn
around the button.isOutlineDrawn()
public boolean isOutlineDrawn()
true
if an outline is to be drawn around the button.setOutlineDrawn(boolean)
public void setSticky(boolean sticky)
sticky
- A boolean value of true indicates that toggling should be enabledisSticky()
public boolean isSticky()
true
if toggling is enabled.setSticky(boolean)
public void setInGroup(boolean state)
true
then only one button of the
group of sticky buttons can be depressed at one time. If a button in the group is pushed
only the pushed button's ActionEvent
is fired. If the button is not sticky then
it is automatically made sticky when added to the group.
There can only be one unnamed group in an
application. Programmers needing more than one group should use Sun's JFC classes.state
- A boolean value oftrue
designates the button of part of the group.isInGroup()
public boolean isInGroup()
true
indicates the button is in the group.public void setImageGrayOutEnabled(boolean grayed_out)
grayedout
- A boolean value of false indicates the image should not be grayed out when
the cursor is not over the button. setEnabled(false)
will still gray out the
image though.isImageGrayOutEnabled()
public boolean isImageGrayOutEnabled()
true
if the graying out of images occurs even if the cursor is not
over the button.setImageGrayOutEnabled(boolean)
public void setLitup(boolean on)
on
- A boolean value to indicate if highlighting should be permanently on.isLitup()
public boolean isLitup()
true
value).true
indicates that the button will always be highlighted.setLitup(boolean)
public void setFont(java.awt.Font font)
font
- The font in which the text is to appear.getFont(java.awt.Font)
public java.awt.Font getFont(java.awt.Font ft)
setFont(java.awt.Font)
public void setBorderInset(int borderinset)
borderinset
- The new value of the border inset.public int getBorderInset()
setBorderInset(int)
public void setBorderWidth(int border_width)
border_width
- An int value indicating the border width to be used.getBorderWidth()
public int getBorderWidth()
setBorderWidth(int)
public void setPreferredSize(java.awt.Dimension dim)
dim
- The font in which the text is to appear.getPreferredSize()
public java.awt.Dimension getPreferredSize()
setPreferredSize(java.awt.Dimension)
public java.awt.Dimension getMinimumSize()
getPreferredSize()
public void setText(java.lang.String text)
null
then the text is set to the
be an empty String.String
- The text of the label or tooltip.getText()
public java.lang.String getText()
null
.setText(java.lang.String)
public void setTextColor(java.awt.Color col)
Color
- The color with which the text is drawn.getTextColor()
public java.awt.Color getTextColor()
setTextColor(java.awt.Color)
public void setOpaque(boolean opaque)
setButtonBackgroundColor
then
the color used will be background color of the button's container. By default IEButton
instances are transparent and not opaque.opaque
- A boolean value where true
means the background is to be filled.isOpaque()
,
setButtonBackground(java.awt.Color)
public boolean isOpaque()
true
indicates that the background is opaque.true
indicates that the button is opaque.setOpaque(boolean)
,
setButtonBackground(java.awt.Color)
public void setButtonBackground(java.awt.Color background)
setOpaque(true)
background
- The color with which the backgroound is drawn.getButtonBackground()
,
setOpaque(boolean)
public java.awt.Color getButtonBackground()
setButtonBackground(java.awt.Color)
public void setTooltipBackground(java.awt.Color col)
Color
- The color which will be used for the tooltip background.getTooltipBackground()
public java.awt.Color getTooltipBackground()
setTooltipBackground(java.awt.Color)
public void setDepressed(boolean state)
ActionEvent
.
Only used if the method isSticky()
returns a value of true
.state
- A boolean value of true
sets the button to be depressed.isDepressed()
public boolean isDepressed()
true
indicates the button is currently depressed.setDepressed(boolean)
public static IEButton getDepressedButton()
setSticky(true)
.null
is no
button is in the depressed state.public void setTooltipTimeDelay(long boxwait)
long
- The delay is MilliSeconds before the tooltip appears.getTooltipTimeDelay()
public long getTooltipTimeDelay()
long
value.setTooltipTimeDelay(long)
public void setActionCommand(java.lang.String command)
actionCommand
of the ActionEvent
delivered when the
button is pushed. If never set then the value is the text associated with the button. This
mimics the behaviour of the java.awt.Button
component. The mouse button must be
released over the button for an event to be sent to registered listeners.command
- A String which is to be delivered with the ActionEvent
.getActionCommand()
public java.lang.String getActionCommand()
actionCommand
String. If never explicitly set the
this method returns the value of the text associated with the button.actionCommand
fired by this button.setActionCommand(java.lang.String)
public void addActionListener(java.awt.event.ActionListener target)
actionPerformed
method to
be invoked each time the button is clicked. The ActionListener
object is added to a list of ActionListeners managed by
this button, it can be removed with removeActionListener.
Note: ActionListeners will not be notified in any particular order.target
- The ActionListener
to be added.removeActionListener(java.awt.event.ActionListener)
public void removeActionListener(java.awt.event.ActionListener target)
target
- The ActionListener to be removed.addActionListener(java.awt.event.ActionListener)
public boolean isFocusTraversable()
false
. The method setFocusTraversable
should be invoked to set the value to true
.setFocusTraversable(boolean)
public void setFocusTraversable(boolean state)
isFocusTraversable()
. The default is
false
. If set to true
then the focus can be transferred by the
appropriate key sequence (the 'tab' key on Win95). Consecutive transfers moves the focus from
component to component and when IEButton gets the focus the button becomes highlighted.
When highlighted in this way a subsequent pressing of the 'enter' key will cause the buttons
ActionEvent
to be fired.state
- A boolean value to indicate if the focus is to be traversable or not across this
button.isFocusTraversable()
public void setRepeat(boolean repeat)
ActionEvent
to be fired repeatedly if the button is held down.
If this method is not invoked then the default state is that repeat firing won't be
enabled.repeat
- A boolean value of true
indicates that repeat firing occurs
if the button is held down.willRepeat()
public boolean willRepeat()
ActionEvent
if the button
is held down.true
indicates the button will repeatedly fire the
ActionEvent
.setRepeat(boolean)
public void setRepeatInterval(long interval)
ActionEvent
firings when the button is held down
and willRepeat()
returns a value of true.interval
- A long value which is the repeat interval in milliseconds. The default value
is 60 milliseconds.getRepeatInterval()
public long getRepeatInterval()
setRepeatInterval(long)
public void fireAction()
actionPeformed
methods of all registered
ActionListeners are invoked.addActionListener(java.awt.event.ActionListener)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |