Código:
PD: En el switch, solo llega al Case 3, pues como no me funcionaba no quise seguir escribiendo código innecesario. Espero alguien pueda ayudarme, muchas gracias :) package signozod; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import java.util.Calendar; import java.util.GregorianCalendar; public class NewJApplet extends javax.swing.JApplet { /** Initializes the applet NewJApplet */ @Override public void init() { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the applet */ try { java.awt.EventQueue.invokeAndWait(new Runnable() { @Override public void run() { initComponents(); } }); } catch (Exception ex) { } } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jTextField1 = new javax.swing.JTextField(); Btn_Ver = new javax.swing.JButton(); Signo = new javax.swing.JLabel(); Signo2 = new javax.swing.JTextField(); jTextField1.setText("dd/MM/aaaa"); Btn_Ver.setText("jButton1"); Btn_Ver.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn_VerActionPerformed(evt); } }); Signo2.setText("jTextField2"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(121, 121, 121) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(158, 158, 158) .addComponent(Signo)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(139, 139, 139) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(Signo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn_Ver)))) .addContainerGap(133, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(32, 32, 32) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(38, 38, 38) .addComponent(Btn_Ver) .addGap(47, 47, 47) .addComponent(Signo) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Signo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(92, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); }// </editor-fold> private void Btn_VerActionPerformed(java.awt.event.ActionEvent evt) { try { SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); { formateador.setLenient(false); } try { Date fecha = formateador.parse(jTextField1.getText()); } catch (ParseException e) { JOptionPane.showMessageDialog(Btn_Ver, "ERROR: El formato de fecha es erroneo.");} Calendar fecha = Calendar.getInstance(); int dia = fecha.get(Calendar.DAY_OF_MONTH); int mes = fecha.get(Calendar.MONTH); Date AriesI = formateador.parse("21/03/yyyy"); Date AriesF = formateador.parse("20/04/yyyy"); Date TauroI = formateador.parse("21/04/yyyy"); Date TauroF = formateador.parse("21/05/yyyy"); Date GeminisI = formateador.parse("22/05/yyyy"); Date GeminisF = formateador.parse("21/06/yyyy"); Date CancerI = formateador.parse("22/06/yyyy"); Date CancerF = formateador.parse("23/07/yyyy"); Date LeoI = formateador.parse("24/07/yyyy"); Date LeoF = formateador.parse("23/08/yyyy"); Date VirgoI = formateador.parse("24/08/yyyy"); Date VirgoF = formateador.parse("23/09/yyyy"); Date LibraI = formateador.parse("24/09/yyyy"); Date LibraF = formateador.parse("23/10/yyyy"); Date EscorpioI = formateador.parse("24/10/yyyy"); Date EscorpioF = formateador.parse("22/11/yyyy"); Date SagitarioI = formateador.parse("23/11/yyyy"); Date SagitarioF = formateador.parse("21/12/yyyy"); Date CapricornioI = formateador.parse("22/12/yyyy"); Date CapricornioF = formateador.parse("20/01/yyyy"); Date AcuarioI = formateador.parse("21/01/yyyy"); Date AcuarioF = formateador.parse("19/02/yyyy"); Date PiscisI = formateador.parse("20/02/yyyy"); Date PiscisF = formateador.parse("20/03/yyyy"); switch(mes) { case 1: //Case para Aries if (fecha.after(AriesI) && fecha.before(AriesF)) Signo2.setText("Aries"); break; case 2: //Case para Tauro if (fecha.after(TauroI) && fecha.before(TauroF)) Signo2.setText("Tauro"); break; } // TODO add your handling code here: } catch (ParseException ex) { Logger.getLogger(NewJApplet.class.getName()).log(Level.SEVERE, null, ex); } } // Variables declaration - do not modify private javax.swing.JButton Btn_Ver; private javax.swing.JLabel Signo; private javax.swing.JTextField Signo2; private javax.swing.JPanel jPanel1; private javax.swing.JTextField jTextField1; // End of variables declaration }