Component Methods

Although labels don't have many methods of their own, they do inherit a number of useful methods from the superclass, java.awt.Component. An incomplete list of these methods includes:

 public String getName()
 public void setName(String name)
 public boolean isVisible()
 public boolean isShowing()
 public boolean isEnabled()
 public void setEnabled(boolean b)
 public void setVisible(boolean b)
 public Color getForeground()
 public void setForeground(Color c)
 public Color getBackground()
 public void setBackground(Color c)
 public Font getFont()
 public synchronized void setFont(Font f)
 public Locale getLocale()
 public void setLocale(Locale l)
 public ColorModel getColorModel()
 public Point getLocation()
 public Point getLocationOnScreen()
 public void setLocation(int x, int y)
 public void setLocation(Point p)
 public Dimension getSize()
 public void setSize(int width, int height)
 public Rectangle getBounds()
 public void setBounds(int x, int y, int width,int height)
 public void setBounds(Rectangle r)
 public Dimension getPreferredSize()
 public Dimension getMinimumSize()
 public Dimension getMaximumSize()
 public float getAlignmentX()
 public float getAlignmentY()
 public FontMetrics getFontMetrics(Font font)
 public synchronized void setCursor(Cursor cursor)
 public Cursor getCursor()
 public void paint(Graphics g)
 public void update(Graphics g)
 public void paintAll(Graphics g)
 public void repaint()
 public void repaint(long tm)
 public void repaint(int x, int y, int width,int height)
 public void repaint(long tm, int x, int y, int width,int height)
 public void print(Graphics g)
 public void printAll(Graphics g)
 public boolean contains(int x, int y)
 public boolean contains(Point p)
 public Component getComponentAt(int x, int y)
 public Component getComponentAt(Point p)

These methods are also available in all other subclasses of component we'll discuss including Applet, Button, TextField, TextArea, List, Checkbox, and so forth.

Previous | Next | Top | Cafe au Lait

Copyright 1998 Elliotte Rusty Harold
Last Modified June 26, 1998