All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.RollOverButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----symantec.itools.awt.RollOverButton

public class RollOverButton
extends Canvas
implements TransparencyTrick
This is a button that allows three different states and displays the document with a given URL when clicked. Each button state has its own associated image. Each image is specified by providing the file name or the URL of the file containing the image. The document to show is specified by providing the "LinkURL" of that document.

The "standard" state is when the mouse is not over the button. If the standard image is null, the button will be transparent when in the standard state, otherwise the specified image will be displayed.

The "over" state is when the mouse cursor is over the button. This state also displays the LinkURL if it is not null.

The "down" state is when the mouse button is pressed inside the button. When there is a MOUSE_UP in the button, it will attempt to show the document at the LinkURL unless it is null. This state also displays the LinkURL if it is not null.


Variable Index

 o context
The applet context that shows the document.
 o DownFileName
The file name of the image to display while the mouse is over the button and pressed.
 o DownImage
The image displayed while the mouse is pressed down inside the button.
 o DownURL
The URL of the image to use while the mouse is over the button and pressed.
 o frame
The frame specifier for showing a URL document in a browser or applet viewer.
 o isCenterMode
If true the image will be centered within the bounds of the button.
 o isClearFrame
If true the frame is cleared in between drawing different button states.
 o isMouseDrag
True if the mouse is being dragged in the button.
 o isMouseOver
True if the mouse is over the button.
 o isPressed
True if the mouse button is being pressed.
 o LinkURL
The URL of the document to show after the button has been pressed.
 o OverFileName
The file name of the image to display while the mouse is over the button.
 o OverImage
The image displayed while the mouse is over the button.
 o OverURL
The URL of the image to use while the mouse is over the button.
 o StandardFileName
The file name of the image to display while the mouse is not over the button.
 o StandardImage
The image displayed while the mouse is not over the button.
 o StandardURL
The URL of the image to use in while the mouse is not over the button.

Constructor Index

 o RollOverButton()
Constructs a default RollOverButton.
 o RollOverButton(Image, Image, Image)
Constructs a RollOverButton with an image given for each button state.
 o RollOverButton(String, String, String)
Constructs a RollOverButton with an image file name given for each button state.
 o RollOverButton(URL, URL, URL)
Constructs a RollOverButton with an image file URL given for each button state.

Method Index

 o getCenterMode()
Gets the flag that determines whether to center the image within the bounds of the button.
 o getClearFrame()
Gets the flag that determines if the background should be erased before the button is drawn.
 o getDownFileName()
Gets the file name of the image to display while the button is being pressed.
 o getDownImage()
Gets the image displayed while the button is being pressed.
 o getDownURL()
Gets the URL of the image to display while the button is being pressed.
 o getFrame()
Gets the frame specifier for showing a URL document in a browser or applet viewer.
 o getOverFileName()
Gets the file name of the image to display while the mouse is over the button.
 o getOverImage()
Gets the image displayed while the mouse is over the button.
 o getOverURL()
Gets the URL of the image to display while the mouse is over the button.
 o getStandardFileName()
Gets the file name of the image to display while the mouse is not over the button.
 o getStandardImage()
Gets the image displayed while the mouse is not over the button.
 o getStandardURL()
Gets the URL of the image to display while the mouse is not over the button.
 o getURL()
Gets the URL of the document to display on mouse up.
 o mouseDown(Event, int, int)
Processes MOUSE_DOWN events.
 o mouseDrag(Event, int, int)
Processes MOUSE_DRAG events.
 o mouseEnter(Event, int, int)
Processes MOUSE_ENTER events.
 o mouseExit(Event, int, int)
Processes MOUSE_EXIT events.
 o mouseMove(Event, int, int)
Processes MOUSE_MOVE events.
 o mouseUp(Event, int, int)
Processes MOUSE_UP events.
 o paint(Graphics)
Paints this component using the given graphics context.
 o preferredSize()
Returns the recommended dimensions to properly display this component.
 o setAppletContext(AppletContext)
Sets the applet context used to view documents.
 o setCenterMode(boolean)
Sets the flag to center the image within the bounds of the button.
 o setClearFrame(boolean)
Sets the flag to erase the background before drawing the button.
 o setDownFileName(String)
Sets the file name of the image to display while the button is being pressed.
 o setDownImage(Image)
