applet
TRANSCRIPT
Event Source Interface Method of Listener
Interface Constructor Methods
1. Label - -
Label() Label(String str) Label(String str,Int
how)IntHow=Label.LEFT,Label.RIGHT,Label.CENTER
void setText(String str)String getText()void setAlignment(int how)int getAlignment()
2. ButtonAction Listener
void actionPerformed(ActionEvent ae)
Button() Button(String str)
void setLabel(String str)String getLabel()String getActionCommand()
3. TextField
Action Listener
void actionPerformed(ActionEvent ae)
TextField() TextField(int
numChar) TextField(String str); TextField(String
str,int numChars);
String getText()void setText(String str)String getSelectedText()void select(int startIndex,int endIndex)Boolean isEditable()Void setEditable(Boolean canEdit)void setEchoChar(char ch)Boolean echoCharIsSet()Char getEchoChar()
4. TextArea
Action Listener
void actionPerformed(ActionEvent ae)
TextArea() TextArea(int numLines,
int numChars) TextArea(String str) TextArea(String str,int
numLines,int numChars) TextArea(String str,int
numLines,int numChars,int sBars)
numLines-HeightnumChar-Width
String getText()void setText(String str)String getSelectedText()void select(int startIndex,int endIndex)Boolean isEditable()Void setEditable(Boolean canEdit)void append(String str)void insert(String str,int index)void replaceRange(String str,int
Prepared By-Mayank Chauhan Page 1 of 5
startIndex,int endIndex)
5. Choice
Item Listener
void itemStateChanged(ItemEvent ie)
Choice() String getSelectedItem()Int getSelectedIndex()int getItemCount()void select(int index)void select(String name)String getItem(int index)
6. List
Action Listener
void actionPerformed(ActionEvent ae)
List() List(int numRows) List(int numRows,
Boolean multipleSelect)
String getSelectedItem()int getSelectedIndex()String[] getSelectedItems()int[] getSelectedIndexes()int getItemCount()void select(int index)String getItem(int Index)getStateChanged()getItemSelectable()
7. Checkbox
Item Listener
void itemStateChanged(ItemEvent ie)
Checkbox() Checkbox(String str) Checkbox(String str,
boolean on) Checkbox(String str,
CheckboxGroup cbGroup, Boolean on)
Boolean getState()void setState(Boolean on)String getLabel()Void setLabel(String str)
8. CheckboxGroup
Item Listener
void itemStateChanged(ItemEvent ie)
CheckboxGroup() checkbox getSelectedCheckbox()void setSelectedCheckbox(Checkbox which)
Prepared By-Mayank Chauhan Page 2 of 5
The ActionListener InterfaceThis interface defines the actionPerformed( ) method that is invoked when an action event occurs. Its general form is shown here:
void actionPerformed(ActionEvent ae)
The ItemListener InterfaceThis interface defines the itemStateChanged( ) method that is invoked when the state of an item changes. Its general form is shown here:
void itemStateChanged(ItemEvent ie)
Prepared By-Mayank Chauhan Page 3 of 5
Simple Applet Display Methods1. void drawString(String message, int x, int
y)2. void setBackground(Color newColor)3. void setForeground(Color newColor)
Color.black Color.magentaColor.blue Color.orangeColor.cyan Color.pinkColor.darkGray Color.redColor.gray Color.whiteColor.green Color.yellowColor.lightGray
The KeyListener Interface
This interface defines three methods. The keyPressed( ) and keyReleased( ) methods are invoked when a key is pressed and released, respectively. The keyTyped( ) method is invoked when a character has been entered.For example, if a user presses and releases the A key, three events are generated in sequence: key pressed, typed, and released. If a user presses and releases the HOME key, two key events are generated in sequence: key pressed and released.The general forms of these methods are shown here:
void keyPressed(KeyEvent ke)void keyReleased(KeyEvent ke)void keyTyped(KeyEvent ke)
The MouseListener Interface
This interface defines five methods. If the mouse is pressed and released at the same point, mouseClicked( ) is invoked. When the mouse enters a component, the mouseEntered( ) method is called. When it leaves, mouseExited( ) is called. The mousePressed( ) and mouseReleased( ) methods are invoked when the mouse is pressed and released, respectively.
The general forms of these methods are shown here:
void mouseClicked(MouseEvent me)void mouseEntered(MouseEvent me)void mouseExited(MouseEvent me)
Prepared By-Mayank Chauhan Page 4 of 5