Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Top
Back
Next
Online Training
shadowSearchFAQFeedback

Component

A Component is a generic widget that is never instantiated. However, all graphics widgets derive from Component--an abstract class that provides some commonly used methods.

Methods:

These do not include the event-convenience methods and functionality not discussed in this short course):

  • public Rectangle bounds()
    Returns the size of the Component.
  • public void disable()
    Makes the Component insensitive to user input; normally, the Component's appearance "dehighlights" as well.
  • public void enable()
    Makes the Component sensitive to user input.
  • public Font getFont()
    What Font is associated with this Component? You need this when you want to change its Font and then restore it.
  • public Graphics getGraphics()
    Returns the graphics context of this component. If this Component is not currently being displayed, null is returned.
  • public void paint(Graphics g)
    Tells the window toolkit to paint the Component. Most subclasses override this method.
  • public void repaint()
    Repaints the Component; the Component is erased then painted.
  • public void setFont(Font f)
    Sets the font for a Component.
  • setForeground(Color c)
    Sets the color of the Component's foreground.