/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
/*
 * ejercicio5.java
 * Createdon 14/09/2011, 04:12:35 PM
 */
package clase2metodologia;
/**
 *
 * @author Alumno
 */
publicclass ejercicio5 extendsjavax.swing.JFrame {
   /** Creates new form ejercicio5 */
public ejercicio5() {
initComponents();
   }
   /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
@SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jbtnnuevo = new javax.swing.JButton();
jbtncalcular = new javax.swing.JButton();
jbtnsalir = new javax.swing.JButton();
jtxthora = new javax.swing.JTextField();
jtxtsegundo = new javax.swing.JTextField();
      jtxtminuto2 = new javax.swing.JTextField();
      jtxtsegundo2 = new javax.swing.JTextField();
jtxtminuto = new javax.swing.JTextField();
      jtxthora2 = new javax.swing.JTextField();
      jLabel1 = new javax.swing.JLabel();
      jLabel2 = new javax.swing.JLabel();
      jLabel3 = new javax.swing.JLabel();
      jLabel4 = new javax.swing.JLabel();
      jLabel5 = new javax.swing.JLabel();
      jLabel6 = new javax.swing.JLabel();
      jLabel7 = new javax.swing.JLabel();
jtxtdia = new javax.swing.JTextField();
jtxtminutos = new javax.swing.JTextField();
jtxthoras = new javax.swing.JTextField();
jtxtsegundos = new javax.swing.JTextField();
      jLabel8 = new javax.swing.JLabel();
      jLabel9 = new javax.swing.JLabel();
      jLabel10 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jbtnnuevo.setText("NUEVO");
jbtnnuevo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jbtnnuevoActionPerformed(evt);
         }
     });
jbtncalcular.setText("CALCULAR");
jbtncalcular.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jbtncalcularActionPerformed(evt);
         }
     });
jbtnsalir.setText("SALIR");
jbtnsalir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jbtnsalirActionPerformed(evt);
         }
     });
jtxthora.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jtxthoraActionPerformed(evt);
         }
     });
jtxtsegundo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jtxtsegundoActionPerformed(evt);
         }
     });
jtxtsegundo2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jtxtsegundo2ActionPerformed(evt);
         }
     });
jLabel1.setText("TIEMPO 1");
jLabel2.setText("TIEMPO 2");
jLabel3.setText("SUMA DE TIEMPOS");
jLabel4.setText("DIA");
jLabel5.setText("HORA");
jLabel6.setText("MINUTOS");
jLabel7.setText("SEGUNDOS");
jtxthoras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jtxthorasActionPerformed(evt);
         }
     });
jtxtsegundos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEventevt) {
jtxtsegundosActionPerformed(evt);
         }
     });
