    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

##

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

##

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

##

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

  HTML param name/value: "ShadowThickness"/int

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

  HTML param name/value: "Background"/Color

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

  HTML param name/value: "DoubleBuffer"/boolean

setFont(Font)
  Sets the font of the component.

  HTML param name/value: "Font"/font

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

  HTML param name/value: "Foreground"/Color

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

  HTML param name/value: "HighlightColor"/Color

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

  HTML param name/value: "HighlightThickness"/int

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

  HTML param name/value: "Insets"/Insets

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

  HTML param name/value: "Traversable"/boolean

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

##

version

      public final static String version

applet

      protected transient Applet applet

  The parent applet.

applet_context

      protected transient AppletContext applet_context

  The current context.

in_repaint

      protected transient boolean in_repaint

  In repaint() ?

needs_layout

      protected transient boolean needs_layout

  Needs layout?

highlight

      protected int highlight

  Highlight thickness.

shadow

      protected int shadow

  Shadow thickness.

shadow_type

      protected int shadow_type

  Shadow type.

draw_gc

      protected transient Graphics draw_gc

  The instance passed to paint().

dblbuffer_image

      protected transient Image dblbuffer_image

  Current double-buffer image.

##

JCComponent

      public JCComponent()

  Creates a component. No parameters are read from an HTML file.

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

##

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().

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

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

setConverter

      public static void setConverter(JCConverter c)

  Sets the converter to be used for converting strings to internal values.

  See Also:
    JCConverter

getConverter

      public static JCConverter getConverter()

  Gets the converter used for converting strings to internal values.

  See Also:
    JCConverter

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

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

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

getShadowThickness

      public int getShadowThickness()

  Gets the shadow's thickness.

  HTML param name/value: "ShadowThickness"/int

  See Also:
    setShadowThickness

setShadowThickness

      public void setShadowThickness(int v)

  Sets the shadow's thickness (default: 2)

getHighlightThickness

      public int getHighlightThickness()

  Gets the thickness of the highlight rectangle.

  See Also:
    setHighlightThickness

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

getHighlightColor

      public Color getHighlightColor()

  Gets the color of the highlight rectangle.

  See Also:
    setHighlightColor

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

setInsets

      public synchronized void setInsets(Insets insets)

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

  HTML param name/value: "Insets"/Insets

  See Also:
    toInsets

getDrawingArea

      public Rectangle getDrawingArea()

  Gets the bounding rectangle of the component's drawing area, (its area minus the shadows and insets).

  See Also:
    setInsets

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

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

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

insets

      public Insets insets()

  Returns the previously set insets.

  See Also:
    setInsets

getInsets

      public Insets getInsets()

  Returns the previously set insets.

  See Also:
    setInsets

getFrame

      public Frame getFrame()

  Gets the parent frame.

setCursor

      public void setCursor(int cursor)

  Sets the cursor in the parent frame.

enable

      public synchronized void enable()

  Enables the component.

  Overrides:
    enable in class Component

disable

      public synchronized void disable()

  Disables the component.

  Overrides:
    disable in class Component

isTraversable

      public boolean isTraversable()

  Returns true if the component can accept focus - it must be traversable, showing, and enabled.

  See Also:
    setTraversable, isEnabled, isShowing

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

setTraversable

      public void setTraversable(boolean v)

  Sets whether the component can accept focus (default: true).

  HTML param name/value: "Traversable"/boolean

  See Also:
    toBoolean

getUserData

      public Object getUserData()

  Gets the userdata value.

  See Also:
    setUserData

getUserDataInt

      public int getUserDataInt()

  Gets the userdata value as an int.

  Returns:
    0 if no user data has been set.
  See Also:
    setUserData

setUserData

      public void setUserData(Object v)

  Sets an application-defined object that can be attached to the component.

layout

      public synchronized void layout()

  Lays out the component's internal elements.

  Overrides:
    layout in class Component

reshape

      public synchronized void reshape(Rectangle rect)

  Reshapes the Component to the specified bounding box.

getDoubleBufferImage

      public Image getDoubleBufferImage()

  Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.

  See Also:
    getDoubleBufferGraphics

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

repaint

      public synchronized void repaint()

  Overrides Component.repaint(), which does not always call paint().

  Overrides:
    repaint in class Component

repaint

      public synchronized void repaint(Rectangle r)

  Repaints part of the component by calling paint directly.

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

update

      public void update(Graphics g)

  Overriden because the default implementation always calls clearRect first, causing unwanted flicker

  Overrides:
    update in class Component

updateParent

      public void updateParent()

  Forces the parent to relayout this component.

paintComponent

      protected synchronized void paintComponent(Graphics gc)

  Called by paint.

fillBackground

      protected void fillBackground(Graphics gc)

  Fills the component with the background color (called by paint).

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

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

drawShadow

      protected void drawShadow(Graphics gc)

  Draws the shadow (called by paint).

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

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

printAll

      public void printAll(Graphics gc)

  Disables double-buffering, and calls Container.printAll

  Overrides:
    printAll in class Component
  See Also:
    setDoubleBuffer

enable11Events

      protected void enable11Events(long mask)

  For JDK1.1, calls Component.enableEvents (which is final).

addNotify

      public void addNotify()

  Creates the peer of the canvas.

  Overrides:
    addNotify in class Canvas

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

minimumSize

      public Dimension minimumSize()

  Returns preferredSize().

  Overrides:
    minimumSize in class Component

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.

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.

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

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

getDoubleBuffer

      public boolean getDoubleBuffer()

  Gets the component's DoubleBuffer value.

  See Also:
    setDoubleBuffer

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

hasFocus

      public boolean hasFocus()

  Returns true if this component has keyboard focus.

lostFocus

      public boolean lostFocus(Event ev,
                               Object what)

  Called when the component loses keyboard focus.

  Overrides:
    lostFocus in class Component
  See Also:
    drawHighlight

gotFocus

      public boolean gotFocus(Event ev,
                              Object what)

  Called when the component receives keyboard focus.

  Overrides:
    gotFocus in class Component
  See Also:
    drawHighlight

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

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

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

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

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

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

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

validate

      public void validate()

  Validates a component.

  Overrides:
    validate in class Component

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