Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rh_exam;

import javax.swing.JOptionPane;

/**
*
* @author BigBoss
*/
public class frmPantalla extends javax.swing.JFrame {

private void fn_calcularSalario()


{
int mNumero1 = Integer.parseInt (txtHoras.getText());
int mNumero2 = Integer.parseInt(txtHorasAdicionales.getText());
int mNumero3 = Integer.parseInt(txtPrecioPorHora.getText());
int mResultado=((mNumero1+mNumero2)*mNumero3);

JOptionPane.showMessageDialog(null, mResultado);

/**
* Creates new form frmPantalla
*/
public frmPantalla() {
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() {

jDialog1 = new javax.swing.JDialog();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtHoras = new javax.swing.JTextField();
txtHorasAdicionales = new javax.swing.JTextField();
txtPrecioPorHora = new javax.swing.JTextField();
btnCalcularSalario = new javax.swing.JButton();

javax.swing.GroupLayout jDialog1Layout = new


javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(

jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(

jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Horas trabajadas:");

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel2.setText("Horas adicionales:");

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel3.setText("Precio por hora:");

txtHoras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtHorasActionPerformed(evt);
}
});

btnCalcularSalario.setText("CALCULAR");
btnCalcularSalario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCalcularSalarioActionPerformed(evt);
}
});

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(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING, false)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELAT
ED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Al
ignment.LEADING, false)
.addComponent(txtHoras)
.addComponent(txtHorasAdicionales)
.addComponent(txtPrecioPorHora,
javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE))
.addComponent(btnCalcularSalario,
javax.swing.GroupLayout.PREFERRED_SIZE, 158,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(130, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel1)
.addComponent(txtHoras, javax.swing.GroupLayout.PREFERRED_SIZE,
28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING)
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup()
.addComponent(txtHorasAdicionales,
javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING)
.addComponent(jLabel3)
.addComponent(txtPrecioPorHora,
javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(59, 59, 59)
.addComponent(btnCalcularSalario,
javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(57, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void txtHorasActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:


}

private void btnCalcularSalarioActionPerformed(java.awt.event.ActionEvent evt)


{
fn_calcularSalario();

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* 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(frmPantalla.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(frmPantalla.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(frmPantalla.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(frmPantalla.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmPantalla().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton btnCalcularSalario;
private javax.swing.JDialog jDialog1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField txtHoras;
private javax.swing.JTextField txtHorasAdicionales;
private javax.swing.JTextField txtPrecioPorHora;
// End of variables declaration
}

You might also like