| Method or Constructor | Purpose |
|---|---|
void drawArc(int x, int y, int width, int height, int startAngle, int
arcAngle) |
Draws the outline of a circular or elliptical arc covering the specified rectangle. |
void drawLine(int x1, int y1, int x2, int y2)
|
Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics. |
void drawOval(int x, int y, int width, int height)
|
Draws the outline of an oval. |
void drawString(String str, int x, int y)
|
Draws the text given by the specified string, using this graphics context's current font and color. |
void fillArc(int x, int y, int width, int height, int startAngle, int
arcAngle) |
Fills a circular or elliptical arc covering the specified rectangle. |
void fillOval(int x, int y, int width, int height) |
Fills an oval bounded by the specified rectangle with the current color. |
void fillRect(int x, int y, int width, int height) |
Fills the specified rectangle. |
Color getColor(), void setColor(Color) |
Gets and sets this graphics context's current color. |
Font, getFont(),void setFont(Font font) |
Sets this graphics context's font to the specified font. |
| Method or Constructor | Purpose |
|---|---|
Color(float r, float g, float b) , Color(int r, int g, int b)
|
Specific the red, green, blue component. |
Color brighter(), Color darker() |
Creates a new Color that is a brighter (or darker) version of this Color. |
| Method or Constructor | Purpose |
|---|---|
Font(String name, int style, int size) |
Creates a new Font from the specified name, style and point size. name - the font name. This can be a logical font name or a font face name. style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC). size - the point size of the Font. |
Color getForeground(),
void setForeground(Color c),
Color getBackground(),
void setBackground(Color c)
|
Gets and sets the background/foreground color of this component. |
void setSize(int width, int height)
|
Resizes this component so that it has width width and height. |
| Method or Constructor | Purpose |
|---|---|
JButton(String, Icon)
|
Create a JButton instance,
initializing it to have the specified text/image.
|
void setText(String)
|
Set or get the text displayed by the button. |
void setIcon(Icon)
|
Set or get the image displayed by the button when the button isn't selected or pressed. |
void setDisabledIcon(Icon)
|
Set or get the image displayed by the button when it's disabled. If you don't specify a disabled image, then the look and feel creates one by manipulating the default image. |
void setPressedIcon(Icon)
|
Set or get the image displayed by the button when it's being pressed. |
void setSelectedIcon(Icon)
|
Set or get the image displayed by the button when it's selected. If you don't specify a disabled selected image, then the look and feel creates one by manipulating the selected image. |
setRolloverEnabled(boolean)
|
Use setRolloverEnabled(true) and
setRolloverIcon(someIcon)
to make the button display the specified icon
when the cursor passes over it.
|
| Method or Constructor | Purpose |
|---|---|
void setHorizontalAlignment(int)
|
Set or get where in the button its contents should be placed.
The AbstractButton class allows
any one of the following values
for horizontal alignment:
LEFT,
CENTER (the default), and
RIGHT.
For vertical alignment:
TOP,
CENTER (the default), and
BOTTOM.
|
void setHorizontalTextPosition(int)
|
Set or get where the button's text should be placed,
relative to the button's image.
The AbstractButton class allows
any one of the following values
for horizontal position:
LEFT,
CENTER, and
RIGHT (the default).
For vertical position:
TOP,
CENTER (the default), and
BOTTOM.
|
| Method or Constructor | Purpose |
|---|---|
JLabel(Icon)
|
Create a JLabel instance,
initializing it to have the specified text/image/alignment.
The int argument
specifies the horizontal alignment
of the label's contents within its drawing area.
The horizontal alignment must be one of the following constants
defined in the
SwingConstantsJLabel implements):
LEFT, CENTER, RIGHT,
LEADING, or TRAILING.
|
void setText(String)
|
Set or get the text displayed by the label. |
void setIcon(Icon)
|
Set or get the image displayed by the label. |
| Method | Purpose |
|---|---|
void setHorizontalAlignment(int)
|
Set or get where in the label its contents should be placed.
The
SwingConstantsLEFT (the default for text-only labels),
CENTER (the default for image-only labels),
RIGHT,
LEADING, and
TRAILING.
For vertical alignment:
TOP,
CENTER (the default), and
BOTTOM.
|
void setHorizontalTextPosition(int)
|
Set or get where the button's text should be placed,
relative to the button's image.
The
SwingConstantsLEFT,
CENTER, and
RIGHT (the default).
For vertical position:
TOP,
CENTER (the default), and
BOTTOM.
|
| Method or Constructor | Purpose |
|---|---|
public FlowLayout(),
public FlowLayout(int alignment),
public FlowLayout(int alignment,
int horizontalGap, int verticalGap)
|
The alignment argument must have the value FlowLayout.LEFT, FlowLayout.CENTER, or FlowLayout.RIGHT. The horizontalGap and verticalGap arguments specify the number of pixels to put between components. If you don't specify a gap value, FlowLayout uses 5 for the default gap value. |
| Method or Constructor | Purpose |
|---|---|
BorderLayout(),
BorderLayout(int horizontalGap, int verticalGap)
|
Constructs a border layout with the specified gaps between components. The default is 0. |
| Method or Constructor | Purpose |
|---|---|
public GridLayout(int rows, int columns)
public GridLayout(int rows, int columns,
int horizontalGap, int verticalGap)
|
At least one of the rows and columns arguments must be nonzero. The horizontalGap and verticalGap arguments to the second constructor allow you to specify the number of pixels between cells. If you don't specify gaps, their values default to zero. |
Methods for changing strings |
|
String concat(String str) |
String toUpperCase() |
Methods for searching |
|
int indexOf(int ch) |
int indexOf(String str) |
Methods for testing |
|
boolean startsWith(String prefix, int toffset) |
boolean endsWith(String suffix) |
Methods for accessing |
|
String substring(int beginIndex) |
char charAt(int index) |