jLabel8.setText("MINUTOS");
jLabel9.setText("SEGUNDOS");
jLabel10.setText("HORA");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
       .addGroup(layout.createSequentialGroup()
         .addGap(160, 160, 160)
         .addComponent(jLabel10)
         .addGap(31, 31, 31)
         .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(10, 10, 10)
         .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
         .addGap(60, 60, 60)
         .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(30, 30, 30)
         .addComponent(jtxthora, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(20, 20, 20)
         .addComponent(jtxtminuto, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(20, 20, 20)
         .addComponent(jtxtsegundo, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
         .addGap(60, 60, 60)
         .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(40, 40, 40)
         .addComponent(jtxthora2, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(20, 20, 20)
         .addComponent(jtxtminuto2, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(20, 20, 20)
         .addComponent(jtxtsegundo2, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
         .addGap(50, 50, 50)
         .addComponent(jbtnnuevo)
         .addGap(33, 33, 33)
         .addComponent(jbtncalcular, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(20, 20, 20)
         .addComponent(jbtnsalir))
       .addGroup(layout.createSequentialGroup()
         .addGap(50, 50, 50)
         .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
         .addGap(60, 60, 60)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(40, 40, 40)
         .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(30, 30, 30)
         .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(4, 4, 4)
         .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
       .addGroup(layout.createSequentialGroup()
         .addGap(50, 50, 50)
         .addComponent(jtxtdia, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(40, 40, 40)
         .addComponent(jtxthoras, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(40, 40, 40)
         .addComponent(jtxtminutos, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
         .addGap(30, 30, 30)
         .addComponent(jtxtsegundos, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
    );
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
       .addGroup(layout.createSequentialGroup()
         .addGap(10, 10, 10)
         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jLabel10)
           .addComponent(jLabel8)
           .addComponent(jLabel9))
         .addGap(16, 16, 16)
         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jLabel1)
           .addComponent(jtxthora, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
           .addComponent(jtxtminuto, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
           .addComponent(jtxtsegundo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
         .addGap(10, 10, 10)
         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jLabel2)
           .addComponent(jtxthora2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
           .addComponent(jtxtminuto2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
           .addComponent(jtxtsegundo2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
         .addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbtnnuevo)
             .addComponent(jbtncalcular)
             .addComponent(jbtnsalir))
.addGap(17, 17, 17)
           .addComponent(jLabel3)
           .addGap(16, 16, 16)
           .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addComponent(jLabel4)
             .addComponent(jLabel5)
             .addComponent(jLabel6)
             .addComponent(jLabel7))
           .addGap(16, 16, 16)
           .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addComponent(jtxtdia, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addComponent(jtxthoras, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addComponent(jtxtminutos, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
             .addComponent(jtxtsegundos, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
      );
pack();
   }// </editor-fold>
private void jtxthoraActionPerformed(java.awt.event.ActionEventevt) {
      // TODO add your handling code here:
   }
private void jtxtsegundoActionPerformed(java.awt.event.ActionEventevt) {
      // TODO add your handling code here:
   }
private void jtxtsegundo2ActionPerformed(java.awt.event.ActionEventevt) {
      // TODO add your handling code here:
   }
private void jbtnnuevoActionPerformed(java.awt.event.ActionEventevt) {
jtxtminuto.setText(null);
jtxtsegundo.setText("");
jtxthora2.setText(null);
jtxtminuto2.setText(null);
jtxtsegundo2.setText(null);
jtxtdia.setText(null);
jtxthoras.setText(null);
jtxtminutos.setText(null);
jtxtsegundos.setText(null);
jbtnnuevo.requestFocus();
     // TODO add your handling code here:
   }
private void jtxthorasActionPerformed(java.awt.event.ActionEventevt) {
      // TODO add your handling code here:
   }
private void jtxtsegundosActionPerformed(java.awt.event.ActionEventevt) {
      // TODO add your handling code here:
}
private void jbtncalcularActionPerformed(java.awt.event.ActionEventevt) {
int h1, m1, s1, h2, m2, s2, dt,th, tm, ts, ma, ha, da;
       h1=Integer.parseInt(jtxthora.getText());
     m1=Integer.parseInt(jtxtminuto.getText());
     s1=Integer.parseInt(jtxtsegundo.getText());
     h2=Integer.parseInt(jtxthora2.getText());
     m2=Integer.parseInt(jtxtminuto2.getText());
     s2=Integer.parseInt(jtxtsegundo2.getText());
ts=(s1+s2)%60;
ma=(s1+s2)/60;
tm=(m1+m2+ma)%60;
ha=(m1+m2+ma)/60;
th=(h1+h2+ha)%24;
da=(h1+h2+ha)/24;
dt=da;
jtxtdia.setText(String.valueOf(dt));
jtxthoras.setText(String.valueOf(th));
jtxtminutos.setText(String.valueOf(tm));
jtxtsegundos.setText(String.valueOf(ts));
jbtnnuevo.requestFocus();
        }
private void jbtnsalirActionPerformed(java.awt.event.ActionEventevt) {
System.exit(0);      // TODO add your handling code here:
   }

  /**
  * @paramargs the command line arguments
  */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ejercicio5().setVisible(true);
         }
     });
  }
  // Variables declaration - do not modify
privatejavax.swing.JLabel jLabel1;
privatejavax.swing.JLabel jLabel10;
privatejavax.swing.JLabel jLabel2;
privatejavax.swing.JLabel jLabel3;
privatejavax.swing.JLabel jLabel4;
privatejavax.swing.JLabel jLabel5;
privatejavax.swing.JLabel jLabel6;
privatejavax.swing.JLabel jLabel7;
privatejavax.swing.JLabel jLabel8;
privatejavax.swing.JLabel jLabel9;
privatejavax.swing.JButtonjbtncalcular;
privatejavax.swing.JButtonjbtnnuevo;
privatejavax.swing.JButtonjbtnsalir;
privatejavax.swing.JTextFieldjtxtdia;
privatejavax.swing.JTextFieldjtxthora;
privatejavax.swing.JTextField jtxthora2;
privatejavax.swing.JTextFieldjtxthoras;
privatejavax.swing.JTextFieldjtxtminuto;
privatejavax.swing.JTextField jtxtminuto2;
privatejavax.swing.JTextFieldjtxtminutos;
privatejavax.swing.JTextFieldjtxtsegundo;
privatejavax.swing.JTextField jtxtsegundo2;
privatejavax.swing.JTextFieldjtxtsegundos;
  // End of variables declaration
}

To change this template

  • 1.
    /* * Tochange this template, choose Tools | Templates * and open the template in the editor. */ /* * ejercicio5.java * Createdon 14/09/2011, 04:12:35 PM */ package clase2metodologia; /** * * @author Alumno */ publicclass ejercicio5 extendsjavax.swing.JFrame { /** Creates new form ejercicio5 */ public ejercicio5() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jbtnnuevo = new javax.swing.JButton(); jbtncalcular = new javax.swing.JButton(); jbtnsalir = new javax.swing.JButton(); jtxthora = new javax.swing.JTextField(); jtxtsegundo = new javax.swing.JTextField(); jtxtminuto2 = new javax.swing.JTextField(); jtxtsegundo2 = new javax.swing.JTextField(); jtxtminuto = new javax.swing.JTextField(); jtxthora2 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jtxtdia = new javax.swing.JTextField(); jtxtminutos = new javax.swing.JTextField(); jtxthoras = new javax.swing.JTextField(); jtxtsegundos = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jbtnnuevo.setText("NUEVO"); jbtnnuevo.addActionListener(new java.awt.event.ActionListener() {
  • 2.
    public void actionPerformed(java.awt.event.ActionEventevt){ jbtnnuevoActionPerformed(evt); } }); jbtncalcular.setText("CALCULAR"); jbtncalcular.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jbtncalcularActionPerformed(evt); } }); jbtnsalir.setText("SALIR"); jbtnsalir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jbtnsalirActionPerformed(evt); } }); jtxthora.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jtxthoraActionPerformed(evt); } }); jtxtsegundo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jtxtsegundoActionPerformed(evt); } }); jtxtsegundo2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jtxtsegundo2ActionPerformed(evt); } }); jLabel1.setText("TIEMPO 1"); jLabel2.setText("TIEMPO 2"); jLabel3.setText("SUMA DE TIEMPOS"); jLabel4.setText("DIA"); jLabel5.setText("HORA"); jLabel6.setText("MINUTOS"); jLabel7.setText("SEGUNDOS"); jtxthoras.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jtxthorasActionPerformed(evt); } }); jtxtsegundos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { jtxtsegundosActionPerformed(evt); } }); jLabel8.setText("MINUTOS"); jLabel9.setText("SEGUNDOS"); jLabel10.setText("HORA"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  • 3.
    getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(160, 160, 160) .addComponent(jLabel10) .addGap(31, 31, 31) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10) .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(60, 60, 60) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jtxthora, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jtxtminuto, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jtxtsegundo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(60, 60, 60) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(40, 40, 40) .addComponent(jtxthora2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jtxtminuto2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jtxtsegundo2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(50, 50, 50) .addComponent(jbtnnuevo) .addGap(33, 33, 33) .addComponent(jbtncalcular, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jbtnsalir)) .addGroup(layout.createSequentialGroup() .addGap(50, 50, 50) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(60, 60, 60)
  • 4.
    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(40, 40, 40) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(4, 4, 4) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(50, 50, 50) .addComponent(jtxtdia, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(40, 40, 40) .addComponent(jtxthoras, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(40, 40, 40) .addComponent(jtxtminutos, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jtxtsegundos, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10) .addComponent(jLabel8) .addComponent(jLabel9)) .addGap(16, 16, 16) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jtxthora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtminuto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtsegundo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jtxthora2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtminuto2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtsegundo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(20, 20, 20)
  • 5.
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jbtnnuevo) .addComponent(jbtncalcular) .addComponent(jbtnsalir)) .addGap(17, 17, 17) .addComponent(jLabel3) .addGap(16, 16, 16) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(jLabel5) .addComponent(jLabel6) .addComponent(jLabel7)) .addGap(16, 16, 16) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jtxtdia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxthoras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtminutos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtsegundos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) ); pack(); }// </editor-fold> private void jtxthoraActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void jtxtsegundoActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void jtxtsegundo2ActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void jbtnnuevoActionPerformed(java.awt.event.ActionEventevt) { jtxtminuto.setText(null); jtxtsegundo.setText(""); jtxthora2.setText(null); jtxtminuto2.setText(null); jtxtsegundo2.setText(null); jtxtdia.setText(null); jtxthoras.setText(null); jtxtminutos.setText(null); jtxtsegundos.setText(null); jbtnnuevo.requestFocus(); // TODO add your handling code here: } private void jtxthorasActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void jtxtsegundosActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here:
  • 6.
    } private void jbtncalcularActionPerformed(java.awt.event.ActionEventevt){ int h1, m1, s1, h2, m2, s2, dt,th, tm, ts, ma, ha, da; h1=Integer.parseInt(jtxthora.getText()); m1=Integer.parseInt(jtxtminuto.getText()); s1=Integer.parseInt(jtxtsegundo.getText()); h2=Integer.parseInt(jtxthora2.getText()); m2=Integer.parseInt(jtxtminuto2.getText()); s2=Integer.parseInt(jtxtsegundo2.getText()); ts=(s1+s2)%60; ma=(s1+s2)/60; tm=(m1+m2+ma)%60; ha=(m1+m2+ma)/60; th=(h1+h2+ha)%24; da=(h1+h2+ha)/24; dt=da; jtxtdia.setText(String.valueOf(dt)); jtxthoras.setText(String.valueOf(th)); jtxtminutos.setText(String.valueOf(tm)); jtxtsegundos.setText(String.valueOf(ts)); jbtnnuevo.requestFocus(); } private void jbtnsalirActionPerformed(java.awt.event.ActionEventevt) { System.exit(0); // TODO add your handling code here: } /** * @paramargs the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ejercicio5().setVisible(true); } }); } // Variables declaration - do not modify privatejavax.swing.JLabel jLabel1; privatejavax.swing.JLabel jLabel10; privatejavax.swing.JLabel jLabel2; privatejavax.swing.JLabel jLabel3; privatejavax.swing.JLabel jLabel4; privatejavax.swing.JLabel jLabel5; privatejavax.swing.JLabel jLabel6; privatejavax.swing.JLabel jLabel7; privatejavax.swing.JLabel jLabel8; privatejavax.swing.JLabel jLabel9; privatejavax.swing.JButtonjbtncalcular; privatejavax.swing.JButtonjbtnnuevo; privatejavax.swing.JButtonjbtnsalir; privatejavax.swing.JTextFieldjtxtdia; privatejavax.swing.JTextFieldjtxthora;
  • 7.