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) |
| 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 |
|---|---|
void setActionCommand(String)
|
Set or get the name of the action performed by the button. |
void addActionListener(ActionListener)
|
Add or remove an object that listens for action events fired by the button. |
| 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 |
|---|---|
JTextField()
|
Create a text field.
When present, the int argument specifies the desired width
in columns.
The String argument contains the field's initial text.
|
void setText(String)
|
Set or get the text displayed by the text field.
Note that getText does not work for
password fields.
|
| Constructor | Purpose |
|---|---|
JPanel()
|
Create a panel.
The LayoutManager parameter provides a
layout manager for the new panel.
By default, a panel uses a FlowLayout
to lay out its components.
|
| Method | Purpose |
|---|---|
void add(Component)
|
Add the specified component to the panel.
When present, the int
parameter is the index of the component
within the container.
By default, the first component added is at index 0,
the second is at index 1, and so on.
The Object parameter
is layout manager dependent and typically provides
information to the layout manager regarding positioning
and other layout constraints for the added component.
The String parameter
is similar to the Object parameter.
|
int getComponentCount()
|
Get the number of components in this panel. |
Component getComponent(int)
|
Get the specified component or components. You can get a component based on its index or x, y position. |
void remove(Component)
|
Remove the specified component(s). |
| Method | Purpose |
|---|---|
void setLayout(LayoutManager)
|
Set or get the layout manager for this panel. The layout manager is responsible for positioning the panel's components within the panel's bounds according to some philosophy. |
| 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. |
| Method or Constructor | Purpose |
|---|---|
Object getSource()
|
The object on which the Event initially occurred. |
String getActionCommand()
|
Returns the command string associated with this action. |
| Member | Description |
byte byteValue(), short shortValue(), int intValue(),
long longValue(), float floatValue(), double doubleValue()
|
Convert the value of this number object to the primitive date types
of byte, short, int, long, float and double
|
| Constructors or members | Description |
static double MAX_VALUE, |
max/min value |
static double NaN |
Not a number |
static double NEGATIVE_INFINITY,. |
|
public Double(double value), |
meaning is clear |
String toString(), |
Returns a String representation. |
static double parseDouble(String s)
throws NumberFormatException,
|
Returns a new double(or Double) initialized to the value represented by the specified String. |
boolean equals(Object) |
determine if the object is equal to the Double |
int compareTo(Double anotherDouble) |
Compares two Doubles numerically. The value is bigger then 0 if the
Double is bigger than anotherDouble etc.
|
| Methods | Description |
void add(int index, Object element) |
Inserts the specified element at the specified position in this list. |
boolean add(Object o) |
Appends the specified element to the end of this list |
void clear() |
Removes all of the elements from this list. |
boolean contains(Object o) |
Returns true if this list contains the specified element. |
Object get(int index) |
Returns the element at the specified position in this list. |
int indexOf(Object o) |
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
boolean isEmpty() |
Returns true if this list contains no elements. |
int lastIndexOf(Object o) |
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. |
Object remove(int index) |
Removes the element at the specified position in this list. |
boolean remove(Object o) |
Removes the first occurrence in this list of the specified element . |
Object set(int index, Object element) |
Replaces the element at the specified position in this list with the specified element. |
int size() |
Returns the number of elements in this list. |
Object[] toArray() |
Returns an array containing all of the elements in this list in proper sequence. |
| Constructor/Methods | Description |
Vector(),Vector(int initialCapacity) |
Constructs an empty vector with the specified initial capacity, the default is 10. |
Object firstElement() |
Returns the first component (the item at index 0) of this vector. |
Object lastElement() |
Returns the last component of the vector. |
| Methods | Description |
LinkedList() |
Constructs an empty list. |
void addFirst(Object o) |
Inserts the given element at the beginning of this list. |
void addLast(Object o) |
Appends the given element to the end of this list. |
Object getFirst() |
Returns the first element in this list. |
Object getLast() |
Returns the last element in this list. |
Object removeFirst() |
Removes and returns the first element from this list. |
Object removeLast() |
Removes and returns the last element from this list. |
| Constructors/Methods | Description |
|---|---|
|
File(String pathname), File(String parent, String filename), File(File directory, String filename) |
Creates a new File instance by converting the given pathname string into an abstract pathname. Or creates a new File instance from a parent pathname string (or directory) and a child pathname string. |
| Constructors/Methods | Description |
|---|---|
| exists() | Tests whether the file denoted by this abstract pathname exists. |
| isFile() |
Tests whether the file denoted by this abstract pathname is a normal file.
Returns true if and only if the file denoted by this abstract pathname exists and is a normal file;
false otherwise.
|
| isDirectory() |
Tests whether the file denoted by this abstract pathname is a directory.
Returns true if and only if the file denoted by this abstract pathname exists and is a directory;
false otherwise.
|
| Constructors/Methods | Description |
|---|---|
| boolean mkdir() | Creates the directory named by this abstract pathname. Returns true if and only if the directory was created; false otherwise. |
| boolean mkdirs() | Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Returns true if and only if the directory was created, along with all necessary parent directories; false otherwise |
| boolean delete() | Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted. Returns true if and only if the file or directory is successfully deleted; false otherwise |
| boolean renameTo(File dest) | Renames the file denoted by this abstract pathname. Returns true if and only if the renaming succeeded; false otherwise |
| Constructors/Methods | Description |
|---|---|
| String[] list() | Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname. If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. |
| File[] listFiles() | Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. |
| Constructors/Methods | Description |
|---|---|
| long lastModified() | Returns the time that the file denoted by this abstract pathname was last modified. |
| long length() | Returns the length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist |
| Constructors/Methods | Description |
|---|---|
|
FileInputStream(String name) throws FileNotFoundException FileInputStream(File file) throws FileNotFoundException |
Creates a FileInputStream by opening a connection to an actual file.If the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading then a FileNotFoundException is thrown.
|
| int read() throws IOException | Read and return the next byte of data, or -1 if the end of the file is reached. |
int read(byte[] b) throws IOException int read(byte[] b, int off, int len) throws IOException |
Reads up to b.length/len bytes of data from this input stream into
an array of bytes.It returns the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached. |
| int available() throws IOException | Returns the number of bytes that can be read from this file input stream without blocking |
| long skip(long n) throws IOException | Skips over and discards n bytes of data from the input stream. |
| void close() throws IOException | Closes this file input stream and releases any system resources associated with the stream. |
| Constructors/Methods | Description |
|---|---|
|
FileOutputStream(File file) throws FileNotFoundException FileOutputStream(String name) throws FileNotFoundException FileOutputStream(String name, boolean append) throws FileNotFoundException |
Creates an output file stream to write to the file with the specified file or
name. If append is true, then bytes will be written to the end of the file
rather than the beginning.If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.
|
|
void write(int b)throws IOException void write(byte[] b) throws IOException void write(byte[] b, int off, int len) throws IOException |
Writes the specified byte(s) to this file output stream. |
| void close() throws IOException | Closes this file output stream and releases any system resources associated with this stream. This file output stream may no longer be used for writing bytes. |
| Constructors/Methods | Description |
|---|---|
|
BufferedInputStream(InputStream in), BufferedInputStream(InputStream in, int size) |
Creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use. An internal buffer array of length size is created and stored in buf. |
|
int available(),
void close() ,
int read(),
int read(byte[] b, int off, int len),
long skip(long n) All throws IOException |
Meanings of the methods are clear. |
| Constructors/Methods | Description |
|---|---|
| BufferedOutputStream(OutputStream out), BufferedOutputStream(OutputStream out, int size). | Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size. The default is 512. |
|
void write(int b),
void write(byte[] b, int off, int len) all throws IOException |
|
| void flush() | Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream. |
| Constructors/Methods | Description |
|---|---|
|
PrintStream(OutputStream out), PrintStream(OutputStream out, boolean autoFlush) |
out - The output stream to which values and objects will be printed autoFlush - A boolean; if true, the output buffer will be flushed whenever a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written. |
|
void print(boolean b),
void print(char c),
void print(char[] s),
void print(double d),
void print(float f),
void print(int i),
void print(long l),
void print(Object obj),
void print(String s) void println(boolean b), void println(char c), void println(char[] s), void println(double d), void println(float f), void println(int i), void println(long l), void println(Object obj), void println(String s), |
The meanings are clear. |
| void close() ,void flush(),void write(int b) , void write(byte[] buf, int off, int len) |
Same as in FileOutputStream.
|
| boolean checkError(),void setError() | Flush the stream and check its error state. The internal error state is set to true when the underlying output stream throws an IOException other than InterruptedIOException. |
| Constructors/Methods | Description |
|---|---|
|
FileReader(File file) , FileReader(String fileName) |
Creates a new FileReader, given the file to read from. |
| Constructors/Methods | Description |
|---|---|
| BufferedReader(Reader in) | Create a buffering character-input stream that uses a default-sized input buffer |
| public String readLine() throws IOException | Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. Returns a String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached |
| Constructors/Methods | Description |
|---|---|
| StringTokenizer(String str) | Constructs a string tokenizer for the specified string. |
| int countTokens() | Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.. |
| boolean hasMoreTokens() | Tests if there are more tokens available from this tokenizer's string. |
| String nextToken() | Returns the next token from this string tokenizer. |