PROGRAMACIN
ALUMNA: Cynthia Chipantiza
CURSO: Segundo Industrial B
PROGRAMA 1
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ListModel aux;
aux=jMaquinas.getModel();
int ele;
ele=aux.getSize();
if(cuenta<ele){
Object obj;
obj=aux.getElementAt(cuenta);
String p;
jTexto.setText(obj.toString());
}
else{
jTexto.setText("EL ELEMENTO NO EXISTE");
}
++cuenta;
public static void main(String args[]) {
//<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(VentanaPrincipal.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VentanaPrincipal().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.JList jMaquinas;
private javax.swing.JTextField jPosicion;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel jTexto;
// End of variables declaration
int cuenta=0;
}
CAPTURA DEPANTALLA
PROGRAMA2
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//Obtener el texdto a buscar
String m;
m=jTexto.getText();
//Atraves de un ciclo for que empieca en 0 y termine en cantidad
int con=0;
ListModel mod;
mod=jApellidos.getModel();
int cuenta;
cuenta=mod.getSize();
for(int k=0;k<cuenta;++k){
Object o1;
o1=mod.getElementAt(k);
if(m.compareTo(o1.toString())==0){
++con;
}
}
jConteo.setText(m+"Existe"+String.valueOf(con)+"Veces");
CAPTURA DEPANTALLA