String

Methods for changing strings

String concat(String str)
String replace(char oldChar, char newChar)
String toLowerCase()
String toUpperCase()
String trim()

Methods for searching

int indexOf(int ch)
int indexOf(int ch, int fromIndex)
int lastIndexOf(int ch)
int lastIndexOf(int ch, int fromIndex)
int indexOf(String str)
int indexOf(String str, int fromIndex)
int lastIndexOf(String str)
int lastIndexOf(String str,int fromIndex)


Methods for testing

boolean startsWith(String prefix, int toffset)
boolean startsWith(String prefix)
boolean endsWith(String suffix)
boolean equalsIgnoreCase(String anotherString)

Methods for accessing

String substring(int beginIndex)
String substring(int beginIndex, int endIndex)
char charAt(int index)
public char[] toCharArray()


Color

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.



Componenet

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.

Buttons

Setting or Getting the Button's Contents
Method or Constructor Purpose
JButton(String, Icon)
JButton(String)
JButton(Icon)
JButton()
Create a JButton instance, initializing it to have the specified text/image.
void setText(String)
String getText()
Set or get the text displayed by the button.
void setIcon(Icon)
Icon getIcon()
Set or get the image displayed by the button when the button isn't selected or pressed.
void setDisabledIcon(Icon)
Icon getDisabledIcon()
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)
Icon getPressedIcon()
Set or get the image displayed by the button when it's being pressed.
void setSelectedIcon(Icon)
Icon getSelectedIcon()
void setDisabledSelectedIcon(Icon)
Icon getDisabledSelectedIcon()
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)
boolean getRolloverEnabled()
void setRolloverIcon(Icon)
Icon getRolloverIcon()
void setRolloverSelectedIcon(Icon)
Icon getRolloverSelectedIcon()
Use setRolloverEnabled(true) and setRolloverIcon(someIcon) to make the button display the specified icon when the cursor passes over it.

Fine Tuning the Button's Appearance
Method or Constructor Purpose
void setHorizontalAlignment(int)
void setVerticalAlignment(int)
int getHorizontalAlignment()
int getVerticalAlignment()
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)
void setVerticalTextPosition(int)
int getHorizontalTextPosition()
int getVerticalTextPosition()
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.

Implementing the Button's Functionality
Method or Constructor Purpose
void setActionCommand(String)
String getActionCommand(void)
Set or get the name of the action performed by the button.
void addActionListener(ActionListener)
ActionListener removeActionListener()
Add or remove an object that listens for action events fired by the button.

JLabel

Setting or Getting the Label's Contents
Method or Constructor Purpose
JLabel(Icon)
JLabel(Icon, int)
JLabel(String)
JLabel(String, Icon, int)
JLabel(String, int)
JLabel()
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 SwingConstants(in the API reference documentation) interface (which JLabel implements): LEFT, CENTER, RIGHT, LEADING, or TRAILING.
void setText(String)
String getText()
Set or get the text displayed by the label.
void setIcon(Icon)
Icon getIcon()
Set or get the image displayed by the label.

Fine Tuning the Label's Appearance
Method Purpose
void setHorizontalAlignment(int)
void setVerticalAlignment(int)
int getHorizontalAlignment()
int getVerticalAlignment()
Set or get where in the label its contents should be placed. The SwingConstants(in the API reference documentation) interface defines five possible values for horizontal alignment: LEFT (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)
void setVerticalTextPosition(int)
int getHorizontalTextPosition()
int getVerticalTextPosition()
Set or get where the button's text should be placed, relative to the button's image. The SwingConstants(in the API reference documentation) interface defines three possible values for horizontal position: LEFT, CENTER, and RIGHT (the default). For vertical position: TOP, CENTER (the default), and BOTTOM.

JPanel

Creating a JPanel
Constructor Purpose
JPanel()
JPanel(LayoutManager)
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.

Managing a Container's Components
Method Purpose
void add(Component)
void add(Component, int)
void add(Component, Object)
void add(Component, Object, int)
void add(String, 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)
Component getComponentAt(int, int)
Component getComponentAt(Point)
Component[] getComponents()
Get the specified component or components. You can get a component based on its index or x, y position.
void remove(Component)
void remove(int)
void removeAll()
Remove the specified component(s).

Setting/Getting the Layout Manager
Method Purpose
void setLayout(LayoutManager)
LayoutManager getLayout()
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.


FlowLayout

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.

BorderLayout

Method or Constructor Purpose
BorderLayout(), BorderLayout(int horizontalGap, int verticalGap) Constructs a border layout with the specified gaps between components. The default is 0.

GridLayout

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.

ActionEvent

Method or Constructor Purpose
Object getSource() The object on which the Event initially occurred.
String getActionCommand() Returns the command string associated with this action.

Integer.parseInt(String s) : return the integer represents by the String s.
Double.parseDouble(String s) : return the double represents by the String s.