java.awt
Class Component
java.lang.Object
|
+--java.awt.Component
- All Implemented Interfaces:
- ImageObserver
- Direct Known Subclasses:
- Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, TextComponent
- public abstract class Component
- extends java.lang.Object
- implements ImageObserver
Important Limitations:
- Only one listener of each type is allowed
- Many methods are still missing
|
Method Summary |
void |
addFocusListener(FocusListener l)
|
void |
addKeyListener(KeyListener l)
|
void |
addMouseListener(MouseListener l)
|
void |
addMouseMotionListener(MouseMotionListener l)
|
boolean |
contains(int x,
int y)
|
void |
dispatchEvent(AWTEvent event)
|
void |
enableEvents(long mask)
internal convenience method for drawing possibly focussed strings
void drawFocusString (Graphics g, String text, int x, int y) {
if (hasFocus) {
FontMetrics fm = g.getFontMetrics ();
g.fillRect (x, y, fm.stringWidth (text), fm.getHeight ());
Color c = g.getColor ();
g.setColor (new Color (0x0ffffff ^ c.getRGB ()));
g.drawString (text, x, y+fm.getAscent ());
g.setColor (c);
}
else g.drawString (text, x, y+fontMetrics.getAscent ());
} |
Component |
findComponentAt(int px,
int py)
|
Color |
getBackground()
|
Rectangle |
getBounds()
|
Font |
getFont()
|
FontMetrics |
getFontMetrics(Font font)
|
Color |
getForeground()
|
Graphics |
getGraphics()
|
int |
getHeight()
|
Point |
getLocationOnScreen()
return null if not visible |
Dimension |
getMaximumSize()
|
Dimension |
getMinimumSize()
|
Container |
getParent()
|
Dimension |
getPreferredSize()
|
Dimension |
getSize()
|
int |
getWidth()
|
int |
getX()
|
int |
getY()
|
boolean |
hasFocus()
|
void |
invalidate()
|
boolean |
isEnabled()
|
boolean |
isFocusTraversable()
|
boolean |
isValid()
|
boolean |
isVisible()
|
void |
paint(Graphics g)
|
void |
paintAll(Graphics g)
|
void |
processEvent(AWTEvent e)
Processes the given event. |
void |
processFocusEvent(FocusEvent fe)
|
void |
processKeyEvent(KeyEvent ke)
|
void |
processMouseEvent(MouseEvent me)
|
void |
processMouseMotionEvent(MouseEvent me)
|
void |
repaint()
|
void |
repaint(int rx,
int ry,
int rw,
int rh)
|
void |
requestFocus()
|
void |
setBackground(Color c)
|
void |
setBounds(int newX,
int newY,
int newW,
int newH)
|
void |
setEnabled(boolean b)
|
void |
setFont(Font f)
|
void |
setForeground(Color c)
sets foreground color |
void |
setLocation(int x,
int y)
|
void |
setSize(Dimension d)
|
void |
setSize(int w,
int h)
|
void |
setVisible(boolean v)
|
void |
update(Graphics g)
|
void |
validate()
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Component
public Component()
addMouseListener
public void addMouseListener(MouseListener l)
addFocusListener
public void addFocusListener(FocusListener l)
addMouseMotionListener
public void addMouseMotionListener(MouseMotionListener l)
addKeyListener
public void addKeyListener(KeyListener l)
contains
public boolean contains(int x,
int y)
enableEvents
public void enableEvents(long mask)
- internal convenience method for drawing possibly focussed strings
void drawFocusString (Graphics g, String text, int x, int y) {
if (hasFocus) {
FontMetrics fm = g.getFontMetrics ();
g.fillRect (x, y, fm.stringWidth (text), fm.getHeight ());
Color c = g.getColor ();
g.setColor (new Color (0x0ffffff ^ c.getRGB ()));
g.drawString (text, x, y+fm.getAscent ());
g.setColor (c);
}
else g.drawString (text, x, y+fontMetrics.getAscent ());
}
findComponentAt
public Component findComponentAt(int px,
int py)
getBackground
public Color getBackground()
getBounds
public Rectangle getBounds()
getLocationOnScreen
public Point getLocationOnScreen()
- return null if not visible
getFont
public Font getFont()
getFontMetrics
public FontMetrics getFontMetrics(Font font)
getForeground
public Color getForeground()
getGraphics
public Graphics getGraphics()
getMaximumSize
public Dimension getMaximumSize()
getSize
public Dimension getSize()
getX
public int getX()
getY
public int getY()
getWidth
public int getWidth()
getHeight
public int getHeight()
getPreferredSize
public Dimension getPreferredSize()
getMinimumSize
public Dimension getMinimumSize()
getParent
public Container getParent()
dispatchEvent
public void dispatchEvent(AWTEvent event)
hasFocus
public boolean hasFocus()
invalidate
public void invalidate()
isEnabled
public boolean isEnabled()
isVisible
public boolean isVisible()
isValid
public boolean isValid()
isFocusTraversable
public boolean isFocusTraversable()
processEvent
public void processEvent(AWTEvent e)
- Processes the given event. Only active when a listener
is registered or events are enabled by enableEvents ().
processFocusEvent
public void processFocusEvent(FocusEvent fe)
processKeyEvent
public void processKeyEvent(KeyEvent ke)
processMouseEvent
public void processMouseEvent(MouseEvent me)
processMouseMotionEvent
public void processMouseMotionEvent(MouseEvent me)
paint
public void paint(Graphics g)
paintAll
public void paintAll(Graphics g)
requestFocus
public void requestFocus()
repaint
public void repaint(int rx,
int ry,
int rw,
int rh)
repaint
public void repaint()
setBackground
public void setBackground(Color c)
setBounds
public void setBounds(int newX,
int newY,
int newW,
int newH)
setEnabled
public void setEnabled(boolean b)
setForeground
public void setForeground(Color c)
- sets foreground color
setFont
public void setFont(Font f)
setLocation
public void setLocation(int x,
int y)
setSize
public void setSize(int w,
int h)
setSize
public void setSize(Dimension d)
update
public void update(Graphics g)
setVisible
public void setVisible(boolean v)
validate
public void validate()