All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCComponent

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----jclass.bwt.JCComponent

public class JCComponent
extends Canvas
The abstract base class for all BWT components.

Methods which may be supplied by a subclass

 drawComponent (mandatory)
 preferredWidth
 preferredHeight
 reshape
 

Properties

Name Method
Background setBackground
DoubleBuffer setDoubleBuffer
Font setFont
Foreground setForeground
HighlightColor setHighlightColor
HighlightThickness setHighlightThickness
Insets setInsets
PreferredSize setPreferredSize
ShadowThickness setShadowThickness
Traversable setTraversable
UserData setUserData


Variable Index

 o applet
The parent applet.
 o applet_context
The current context.
 o dblbuffer_image
Current double-buffer image.
 o draw_gc
The instance passed to paint().
 o highlight
Highlight thickness.
 o in_repaint
In repaint() ?
 o needs_layout
Needs layout?
 o shadow
Shadow thickness.
 o shadow_type
Shadow type.
 o version

Constructor Index

 o JCComponent()
Creates a component.
 o JCComponent(Applet, String)
Creates a component which reads parameters from the applet's HTML file.

Method Index

 o addNotify()
Creates the peer of the canvas.
 o createImage(int, int)
Creates an off-screen drawable Image to be used for double buffering.
 o disable()
Disables the component.
 o drawHighlight(boolean)
Draws or clears the highlight rectangle (called by gotFocus).
 o drawHighlight(Graphics, boolean)
Draws or clears the highlight rectangle (called by paint).
 o drawShadow(Graphics)
Draws the shadow (called by paint).
 o enable()
Enables the component.
 o enable11Events(long)
For JDK1.1, calls Component.enableEvents (which is final).
 o fillBackground(Graphics)
Fills the component with the background color (called by paint).
 o getAppletContext()
Gets the component's applet's context.
 o getConverter()
Gets the converter used for converting strings to internal values.
 o getDoubleBuffer()
Gets the component's DoubleBuffer value.
 o getDoubleBufferGraphics()
Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage
 o getDoubleBufferImage()
Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.
 o getDrawingArea()
Gets the bounding rectangle of the component's drawing area, (its area minus the shadows and insets).
 o getDrawingArea(Rectangle)
Gets the bounding rectangle of the component's drawing area, (its area minus the shadows and insets).
 o getDrawingAreaHeight()
Gets the bounding rectangle's height of the component's drawing area, (its area minus the shadows and insets).
 o getDrawingAreaWidth()
Gets the bounding rectangle's width of the component's drawing area, (its area minus the shadows and insets).
 o getFrame()
Gets the parent frame.
 o getHighlightColor()
Gets the color of the highlight rectangle.
 o getHighlightThickness()
Gets the thickness of the highlight rectangle.
 o getInsets()
Returns the previously set insets.
 o getPaintRect()
Returns the area currently being painted, relative to the component's origin.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getParameters(Applet)
Reads the parameter values from the HTML page using the specified applet.
 o getParameters(Applet, String)
Reads the parameter values from the file.
 o getShadowThickness()
Gets the shadow's thickness.

HTML param name/value: "ShadowThickness"/int

 o getUserData()
Gets the userdata value.
 o getUserDataInt()
Gets the userdata value as an int.
 o gotFocus(Event, Object)
Called when the component receives keyboard focus.
 o hasFocus()
Returns true if this component has keyboard focus.
 o insets()
Returns the previously set insets.
 o isFocusTraversable()
Returns whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.
 o isTraversable()
Returns true if the component can accept focus - it must be traversable, showing, and enabled.
 o layout()
Lays out the component's internal elements.
 o lostFocus(Event, Object)
Called when the component loses keyboard focus.
 o minimumSize()
Returns preferredSize().
 o mouseDown(Event, int, int)
If btn1 is pressed and the component is traversable, requestFocus is called.
 o paint(Graphics)
An internal method used to handle repaint events.
 o paintComponent(Graphics)
Called by paint.
 o preferredHeight()
Gets the subclass' preferred height (default: 100).
 o preferredSize()
Returns the preferred size of this component.
 o preferredWidth()
Gets the subclass' preferred width (default: 100).
 o printAll(Graphics)
Disables double-buffering, and calls Container.printAll
 o processFocusEvent(FocusEvent)
Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.
 o processKeyEvent(KeyEvent)
Processes key events occurring on this component by dispatching them to any registered KeyListener objects.
 o processMouseEvent(MouseEvent)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.
 o processMouseMotionEvent(MouseEvent)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.
 o repaint()
Overrides Component.repaint(), which does not always call paint().
 o repaint(int, int, int, int)
Repaints part of the component by calling paint directly.
 o repaint(Rectangle)
Repaints part of the component by calling paint directly.
 o requestFocus()
