Class wb.WBButton
All Packages Class Hierarchy This Package Previous Next Index
Class wb.WBButton
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----wb.WBButton
- public class WBButton
- extends Canvas
- implements GTypes
WBButton, is the base unit for all buttons. It is an extension of canvas
which has (more or less) same functionality as buttons and yet does not use
ButtonPeer. When add to a layout, it displays a small rectangle onto which
method draw can be used to draw anything including an image.
A string or label for this button can also be displayed conditionally.
In order to use this effectively, derive a class from this, and
override the method (fill in) ``draw'' method to display appropriate graphics
-
WBButton()
- Creates an instance of this.
-
WBButton(String, boolean)
- Creates an instance of this.
-
WBButton(String, WBDrawPanel, boolean)
- Creates an instance of this.
-
WBButton(String, WBDrawPanel, boolean, int)
- Creates an instance of this.
-
action(Event, Object)
- Called if an action occurs in the Component.
-
draw(Graphics)
- Only Method that has to be overridden to draw the required
on the available canvas.
-
drawFrame(Graphics, int, int, boolean)
-
Helper Internal Method that takes care of the borders of this
button when pressed
-
getLabel()
- Gets the label of the button.
-
handleEvent(Event)
- Handles the event.
-
inside(int, int)
- Internal method that tells the state of coordinates.
-
minimunSize()
- Returns the minimum size of this component.
-
mouseDown(Event, int, int)
- Called if the mouse is down.
-
mouseEnter(Event, int, int)
- Called when the mouse enters the component.
-
mouseExit(Event, int, int)
- Called if the mouse exits this component
-
mouseUp(Event, int, int)
- Called when the mouse button is Up (released)
-
paint(Graphics)
-
Paints the component.
-
paramString()
- Helper method to return the string representation of this
-
preferredSize()
-
Returns the preferred size of this component.
-
setPanel(WBDrawPanel)
- Helper Method to set the Panel that holds this Button
-
setType(int)
- Helper Method to set the type of this button
-
showText(boolean)
- Helper Method to alter the state of the label display on the button
-
update(Graphics)
-
Updates the component.
WBButton
public WBButton()
- Creates an instance of this.
WBButton
public WBButton(String name,
boolean displaytext)
- Creates an instance of this.
- Parameters:
- name - String that holds the name or label of this button
- displaytext - boolean to indicate if the label is to be displayed
WBButton
public WBButton(String name,
WBDrawPanel above,
boolean displaytext)
- Creates an instance of this.
- Parameters:
- name - String that holds the name or label of this button
- above - the Panel that holds this
- displaytext - boolean to indicate if the label is to be displayed
WBButton
public WBButton(String name,
WBDrawPanel above,
boolean displaytext,
int gtype)
- Creates an instance of this.
- Parameters:
- name - String that holds the name or label of this button
- above - the Panel that holds this
- displaytext - boolean to indicate if the label is to be displayed
- gtype - an int that is assigned to this button
showText
public void showText(boolean flag)
- Helper Method to alter the state of the label display on the button
- Parameters:
- flag - boolean that tells if the label is to be displayed
setPanel
public void setPanel(WBDrawPanel arg)
- Helper Method to set the Panel that holds this Button
- Parameters:
- arg - the WBDrawPanel that holds this.
setType
public void setType(int gtype)
- Helper Method to set the type of this button
- Parameters:
- gtype - int that is assigned to his button.
update
public void update(Graphics g)
- Updates the component. This method is called in
response to a call to repaint.
- Parameters:
- g - the specified Graphics window
- Overrides:
- update in class Component
- See Also:
- paint
paint
public void paint(Graphics g)
- Paints the component.
- Parameters:
- g - the specified Graphics window
- Overrides:
- paint in class Canvas
- See Also:
- update
preferredSize
public Dimension preferredSize()
- Returns the preferred size of this component.
- Overrides:
- preferredSize in class Component
- See Also:
- minimumSize
minimunSize
public Dimension minimunSize()
- Returns the minimum size of this component.
- See Also:
- preferredSize, LayoutManager
getLabel
public String getLabel()
- Gets the label of the button. Useful for capturing the evt.target
when an action event occcurs.
handleEvent
public boolean handleEvent(Event evt)
- Handles the event. Returns true if the event is handled and
should not be passed to the parent of this component.
It is required to overide the parent class handler since we are
interested in repaint.
did some changes. May be this is not required any more.
- Parameters:
- evt - the event
- Overrides:
- handleEvent in class Component
- See Also:
- mouseEnter, mouseExit, mouseDown, mouseUp
action
public boolean action(Event evt,
Object what)
- Called if an action occurs in the Component.
- Parameters:
- evt - the event
- what - the action that's occuring
- Overrides:
- action in class Component
- See Also:
- handleEvent
mouseDown
public boolean mouseDown(Event evt,
int x,
int y)
- Called if the mouse is down.
- Parameters:
- evt - the event
- x - the x coordinate
- y - the y coordinate
- Overrides:
- mouseDown in class Component
- See Also:
- handleEvent
mouseExit
public boolean mouseExit(Event evt,
int x,
int y)
- Called if the mouse exits this component
- Parameters:
- evt - the event
- x - the x coordinate
- y - the y coordinate
- Overrides:
- mouseExit in class Component
- See Also:
- handleEvent
mouseEnter
public boolean mouseEnter(Event evt,
int x,
int y)
- Called when the mouse enters the component.
- Parameters:
- evt - the event
- x - the x coordinate
- y - the y coordinate
- Overrides:
- mouseEnter in class Component
- See Also:
- handleEvent
mouseUp
public boolean mouseUp(Event evt,
int x,
int y)
- Called when the mouse button is Up (released)
- Parameters:
- evt - the event
- x - the x coordinate
- y - the y coordinate
- Overrides:
- mouseUp in class Component
- See Also:
- handleEvent
draw
protected void draw(Graphics g)
- Only Method that has to be overridden to draw the required
on the available canvas.
left top = (5, 5)
right bottom = (35, 25)
- Parameters:
- g - Graphics on to which the drawing is to be made.
drawFrame
protected void drawFrame(Graphics g,
int width,
int height,
boolean pressed)
- Helper Internal Method that takes care of the borders of this
button when pressed
inside
public boolean inside(int x,
int y)
- Internal method that tells the state of coordinates.
Was required to overide Java 's "inside" method. (bug fix)
- Parameters:
- x - the x-coordinate
- y - the y-coordinate
- Returns:
- boolean true iff the (x,y) is inside this
- Overrides:
- inside in class Component
paramString
protected String paramString()
- Helper method to return the string representation of this
- Returns:
- String
- Overrides:
- paramString in class Component
All Packages Class Hierarchy This Package Previous Next Index