KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > awt > event > ActionListener

java.awt.event
Interface ActionListener

All Superinterfaces:
EventListener
All Known Subinterfaces:
Action
All Known Implementing Classes:
AbstractAction, AWTEventMulticaster, BasicDesktopPaneUI.CloseAction, BasicDesktopPaneUI.MaximizeAction, BasicDesktopPaneUI.MinimizeAction, BasicDesktopPaneUI.NavigateAction, BasicDesktopPaneUI.OpenAction, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.UpdateAction, BasicInternalFrameTitlePane.CloseAction, BasicInternalFrameTitlePane.IconifyAction, BasicInternalFrameTitlePane.MaximizeAction, BasicInternalFrameTitlePane.MoveAction, BasicInternalFrameTitlePane.RestoreAction, BasicInternalFrameTitlePane.SizeAction, BasicOptionPaneUI.ButtonActionListener, BasicScrollBarUI.ScrollListener, BasicSliderUI.ActionScroller, BasicSliderUI.ScrollListener, BasicSplitPaneUI.KeyboardDownRightHandler, BasicSplitPaneUI.KeyboardEndHandler, BasicSplitPaneUI.KeyboardHomeHandler, BasicSplitPaneUI.KeyboardResizeToggleHandler, BasicSplitPaneUI.KeyboardUpLeftHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreePageAction, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction, DefaultCellEditor.EditorDelegate, DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction, DefaultTreeCellEditor, DropTarget.DropTargetAutoScroller, FormView, HTMLEditorKit.HTMLTextAction, HTMLEditorKit.InsertHTMLTextAction, JComboBox, List.AccessibleAWTList, MetalFileChooserUI.DirectoryComboBoxAction, StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineAction, TextAction, ToolTipManager.insideTimerAction, ToolTipManager.outsideTimerAction, ToolTipManager.stillInsideTimerAction
See Also:
Top Examples, Source Code, ActionEvent

void actionPerformed(ActionEvent e)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[68]Implement ActionListener
By Anonymous on 2002/10/09 17:09:55  Rate
import java.awt.*; 
 import java.awt.event.*; 
  
  
 public class Example10 extends Frame implements ActionListener  {  
    Dialog d; 
    String name; 
    TextField t; 
     
    public Example10 ( String s )   {  
       super ( s ) ; 
  
  
       setLayout ( null ) ; 
  
  
       d = new Dialog ( this ) ; 
       d.setSize ( 400,100 ) ; 
  
  
       d.setLayout ( new FlowLayout (  )  ) ; 
  
  
       Button b = new Button ( "OK" ) ; 
  
  
       Label l = new Label ( "Name:" ) ; 
  
  
       t = new TextField ( 40 ) ; 
  
  
       d.add ( l ) ; 
       d.add ( t ) ; 
       d.add ( b ) ; 
  
  
       d.show (  ) ; 
  
  
       b.addActionListener ( this ) ; 
     }  
  
  
    public void actionPerformed ( ActionEvent e )   {  
       if  ( e.getActionCommand (  ) .equals ( "OK" )  )   {  
          Graphics g = getGraphics (  ) ; 
  
  
          g.drawString ( t.getText (  ) ,50,50 ) ; 
        }  
     }  
  
  
    public static void main ( String [  ]  args )   {  
       Example10 example10 = new Example10 ( "Dialog Tester" ) ; 
  
  
       example10.setSize ( 200,200 ) ; 
       example10.setVisible ( true ) ; 
     }  
  }  
  
  
 

Popular Tags