Requests the input focus.
 o reshape(int, int, int, int)
Reshapes the Component to the specified bounding box.
 o reshape(Rectangle)
Reshapes the Component to the specified bounding box.
 o setBackground(Color)
Sets the background color of the component.

HTML param name/value: "Background"/Color

 o setConverter(JCConverter)
Sets the converter to be used for converting strings to internal values.
 o setCursor(int)
Sets the cursor in the parent frame.
 o setDoubleBuffer(boolean)
Controls whether double-buffering is used when displaying and updating the component.

HTML param name/value: "DoubleBuffer"/boolean

 o setFont(Font)
Sets the font of the component.

HTML param name/value: "Font"/font

 o setForeground(Color)
Sets the foreground color of the component.

HTML param name/value: "Foreground"/Color

 o setHighlightColor(Color)
Sets the color of the rectangle drawn when the component has focus (default: black).

HTML param name/value: "HighlightColor"/Color

 o setHighlightThickness(int)
Sets the thickness of the rectangle drawn when the component has focus (default: 2).

HTML param name/value: "HighlightThickness"/int

 o setInsets(Insets)
Sets the component's margins (default: 0).

HTML param name/value: "Insets"/Insets

 o setPreferredSize(int, int)
Sets the component's preferred size.
 o setShadowThickness(int)
Sets the shadow's thickness (default: 2)
 o setTraversable(boolean)
Sets whether the component can accept focus (default: true).

HTML param name/value: "Traversable"/boolean

 o setUserData(Object)
Sets an application-defined object that can be attached to the component.
 o update(Graphics)
Overriden because the default implementation always calls clearRect first, causing unwanted flicker
 o updateParent()
Forces the parent to relayout this component.
 o validate()
Validates a component.

Variables

 o version
  public final static String version
 o applet
  protected transient Applet applet
The parent applet.

 o applet_context
  protected transient AppletContext applet_context
The current context.

 o in_repaint
  protected transient boolean in_repaint
In repaint() ?

 o needs_layout
  protected transient boolean needs_layout
Needs layout?

 o highlight
  protected int highlight
Highlight thickness.

 o shadow
  protected int shadow
Shadow thickness.

 o shadow_type
  protected int shadow_type
Shadow type.

 o draw_gc
  protected transient Graphics draw_gc
The instance passed to paint().

 o dblbuffer_image
  protected transient Image dblbuffer_image
Current double-buffer image.

Constructors

 o JCComponent
  public JCComponent()
Creates a component. No parameters are read from an HTML file.

 o JCComponent
  public JCComponent(Applet applet,
                     String name)
Creates a component which reads parameters from the applet's HTML file.

Parameters:
applet - the applet whose PARAM tags are to be read
name - if this is not null, only parameters preceded by this name are read
See Also:
getParameter

Methods

 o getParameters
  protected void getParameters()
Reads the parameter values from the HTML page using the component's applet. The values will override those previously set. Subclasses may override this method to set their own values - in this case, the method should first call super.getParameters().

 o getParameters
  public void getParameters(Applet applet)
Reads the parameter values from the HTML page using the specified applet. The values will override those previously set.

See Also:
getParameter
 o getParameters
  public void getParameters(Applet applet,
                            String file)
Reads the parameter values from the file. The values will override those previously set.

Parameters:
applet - if not null and in a browser, its documentBase() is used to construct a complete filename if necessary
file - if an http protocol is not specified (if a ":" is not present), the current working directory is used
 o setConverter
  public static void setConverter(JCConverter c)
Sets the converter to be used for converting strings to internal values.

See Also:
JCConverter
 o getConverter
  public static JCConverter getConverter()
Gets the converter used for converting strings to internal values.

See Also:
JCConverter
 o setFont
  public synchronized void setFont(Font f)
Sets the font of the component.

HTML param name/value: "Font"/font

Overrides:
setFont in class Component
See Also:
toFont
 o setBackground
  public synchronized void setBackground(Color c)
Sets the background color of the component.

HTML param name/value: "Background"/Color

Overrides:
setBackground in class Component
See Also:
toColor
 o setForeground
  public synchronized void setForeground(Color c)
Sets the foreground color of the component.

HTML param name/value: "Foreground"/Color

Overrides:
setForeground in class Component
See Also:
toColor
 o getShadowThickness
  public int getShadowThickness()
Gets the shadow's thickness.

HTML param name/value: "ShadowThickness"/int

See Also:
setShadowThickness
 o setShadowThickness
  public void setShadowThickness(int v)
Sets the shadow's thickness (default: 2)

 o getHighlightThickness
  public int getHighlightThickness()
Gets the thickness of the highlight rectangle.

