EJERCICIOS Jcombobox
EJERCICIOS Jcombobox
*/
package aplicaciones;
import javax.swing.*;
/**
* @author Misan;
*/
initComponents();
lstCurOfer.setModel(modelo1);
lstCostos.setModel(modelo2);
lstCurEsco.setModel(modelo3);
lstCos.setModel(modelo4);
btnAgregar.setEnabled(false);
btnEliminar.setEnabled(false);
setSize (450,400);
setLocation (250,250);
/**
* 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
*/
@SuppressWarnings("unchecked")
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setText("ALUMNO :");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 20, -
1, -1));
txtAlu.addActionListener(new java.awt.event.ActionListener() {
txtAluActionPerformed(evt);
});
jLabel2.setText("Categoria de Cursos:");
cboCategorias.addActionListener(new java.awt.event.ActionListener() {
cboCategoriasActionPerformed(evt);
});
getContentPane().add(cboCategorias, new
org.netbeans.lib.awtextra.AbsoluteConstraints(170, 50, -1, -1));
jLabel3.setText("Cursos Ofertados");
jLabel4.setText("costo");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 80,
60, -1));
jLabel5.setText("Cursos Escojidos");
jLabel6.setText("costo");
lstCurOfer.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
lstCurOferValueChanged(evt);
});
jScrollPane1.setViewportView(lstCurOfer);
jScrollPane2.setViewportView(lstCostos);
lstCurEsco.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
lstCurEscoValueChanged(evt);
});
jScrollPane3.setViewportView(lstCurEsco);
jScrollPane4.setViewportView(lstCos);
btnAgregar.setText("Agregar");
btnAgregar.addActionListener(new java.awt.event.ActionListener() {
btnAgregarActionPerformed(evt);
});
btnEliminar.setText("Eliminar");
btnEliminar.addActionListener(new java.awt.event.ActionListener() {
btnEliminarActionPerformed(evt);
});
jLabel7.setText("Forma de Pago:");
cboFPago.addActionListener(new java.awt.event.ActionListener() {
cboFPagoActionPerformed(evt);
});
btnCalcular.setText("CALCULAR");
btnCalcular.addActionListener(new java.awt.event.ActionListener() {
btnCalcularActionPerformed(evt);
});
btnBorrar.setText("BORRAR");
btnBorrar.addActionListener(new java.awt.event.ActionListener() {
btnBorrarActionPerformed(evt);
});
btnCerrar.setText("CERRAR");
btnCerrar.addActionListener(new java.awt.event.ActionListener() {
btnCerrarActionPerformed(evt);
});
jLabel8.setText("Matricula");
jLabel9.setText("Costo Total");
jLabel10.setText("Pago Mensual");
txtCTotal.addActionListener(new java.awt.event.ActionListener() {
txtCTotalActionPerformed(evt);
});
}// </editor-fold>
modelo3.remove(indice);
modelo4.remove(indice);
btnEliminar.setEnabled(false);
int indice;
indice = cboCategorias.getSelectedIndex();
switch (indice)
case 0 :
modelo1.clear(); modelo2.clear();
break ;
case 1 :
modelo1.clear(); modelo2.clear();
break;
case 2 :
modelo1.clear(); modelo2.clear();
break;
case 3 :
modelo1.clear(); modelo2.clear();
break;
case 4 :
modelo1.clear(); modelo2.clear();
break;
case 5 :
modelo1.clear(); modelo2.clear();
break;
lstCostos.setSelectedIndex(indice);
btnAgregar.setEnabled(true);
lstCostos.setSelectedIndex(indice);
btnEliminar.setEnabled(true);
int total, i;
curso=(String)lstCurOfer.getSelectedValue();
Costo=(String)lstCostos.getSelectedValue();
modelo3.addElement(curso);
modelo4.addElement(Costo);
btnAgregar.setEnabled(false);
ctotal=ctotal+Float.parseFloat((String)modelo4.elementAt(i));
if(ctotal==0)
return;
if(cuenta==1)
mat=ctotal*0.8f;
if(cuenta==2)
mat=ctotal*0.6f;
if(cuenta>=3)
mat=ctotal*0.5f;
if(cboFPago.getSelectedItem().equals("<Seleccionar>"))
return;
ctotal=ctotal*0.9f;
pmen=0;
if (cboFPago.getSelectedItem().equals("Credito"))
{
ctotal=ctotal*1.1f;
JOptionPane.showMessageDialog(null,"Ctotal es "+ctotal);
pmen=ctotal/4;
txtMat.setText(String.valueOf(mat));
txtCTotal.setText(String.valueOf(ctotal));
txtPMen.setText(String.valueOf(pmen));
txtAlu.setText("");
txtMat.setText("");
txtCTotal.setText("");
txtPMen.setText("");
dispose();
/**
*/
//<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.
*/
try {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
java.util.logging.Logger.getLogger(frmCursosExtension.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
java.util.logging.Logger.getLogger(frmCursosExtension.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
java.util.logging.Logger.getLogger(frmCursosExtension.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
java.util.logging.Logger.getLogger(frmCursosExtension.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
new frmCursosExtension().setVisible(true);
});