Monday, October 22, 2012

AWT notes





Hierarchy

ComponentEvent it generates
Button, TextField, List, MenuActionEvent
FrameWindowEvent
Checkbox, Choice, ListItemEvent
ScrollbarAdjustmentEvent
Mouse (hardware)MouseEvent
Keyboard (hardware)KeyEvent



Listener InterfaceComponent
WindowListenerFrame
ActionListenerButton, TextField, List, Menu
ItemListenerCheckbox, Choice, List
AdjustmentListenerScrollbar
MouseListenerMouse (stable)
MouseMotionListenerMouse (moving)
KeyListenerKeyboard
example 
public class ButtonDemo extends Frame implements ActionListener 
{
  public ButtonDemo()
  {
    Button btn = new Button("OK");
    btn.addActionListener(this);
    add(btn);
  }
  public void actionPerformed(ActionEvent e)
  { 
    String str = e.getActionCommand();
  }
}


No comments:

Post a Comment