Sets the image to display while the button is being pressed.
 o setDownURL(URL)
Sets the URL of the image to display while the button is being pressed.
 o setFileNameHelper(String)
A function used to consolidate shared code between the three file name setting methods.
 o setFrame(String)
Sets the frame specifier for showing a URL document in a browser or applet viewer.
 o setImageHelper(Image)
A function used to consolidate shared code between the three image setting functions.
 o setOverFileName(String)
Sets the file name of the image to display while the mouse is over the button.
 o setOverImage(Image)
Sets the image to display while the mouse is over the button.
 o setOverURL(URL)
Sets the URL of the image to display while the mouse is over the button.
 o setStandardFileName(String)
Sets the file name of the image to display while the mouse is not over the button.
 o setStandardImage(Image)
Sets the image to display while the mouse is not over the button.
 o setStandardURL(URL)
Sets the URL of the image to display while the mouse is not over the button.
 o setURL(URL)
Sets the URL of the document to display on mouse up.
 o update(Graphics)
Handles redrawing of this component on the screen.
 o validate()
Ensures that this component is laid out properly, as needed.

Variables

 o StandardImage
  protected Image StandardImage
The image displayed while the mouse is not over the button. If this is null, the button will be invisible in this state.

 o OverImage
  protected Image OverImage
The image displayed while the mouse is over the button. If this is null, the StandardImage will be used. If that is null, the button will be invisible in this state.

 o DownImage
  protected Image DownImage
The image displayed while the mouse is pressed down inside the button. If this is null, no drawing takes place.

 o StandardFileName
  protected String StandardFileName
The file name of the image to display while the mouse is not over the button.

 o OverFileName
  protected String OverFileName
The file name of the image to display while the mouse is over the button.

 o DownFileName
  protected String DownFileName
The file name of the image to display while the mouse is over the button and pressed.

 o frame
  protected String frame
The frame specifier for showing a URL document in a browser or applet viewer. It is interpreted as follows:

 o StandardURL
  protected URL StandardURL
The URL of the image to use in while the mouse is not over the button.

 o OverURL
  protected URL OverURL
The URL of the image to use while the mouse is over the button.

 o DownURL
  protected URL DownURL
The URL of the image to use while the mouse is over the button and pressed.

 o LinkURL
  protected URL LinkURL
The URL of the document to show after the button has been pressed.

 o isCenterMode
  protected boolean isCenterMode
If true the image will be centered within the bounds of the button. If false the image is drawn at 0,0 relative to the bounds of the button.

 o isMouseOver
  protected boolean isMouseOver
True if the mouse is over the button.

 o isClearFrame
  protected boolean isClearFrame
If true the frame is cleared in between drawing different button states.

 o isPressed
  protected boolean isPressed
True if the mouse button is being pressed.

 o isMouseDrag
  protected boolean isMouseDrag
True if the mouse is being dragged in the button.

 o context
  protected AppletContext context
The applet context that shows the document.

Constructors

 o RollOverButton
  public RollOverButton()
Constructs a default RollOverButton. It has no associated images nor a LinkURL.

 o RollOverButton
  public RollOverButton(String Standard,
                        String Over,
                        String Down) throws MalformedURLException
Constructs a RollOverButton with an image file name given for each button state.

Parameters:
Standard - the file name of the image to use while the mouse is not over the button
Over - the file name of the image to use while the mouse is over the button
Down - the file name of the image to use while the mouse is over the button and pressed
 o RollOverButton
  public RollOverButton(URL Standard,
                        URL Over,
                        URL Down)
Constructs a RollOverButton with an image file URL given for each button state.

Parameters:
Standard - the URL of the image to use while the mouse is not over the button
Over - the URL of the image to use while the mouse is over the button
Down - the URL of the image to use while the mouse is over the button and pressed
 o RollOverButton
  public RollOverButton(Image Standard,
                        Image Over,
                        Image Down)
Constructs a RollOverButton with an image given for each button state.

Parameters:
Standard - the image to use while the mouse is not over the button
Over - the image to use while the mouse is over the button
Down - the image to use while the mouse is over the button and pressed

Methods

 o setStandardFileName
  public void setStandardFileName(String str) throws MalformedURLException
Sets the file name of the image to display while the mouse is not over the button.

