intermediate/ButtonListenerExample

From ggc

Jump to: navigation, search

01 package intermediate;
02 
03 import javax.swing.*;
04 import java.awt.*;
05 import java.awt.event.*;
06 
07 /**
08  * All about my applet.
09  @author My Name Here
10  */
11 public class ButtonListenerExample extends JApplet
12 {
13   private JButton button;
14 
15   class ButtonResponder implements ActionListener
16   {
17     int clicked=0;
18 
19     public void actionPerformed(ActionEvent e)
20     {
21       clicked++;
22       button.setText("Clicked: "+clicked);
23     }
24   }
25 
26   public void init()
27   {}
28 
29   public void start()
30   {
31     button=new JButton("Not yet clicked.");
32     getContentPane().add(button);
33     button.addActionListener(new ButtonResponder());
34   }
35 
36   public void stop()
37   {}
38 }


Download/View intermediate/ButtonListenerExample.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter