下面的两个程序,为何第一个不能达到预期的效果,而第二个可以?
   还请各位指点!程序1:
  package swingTimer;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class NakeTimer implements ActionListener{ int count = 0;
Timer timer;

public NakeTimer(){ timer = new Timer(1000,this);
timer.start();

}

    public static void main(String[] args){
     new NakeTimer();
    }
    
    public void actionPerformed(ActionEvent e){
     count++;
     System.out.println(count+"Hello!");
    }
}程序2:
 package swingTimer;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;
public class NakeTimer implements ActionListener{
JFrame f=null;
JLabel label = null;
int count = 0;
Timer timer;

public NakeTimer(){
f=new JFrame();
label = new JLabel();
f.getContentPane().add(label);
f.setSize(200,100);
f.setLocation(300,300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

timer = new Timer(1000,this);
timer.start();

}

    public static void main(String[] args){
     new NakeTimer();
    }
    
    public void actionPerformed(ActionEvent e){
     count++;
     label.setText(count+"Hello!");
    }
}