Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: Anonymous inner class

Java:  Anonymous inner class
{filelink=11050}

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ClasseMyInnereAnonymouse extends JFrame
 {
  public ClasseMyInnereAnonymouse()
  {
    setSize(300, 200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    JButton msg = new JButton("cliquez ici");
    add(msg);
    // Using Anonymous inner classe
   msg.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent event)
       {
        JOptionPane.showMessageDialog(null,"Welcom to my anonymouse inner class");
      }
    });
  }
  public static void main(String[] args)
  	{
         new ClasseMyInnereAnonymouse();
    }
}

No comments yet.

Leave a Comment