Parameters:
str - the image file name
See Also:
getStandardFileName
 o getStandardFileName
  public String getStandardFileName()
Gets the file name of the image to display while the mouse is not over the button.

Returns:
the image file name
See Also:
setStandardFileName
 o setOverFileName
  public void setOverFileName(String str) throws MalformedURLException
Sets the file name of the image to display while the mouse is over the button.

Parameters:
str - the image file name
See Also:
getOverFileName
 o getOverFileName
  public String getOverFileName()
Gets the file name of the image to display while the mouse is over the button.

Returns:
the image file name
See Also:
setOverFileName
 o setDownFileName
  public void setDownFileName(String str) throws MalformedURLException
Sets the file name of the image to display while the button is being pressed.

Parameters:
str - the image file name
See Also:
getDownFileName
 o getDownFileName
  public String getDownFileName()
Gets the file name of the image to display while the button is being pressed.

Returns:
the image file name
See Also:
setDownFileName
 o setFileNameHelper
  protected void setFileNameHelper(String str) throws MalformedURLException
A function used to consolidate shared code between the three file name setting methods. Do not call directly.

Parameters:
str - the image file name to set
 o setStandardURL
  public void setStandardURL(URL aUrl)
Sets the URL of the image to display while the mouse is not over the button.

Parameters:
aURL - the image URL
See Also:
getStandardURL
 o getStandardURL
  public URL getStandardURL()
Gets the URL of the image to display while the mouse is not over the button.

Returns:
the image URL
See Also:
setStandardURL
 o setOverURL
  public void setOverURL(URL aUrl)
Sets the URL of the image to display while the mouse is over the button.

Parameters:
aURL - the image URL
See Also:
getOverURL
 o getOverURL
  public URL getOverURL()
Gets the URL of the image to display while the mouse is over the button.

Returns:
the image URL
See Also:
setOverURL
 o setDownURL
  public void setDownURL(URL aUrl)
Sets the URL of the image to display while the button is being pressed.

Parameters:
aURL - the image URL
See Also:
getDownURL
 o getDownURL
  public URL getDownURL()
Gets the URL of the image to display while the button is being pressed.

Returns:
the image URL
See Also:
setDownURL
 o setStandardImage
  public void setStandardImage(Image img)
Sets the image to display while the mouse is not over the button.

Parameters:
img - the image
See Also:
getStandardImage
 o getStandardImage
  public Image getStandardImage()
Gets the image displayed while the mouse is not over the button.

Returns:
the image
See Also:
setStandardImage
 o setOverImage
  public void setOverImage(Image img)
Sets the image to display while the mouse is over the button.

Parameters:
img - the image
See Also:
getOverImage
 o getOverImage
  public Image getOverImage()
Gets the image displayed while the mouse is over the button.

Returns:
the image
See Also:
setOverImage
 o setDownImage
  public void setDownImage(Image img)
Sets the image to display while the button is being pressed.

Parameters:
img - the image
See Also:
getDownImage
 o getDownImage
  public Image getDownImage()
Gets the image displayed while the button is being pressed.

Returns:
the image
See Also:
setDownImage
 o setImageHelper
  protected void setImageHelper(Image img)
A function used to consolidate shared code between the three image setting functions. Do not call directly.

Parameters:
img - the image to set
 o setClearFrame
  public void setClearFrame(boolean b)
Sets the flag to erase the background before drawing the button. Not erasing the background often results in a faster, more flicker-free update.

Parameters:
b - if true clear the background before painting, if false then don't
See Also:
getClearFrame
 o getClearFrame
  public boolean getClearFrame()
Gets the flag that determines if the background should be erased before the button is drawn.

Returns:
true if the background will be cleared before painting the button, false if it will not be cleared
See Also:
setClearFrame
 o setURL
  public void setURL(URL u)
Sets the URL of the document to display on mouse up.

Parameters:
u - the URL of the document to display
See Also:
getURL
 o getURL
  public URL getURL()
Gets the URL of the document to display on mouse up.

Returns:
the URL of the document to display
See Also:
setURL
 o setFrame
  public void setFrame(String f)
Sets the frame specifier for showing a URL document in a browser or applet viewer. It is interpreted as follows:

Parameters:
f - the new frame specifier
See Also:
getFrame, frame
 o getFrame
  public String getFrame()
Gets the frame specifier for showing a URL document in a browser or applet viewer. It is interpreted as follows:

Returns:
the current frame specifier
See Also:
setFrame, frame
 o setCenterMode
  public void setCenterMode(boolean flag)
Sets the flag to center the image within the bounds of the button.

Parameters:
b - true to center the image within the button, false to draw the image at 0,0 relative to the button
See Also:
getCenterMode
 o getCenterMode
  public boolean getCenterMode()
Gets the flag that determines whether to center the image within the bounds of the button.

Returns:
true if the image will be centered within the button, false if the image will be drawn at 0,0 relative to the button.
See Also:
setCenterMode
 o setAppletContext
  protected void setAppletContext(AppletContext c)
Sets the applet context used to view documents.

Parameters:
c - the new applet context
 o paint
  public void paint(Graphics g)
Paints this component using the given graphics context. This is a standard Java AWT method which typically gets called by the AWT to handle painting this component. It paints this component using the given graphics context. The graphics context clipping region is set to the bounding rectangle of this component and its <0,0> coordinate is this component's top-left corner.

Parameters:
g - the graphics context used for painting
Overrides:
paint in class Canvas
See Also:
repaint, update
 o mouseEnter
  public boolean mouseEnter(Event e,
                            int x,
                            int y)
Processes MOUSE_ENTER events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_ENTER event. These events occur when the mouse first moves over this component. It keeps track of the mouse position relative to the button, and displays the URL link.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseEnter in class Component
See Also:
mouseExit, handleEvent
 o mouseExit
  public boolean mouseExit(Event e,
                           int x,
                           int y)
Processes MOUSE_EXIT events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_EXIT event. These events occur when the mouse first leaves this component. It keeps track of the mouse position relative to the button, and erases the URL link.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseExit in class Component
See Also:
mouseEnter, handleEvent
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
Processes MOUSE_DOWN events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_DOWN event. These events occur when the mouse button is pressed while inside this component. It handles the mouse down event by setting the boolean isPressed.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseDown in class Component
See Also:
mouseUp, handleEvent
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
Processes MOUSE_UP events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_UP event. These events occur when the mouse button is released while inside this component. It handles the mouse up event by linking to the LinkURL if it is not null, sets the isPressed boolean, and posts an Action Event.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseUp in class Component
See Also:
mouseDown, handleEvent
 o mouseDrag
  public boolean mouseDrag(Event e,
                           int x,
                           int y)
Processes MOUSE_DRAG events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_DRAG event. These events occur when the mouse is moved around inside this component while the button is pressed. It keeps track of the state of the mouse button while the mouse position is in the button.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseDrag in class Component
See Also:
mouseMove, handleEvent
 o mouseMove
  public boolean mouseMove(Event e,
                           int x,
                           int y)
Processes MOUSE_MOVE events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_MOVE event. These events occur when the mouse is moved around inside this component while the button is NOT pressed. It keeps track of the state of the mouse button while the mouse position is in the button.

Parameters:
e - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
always true since the event was handled
Overrides:
mouseMove in class Component
See Also:
mouseDrag, handleEvent
 o update
  public void update(Graphics g)
Handles redrawing of this component on the screen. This is a standard Java AWT method which gets called by the Java AWT (repaint()) to handle repainting this component on the screen. The graphics context clipping region is set to the bounding rectangle of this component and its <0,0> coordinate is this component's top-left corner. Typically this method paints the background color to clear the component's drawing space, sets graphics context to be the foreground color, and then calls paint() to draw the component. It is overridden here to add the clear frame feature to this button.

Parameters:
g - the graphics context
Overrides:
update in class Component
See Also:
repaint, paint
 o validate
  public void validate()
Ensures that this component is laid out properly, as needed. This is a standard Java AWT method which gets called by the AWT to make sure this component and its subcomponents have a valid layout. If this component was made invalid with a call to invalidate(), then it is laid out again. It is overridden here to locate the applet containing this component.

Overrides:
validate in class Component
See Also:
invalidate
 o preferredSize
  public Dimension preferredSize()
Returns the recommended dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the recommended size of this component. In this case the recommended size is the minimum dimension needed to encompass the three images that might be displayed.

Overrides:
preferredSize in class Component
See Also:
minimumSize

All Packages  Class Hierarchy  This Package  Previous  Next  Index