See Also:
setHighlightThickness
 o setHighlightThickness
  public synchronized void setHighlightThickness(int v)
Sets the thickness of the rectangle drawn when the component has focus (default: 2).

HTML param name/value: "HighlightThickness"/int

See Also:
toInt
 o getHighlightColor
  public Color getHighlightColor()
Gets the color of the highlight rectangle.

See Also:
setHighlightColor
 o setHighlightColor
  public synchronized void setHighlightColor(Color v)
Sets the color of the rectangle drawn when the component has focus (default: black).

HTML param name/value: "HighlightColor"/Color

See Also:
toColor
 o setInsets
  public synchronized void setInsets(Insets insets)
Sets the component's margins (default: 0).

HTML param name/value: "Insets"/Insets

See Also:
toInsets
 o getDrawingArea
  public Rectangle getDrawingArea()
Gets the bounding rectangle of the component's drawing area, (its area minus the shadows and insets).

See Also:
setInsets
 o getDrawingArea
  public void getDrawingArea(Rectangle rect)
Gets the bounding rectangle of the component's drawing area, (its area minus the shadows and insets).

See Also:
setInsets
 o getDrawingAreaHeight
  public int getDrawingAreaHeight()
Gets the bounding rectangle's height of the component's drawing area, (its area minus the shadows and insets).

See Also:
setInsets
 o getDrawingAreaWidth
  public int getDrawingAreaWidth()
Gets the bounding rectangle's width of the component's drawing area, (its area minus the shadows and insets).

See Also:
setInsets
 o insets
  public Insets insets()
Returns the previously set insets.

See Also:
setInsets
 o getInsets
  public Insets getInsets()
Returns the previously set insets.

See Also:
setInsets
 o getFrame
  public Frame getFrame()
Gets the parent frame.

 o setCursor
  public void setCursor(int cursor)
Sets the cursor in the parent frame.

 o enable
  public synchronized void enable()
Enables the component.

Overrides:
enable in class Component
 o disable
  public synchronized void disable()
Disables the component.

Overrides:
disable in class Component
 o isTraversable
  public boolean isTraversable()
Returns true if the component can accept focus - it must be traversable, showing, and enabled.

See Also:
setTraversable, isEnabled, isShowing
 o isFocusTraversable
  public boolean isFocusTraversable()
Returns whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.

Overrides:
isFocusTraversable in class Component
See Also:
setTraversable
 o setTraversable
  public void setTraversable(boolean v)
Sets whether the component can accept focus (default: true).

HTML param name/value: "Traversable"/boolean

See Also:
toBoolean
 o getUserData
  public Object getUserData()
Gets the userdata value.

See Also:
setUserData
 o getUserDataInt
  public int getUserDataInt()
Gets the userdata value as an int.

Returns:
0 if no user data has been set.
See Also:
setUserData
 o setUserData
  public void setUserData(Object v)
Sets an application-defined object that can be attached to the component.

 o layout
  public synchronized void layout()
Lays out the component's internal elements.

Overrides:
layout in class Component
 o reshape
  public synchronized void reshape(Rectangle rect)
Reshapes the Component to the specified bounding box.

 o getDoubleBufferImage
  public Image getDoubleBufferImage()
Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.

See Also:
getDoubleBufferGraphics
 o getDoubleBufferGraphics
  public synchronized Graphics getDoubleBufferGraphics()
Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage

Returns:
the Graphics instance for the image
See Also:
getDoubleBufferImage
 o repaint
  public synchronized void repaint()
Overrides Component.repaint(), which does not always call paint().

Overrides:
repaint in class Component
 o repaint
  public synchronized void repaint(Rectangle r)
Repaints part of the component by calling paint directly.

 o repaint
  public void repaint(int x,
                      int y,
                      int width,
                      int height)
Repaints part of the component by calling paint directly.

Overrides:
repaint in class Component
 o update
  public void update(Graphics g)
Overriden because the default implementation always calls clearRect first, causing unwanted flicker

Overrides:
update in class Component
 o updateParent
  public void updateParent()
Forces the parent to relayout this component.

 o paintComponent
  protected synchronized void paintComponent(Graphics gc)
Called by paint.

 o fillBackground
  protected void fillBackground(Graphics gc)
Fills the component with the background color (called by paint).

 o drawHighlight
  protected void drawHighlight(boolean on)
Draws or clears the highlight rectangle (called by gotFocus).

Parameters:
on - if true, draws the highlight rectangle; otherwise clears the rect
 o drawHighlight
  protected void drawHighlight(Graphics gc,
                               boolean on)
Draws or clears the highlight rectangle (called by paint).

Parameters:
on - if true, draws the highlight rectangle; otherwise clears the rect
 o drawShadow
  protected void drawShadow(Graphics gc)
