/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lista_clase;
/**
*
* @author cultca
*/
public class Pantalla
extends javax.
swing.
JFrame {
Alumno ptr,ptr1,inicio,ultimo,aux,c;
public Pantalla() {
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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
Nombre =
new javax.
swing.
JLabel(); APELLIDO =
new javax.
swing.
JLabel(); Cedula =
new javax.
swing.
JLabel(); edad =
new javax.
swing.
JLabel(); jLabel5 =
new javax.
swing.
JLabel(); BOTONINGRESAR =
new javax.
swing.
JButton(); BOTONMOSTRAR =
new javax.
swing.
JButton(); jList1 =
new javax.
swing.
JList();
setAlwaysOnTop(true);
setBackground
(new java.
awt.
Color(0,
0,
0)); setCursor
(new java.
awt.
Cursor(java.
awt.
Cursor.
HAND_CURSOR)); setForeground
(java.
awt.
Color.
green); setName("Pantalla"); // NOI18N
Nombre.
setBackground(new java.
awt.
Color(153,
153,
153)); Nombre.
setFont(new java.
awt.
Font("Tunga",
0,
14)); // NOI18N Nombre.
setForeground(new java.
awt.
Color(51,
51,
255)); Nombre.setText("NOMBRE:");
APELLIDO.
setBackground(new java.
awt.
Color(153,
153,
153)); APELLIDO.
setFont(new java.
awt.
Font("Tunga",
0,
14)); // NOI18N APELLIDO.
setForeground(new java.
awt.
Color(0,
0,
255)); APELLIDO.setText("APELLIDO:");
Cedula.
setBackground(new java.
awt.
Color(153,
153,
153)); Cedula.
setFont(new java.
awt.
Font("Tunga",
0,
14)); // NOI18N Cedula.
setForeground(new java.
awt.
Color(0,
0,
255)); Cedula.setText("CEDULA:");
edad.
setBackground(new java.
awt.
Color(153,
153,
153)); edad.
setFont(new java.
awt.
Font("Tunga",
0,
14)); // NOI18N edad.
setForeground(new java.
awt.
Color(0,
0,
255)); edad.setText("EDAD:");
nombre.
setFont(new java.
awt.
Font("Traditional Arabic",
3,
14)); // NOI18N
apellido.
setFont(new java.
awt.
Font("Traditional Arabic",
3,
14)); // NOI18N
CEDULA.
setFont(new java.
awt.
Font("Traditional Arabic",
3,
14)); // NOI18N public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) { CEDULAActionPerformed(evt);
}
});
EDAD.
setFont(new java.
awt.
Font("Traditional Arabic",
3,
14)); // NOI18N public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) { EDADActionPerformed(evt);
}
});
jLabel5.
setFont(new java.
awt.
Font("Times New Roman",
0,
20)); // NOI18N jLabel5.setText("Lista De Clases ");
BOTONINGRESAR.
setBackground(new java.
awt.
Color(102,
102,
102)); BOTONINGRESAR.
setForeground(new java.
awt.
Color(0,
0,
255)); BOTONINGRESAR.setText("INGRESAR");
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) { BOTONINGRESARActionPerformed(evt);
}
});
BOTONMOSTRAR.
setBackground(new java.
awt.
Color(102,
102,
102)); BOTONMOSTRAR.
setForeground(new java.
awt.
Color(51,
51,
255)); BOTONMOSTRAR.setText("MOSTRAR");
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) { BOTONMOSTRARActionPerformed(evt);
}
});
jScrollPane1.setViewportView(jList1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.
addGap(0,
0,
Short.
MAX_VALUE) .addComponent(BOTONMOSTRAR)
.addGap(120, 120, 120))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(BOTONINGRESAR)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(APELLIDO)
.addComponent(Cedula)
.addComponent(edad))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(CEDULA, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(EDAD, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(118, 118, 118)
.addComponent(jLabel5)))
.
addContainerGap(70,
Short.
MAX_VALUE)) );
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.
addComponent(jScrollPane1, javax.
swing.
GroupLayout.
DEFAULT_SIZE,
262,
Short.
MAX_VALUE) .addGap(18, 18, 18)
.addComponent(BOTONMOSTRAR))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(APELLIDO, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CEDULA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Cedula))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(EDAD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(edad))
.addGap(18, 18, 18)
.addComponent(BOTONINGRESAR)
.addGap(19, 19, 19))))
);
pack();
}// </editor-fold>
private void EDADActionPerformed
(java.
awt.
event.
ActionEvent evt
) { // TODO add your handling code here:
}
private void CEDULAActionPerformed
(java.
awt.
event.
ActionEvent evt
) { // TODO add your handling code here:
}
private void BOTONINGRESARActionPerformed
(java.
awt.
event.
ActionEvent evt
) { // TODO add your handling code here:
if (ptr==null){
ptr=new Alumno();
// esto es para convertir los enteros en string
ptr.
set_cedula(Integer.
parseInt(CEDULA.
getText())); ptr.
set_edad(Integer.
parseInt(EDAD.
getText())); // esto es para borrar los datos en la pantalla
nombre.setText(" ");
apellido.setText(" ");
CEDULA.setText(" ");
EDAD.setText(" ");
ptr1=ptr;
inicio=ptr;
ultimo=ptr;
ultimo.sig=null;
}
else {
ptr=new Alumno();
ptr.set_nombre(nombre.getText());
ptr.set_apellido(apellido.getText());
//esto es para convertir los enteros en string
ptr.
set_cedula(Integer.
parseInt(CEDULA.
getText())); ptr.
set_edad(Integer.
parseInt(EDAD.
getText())); // esto es para borrar los datos de la pantalla
nombre.setText(" ");
apellido.setText(" ");
CEDULA.setText(" ");
EDAD.setText(" ");
ptr1.sig=ptr;
ultimo=ptr;
ultimo.sig=null;
}
}
private void BOTONMOSTRARActionPerformed
(java.
awt.
event.
ActionEvent evt
) { // TODO add your handling code here:
aux=ptr;
int c=0;
while (aux!=null){
System.
out.
println("Nombre : "+aux.
nombre); System.
out.
println("Apellido : "+aux.
apellido); System.
out.
println("Cedula : "+aux.
cedula); System.
out.
println("Edad : "+aux.
edad); c++;
}
if (c==0){
System.
out.
println("LISTA VACIA"); }
}
/**
* @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 {
if ("Nimbus".equals(info.getName())) {
javax.
swing.
UIManager.
setLookAndFeel(info.
getClassName()); break;
}
}
java.
util.
logging.
Logger.
getLogger(Pantalla.
class.
getName()).
log(java.
util.
logging.
Level.
SEVERE,
null, ex
); java.
util.
logging.
Logger.
getLogger(Pantalla.
class.
getName()).
log(java.
util.
logging.
Level.
SEVERE,
null, ex
); java.
util.
logging.
Logger.
getLogger(Pantalla.
class.
getName()).
log(java.
util.
logging.
Level.
SEVERE,
null, ex
); java.
util.
logging.
Logger.
getLogger(Pantalla.
class.
getName()).
log(java.
util.
logging.
Level.
SEVERE,
null, ex
); }
//</editor-fold>
/* Create and display the form */
public void run() {
new Pantalla().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.
swing.
JLabel APELLIDO
; private javax.
swing.
JButton BOTONINGRESAR
; private javax.
swing.
JButton BOTONMOSTRAR
; private javax.
swing.
JLabel Cedula
; private javax.
swing.
JLabel Nombre
; private javax.
swing.
JLabel edad
; private javax.
swing.
JLabel jLabel5
; private javax.
swing.
JList jList1
; // End of variables declaration
}