- import java.awt.*; 
- import java.text.DateFormat; 
- import java.util.Timer; 
- import java.util.GregorianCalendar; 
- import java.util.Calendar; 
- import java.util.*; 
- import javax.swing.*; 
- import java.awt.*; 
- import java.awt.event.*; 
- import java.io.*; 
- import javax.swing.*; 
-   
- public class RelojModeloSwing extends JFrame { 
-   
-    DateFormat df; 
-    JLabel timeLabel; 
-    Timer timer; 
-    JLabel veri; 
-    JTextField Desp; 
-    String c2; 
-    public RelojModeloSwing() { 
-     setTitle("Reloj xD"); 
-     initComponents(); 
-     setSize(500,500); 
-    } 
-      
-     public void initComponents(){ 
-       getContentPane().setLayout(null); 
-       df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); 
-       timer = new Timer(); 
-       timer.schedule(new DoTick(), 0, 1000);   
-       timeLabel = new JLabel("", JLabel.CENTER); 
-       veri = new JLabel(); 
-       Desp=new JTextField("Sun Dec 21 12:48:03 CET 2008");//Intentar con el LABEL.......xD 
-      
-       timeLabel.setBounds(100,70,200,100); 
-       getContentPane().add(timeLabel); 
-      JMenu Despertador=new JMenu("Despertador"); 
-      JMenuItem activar=new JMenuItem("Activar"); 
-      Despertador.add(activar); 
-      activar.addActionListener(new ActionListener(){ 
-       
-         public void actionPerformed(ActionEvent e){ //Accion del boton DEspertador-Activar 
-          
-         final String rec=Desp.getText();   //Se supone que al dar click jala los 2 valores 
-       Date xd=new Date();                 // y deberia cerrar la aplicacion cuando los 2 son iguales.. 
-       String hor= xd.toString();       //Pero bueno no pasa nada........ 
-       timeLabel.setText(hor); 
-       veri.setText(rec); 
-       String c1=timeLabel.getText(); 
-       String c2=veri.getText(); 
-         System.out.println(c1); 
-         System.out.println(c2); 
-          
-         if(c1==c2){ 
-             System.exit(0); 
-             }else{} 
-        
-              
-         } 
-      }); 
-      JMenu pais=new JMenu("Pais"); 
-      Desp.setBounds(50,150,100,50); 
-      getContentPane().add(Desp); 
-      JTextField NH=new JTextField("12:00:00"); 
-      NH.setBounds(200,150,100,50); 
-      getContentPane().add(NH); 
-       
-     JMenuBar barra = new JMenuBar();   
-         setJMenuBar( barra );   
-             barra.add(Despertador);   
-             barra.add(pais);             
-    } 
-     
-     
-    class DoTick extends TimerTask { 
-                 
-       public void run() { 
-       Date xd=new Date(); 
-       String hor= xd.toString(); 
-       timeLabel.setText(hor); 
-       String c1=timeLabel.getText(); 
-         System.out.println(c1); //Las imprime en Sistema  y si salen los 2...  
-         System.out.println(c2); // Esta es la del despertador....... 
-          
-          
-          
-         if(c1==c2){     ///////////Esta es la condicion de prueba se supone que debe de 
-             System.exit(0); //Cerrarse la aplicacion cuando la hora y la del despetador son iguales.... 
-             }else{}  //Pero no pasa nada............  
-        
-       } 
-   } 
-    
-    
-      
-      
-    public static void main(String[] args) { 
-       RelojModeloSwing t = new RelojModeloSwing(); 
-       t.setVisible(true); 
-    } 
- } 
-