Component
A Component is a generic widget that is never instantiated, however, Component has some methods commonly used by subclasses.
Method(s) of note (ignoring the event convenience methods and functionality not discussed in this short course):
- public Rectangle bounds()
Returns the size of the Component.
- public void disable()
Make the Component insensitive to user input; normally, the Component's appearance "dehighlights" as well.
- public void enable()
Make 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)
Tell the window toolkit to paint the Component. Most subclasses override this method.
- public void repaint()
Repaint the Component; the Component is erased then painted.
- public void setFont(Font f)
Set the Font for a Component.
- setForeground(Color c)
Set the color of the Component's foreground.