Draws the shadow (called by paint).

 o getPaintRect
  public Rectangle getPaintRect()
Returns the area currently being painted, relative to the component's origin.

Returns:
null if no area is being drawn
See Also:
paint
 o paint
  public synchronized void paint(Graphics gc)
An internal method used to handle repaint events. Allocates double buffer image, draws highlight rectangle and shadows, then calls the subclass' paintComponent() method.

Overrides:
paint in class Canvas
See Also:
setDoubleBuffer, fillBackground, drawShadow, drawHighlight, setHighlightThickness, paintComponent
 o printAll
  public void printAll(Graphics gc)
Disables double-buffering, and calls Container.printAll

Overrides:
printAll in class Component
See Also:
setDoubleBuffer
 o enable11Events
  protected void enable11Events(long mask)
For JDK1.1, calls Component.enableEvents (which is final).

 o addNotify
  public void addNotify()
Creates the peer of the canvas.

Overrides:
addNotify in class Canvas
 o getAppletContext
  public AppletContext getAppletContext()
Gets the component's applet's context. The applet context lets an applet control the applet's environment which is usually the browser or the applet viewer.

Returns:
null if the component is not in an applet or the applet is not in a browser
See Also:
getAppletContext
 o minimumSize
  public Dimension minimumSize()
Returns preferredSize().

Overrides:
minimumSize in class Component
 o preferredWidth
  protected int preferredWidth()
Gets the subclass' preferred width (default: 100). The subclass should not include the shadow, highlight, or inset sizes in its calculation; these will be added by JCComponent.

 o preferredHeight
  protected int preferredHeight()
Gets the subclass' preferred height (default: 100). The subclass should not include the shadow, highlight, or inset sizes in its calculation; these will be added by JCComponent.

 o setPreferredSize
  public void setPreferredSize(int w,
                               int h)
Sets the component's preferred size. If either dimension is set to BWTEnum.NOVALUE, it is calculated by the subclass (default size: 100x100).

See Also:
preferredSize
 o preferredSize
  public Dimension preferredSize()
Returns the preferred size of this component. If the app has set the preferred size, that is returned. Otherwise the subclass' preferredWidth and/or preferredHeight method is called. This value may be set from an HTML file using a PARAM tag with a "preferredWidth" name and an int value, and/or a "preferredHeight" name and an int value.

Overrides:
preferredSize in class Component
See Also:
setPreferredSize, preferredWidth, preferredHeight, toInt
 o getDoubleBuffer
  public boolean getDoubleBuffer()
Gets the component's DoubleBuffer value.

See Also:
setDoubleBuffer
 o setDoubleBuffer
  public void setDoubleBuffer(boolean v)
Controls whether double-buffering is used when displaying and updating the component.

HTML param name/value: "DoubleBuffer"/boolean

See Also:
toBoolean
 o hasFocus
  public boolean hasFocus()
Returns true if this component has keyboard focus.

 o lostFocus
  public boolean lostFocus(Event ev,
                           Object what)
Called when the component loses keyboard focus.

Overrides:
lostFocus in class Component
See Also:
drawHighlight
 o gotFocus
  public boolean gotFocus(Event ev,
                          Object what)
Called when the component receives keyboard focus.

Overrides:
gotFocus in class Component
See Also:
drawHighlight
 o processFocusEvent
  protected void processFocusEvent(FocusEvent focus_ev)
Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.

Overrides:
processFocusEvent in class Component
 o processKeyEvent
  protected void processKeyEvent(KeyEvent key_ev)
Processes key events occurring on this component by dispatching them to any registered KeyListener objects.

Overrides:
processKeyEvent in class Component
 o processMouseEvent
  protected void processMouseEvent(MouseEvent mouse_ev)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

Overrides:
processMouseEvent in class Component
 o processMouseMotionEvent
  protected void processMouseMotionEvent(MouseEvent mouse_ev)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.

Overrides:
processMouseMotionEvent in class Component
 o mouseDown
  public boolean mouseDown(Event ev,
                           int x,
                           int y)
If btn1 is pressed and the component is traversable, requestFocus is called.

Overrides:
mouseDown in class Component
See Also:
isTraversable
 o requestFocus
  public void requestFocus()
Requests the input focus. gotFocus() will be called if this method is successful.

Overrides:
requestFocus in class Component
See Also:
gotFocus
 o reshape
  public synchronized void reshape(int x,
                                   int y,
                                   int width,
                                   int height)
Reshapes the Component to the specified bounding box.

Overrides:
reshape in class Component
 o validate
  public void validate()
Validates a component.

Overrides:
validate in class Component
 o createImage
  public Image createImage(int w,
                           int h)
Creates an off-screen drawable Image to be used for double buffering.

Overrides:
createImage in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index