Announcement

Collapse
No announcement yet.

Inner Class and EventListner

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inner Class and EventListner

    Stampare a schermo il testo indicato con un ritardo fisso.

    event_print
    PHP Code:
    package oggetto;

    import javax.swing.JOptionPane;
    import javax.swing.Timer;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;


    public class 
    event_print {

        static public class 
    event implements ActionListener{

            public 
    eventString in){
                
    text in;
            }

            public 
    void actionPerformed(ActionEvent e) {
                
    System.out.println(text);
            }

            private 
    String text;
        }

        public 
    event_print(int msString in_string){
            
    exec = new Timer(ms,new event(in_string)); // the timer call function actionPerformed in the object of type event
        
    }

        public 
    void start(){
            
    exec.start();
            
    JOptionPane.showMessageDialog(null,"Exit?");
            
    System.exit(0);
        }

        private 
    Timer exec;


    main
    PHP Code:
    import oggetto.event_print;


    public class 
    test {

        public static 
    void main(String[] input){

                new 
    event_print(1000,"ciao mondo").start();

         }


    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia