2
« en: 31 de Marzo 2022, 16:31 »
Hola a todos, me han puesto el siguiente ejercicio y agradecería ayuda.
Realizar un aplicativo por medio de GUI para la liquidación de nómina para estos 3 empleados (deben usar ArrayList):
Código Nombre Salario Base
123 Juan Camilo Pérez $950.000
124 Lina Maria Mejía $2.125.000
125 Carlos Antonio Ruíz $1.750.000
La interfaz gráfica debe ser la siguiente:
Funcionamiento:
• El usuario digita el código del empleado e inmediatamente debe mostrar el nombre del empleado en el label que aparece con el símbolo (?), en caso que no exista el empleado, debe aparecer el mensaje No Existe el empleado. De igual forma debe aparecer el salario base de dicho empleado en el label con el número (0) y mostrar a cuánto equivale el auxilio de transporte en el respectivo label.
Recuerde que un empleado recibe auxilio de transporte si gana menos de 2 salarios mínimos. (Consultar a cuanto equivale el salario mínimo y el auxilio de transporte). En un botón buscar.
• Se debe mostrar el valor que le hacen de deducción en salud y en pensión.
• Al presionar el botón CALCULAR auxilio de transporte, el valor de las deducciones y el total a pagarle al empleado.
public class LiquidacionNomina extends javax.swing.JFrame {
public LiquidacionNomina() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
pnlPrincipal = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jSeparator1 = new javax.swing.JSeparator();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pnlPrincipal.setBackground(new java.awt.Color(102, 204, 255));
pnlPrincipal.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
jLabel1.setText("Liquidación de Nómina");
jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabel2.setText("Código del Empleado");
jButton1.setText("Buscar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabel3.setText("Nombre del Empleado:");
jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabel4.setText("Salario Base:");
jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabel5.setText("Detalle Nómina:");
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel8.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
jLabel8.setText("Auxilio de Transporte:");
jLabel9.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
jLabel9.setText("Deducción Salud (4%):");
jLabel10.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
jLabel10.setText("Deducción Pensión (4%):");
jLabel11.setFont(new java.awt.Font("Times New Roman", 0, 16)); // NOI18N
jLabel11.setText("Salario a Pagar:");
jLabel12.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
jLabel12.setText("0");
jLabel13.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
jLabel13.setText("0");
jLabel14.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
jLabel14.setText("0");
jLabel15.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
jLabel15.setText("0");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel11)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jLabel13)
.addComponent(jLabel14)
.addComponent(jLabel15))
.addContainerGap(389, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(jLabel14))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jLabel15))
.addContainerGap(17, Short.MAX_VALUE))
);
jButton2.setText("Calcular Nómina");
jScrollPane2.setViewportView(jTextPane2);
jSeparator1.setForeground(new java.awt.Color(255, 255, 255));
jSeparator1.setAlignmentX(1.0F);
jSeparator1.setAlignmentY(1.0F);
jLabel6.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
jLabel6.setText("?");
jLabel7.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
jLabel7.setText("0");
javax.swing.GroupLayout pnlPrincipalLayout = new javax.swing.GroupLayout(pnlPrincipal);
pnlPrincipal.setLayout(pnlPrincipalLayout);
pnlPrincipalLayout.setHorizontalGroup(
pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addGap(53, 53, 53)
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jLabel7))
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(jLabel6))
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(29, 29, 29)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jButton1))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addGap(93, 93, 93)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 493, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(57, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPrincipalLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPrincipalLayout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(210, 210, 210))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPrincipalLayout.createSequentialGroup()
.addComponent(jButton2)
.addGap(271, 271, 271))))
);
pnlPrincipalLayout.setVerticalGroup(
pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPrincipalLayout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane2)
.addComponent(jLabel2)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(25, 25, 25)
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel7))
.addGap(46, 46, 46)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addContainerGap(19, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LiquidacionNomina().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JPanel pnlPrincipal;
// End of variables declaration
}