RSS
Facebook
G+

Buscador de IntercambioSOS:


Retroceder   Foro de Ayuda IntercambiosvirtualeS > Soporte Sobre: Educación & Entretenimiento > Zona Académica > Programación
Comunidad

Respuesta
 
Herramientas Desplegado
Antiguo 19-may-2011     #1
Pregunta Como copiar valores de un Jlist a otro en Java?

Buen dia chicos
Tengo un programa en el cual se introduce por teclado el nombre del alumno y se selecciona la jornada para matricular.
al dar clic en el boton matricular, coloca el nombre en la lista dependiendo la jornada elegida. si se trata de introducir en blanco o un nombre ya registrado mostrara error.
con el boton retirar debe borrar el nombre de la lista seleccionada.



Mis problemas son los siguientes:
Tengo el boton programado para que elimine de la lista diurna, pero en la nocturna me dice que no seleccione ningun elemento, trate de colocar el mismo codigo, pero eliminaba registros de las dos listas, es decir si queria eliminar uno de la nocturna lo hacia pero a su vez eliminaba uno de la diurna
Necesito borrar el registro dependiendo de la lista seleccionada.
Eliminando valores de la lista diurno




eliminando valores de la lista nocturno


El codigo que tengo es este:
Código PHP:
/*
 * AlumnosnocheydiaView.java
 */

package alumnosnocheydia;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;

/**
 * The application's main frame.
 */
public class AlumnosnocheydiaView extends FrameView {

    public 
AlumnosnocheydiaView(SingleFrameApplication app) {
        
super(app);

        
initComponents();

        
// status bar initialization - message timeout, idle icon and busy animation, etc
        
ResourceMap resourceMap getResourceMap();
        
int messageTimeout resourceMap.getInteger("StatusBar.messageTimeout");
        
messageTimer = new Timer(messageTimeout, new ActionListener() {
            public 
void actionPerformed(ActionEvent e) {
                
statusMessageLabel.setText("");
            }
        });
        
messageTimer.setRepeats(false);
        
int busyAnimationRate resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (
int i 0busyIcons.lengthi++) {
            
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" "]");
        }
        
busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public 
void actionPerformed(ActionEvent e) {
                
busyIconIndex = (busyIconIndex 1) % busyIcons.length;
                
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        
idleIcon resourceMap.getIcon("StatusBar.idleIcon");
        
statusAnimationLabel.setIcon(idleIcon);
        
progressBar.setVisible(false);

        
// connecting action tasks to status bar via TaskMonitor
        
TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        
taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public 
void propertyChange(java.beans.PropertyChangeEvent evt) {
                
String propertyName evt.getPropertyName();
                if (
"started".equals(propertyName)) {
                    if (!
busyIconTimer.isRunning()) {
                        
statusAnimationLabel.setIcon(busyIcons[0]);
                        
busyIconIndex 0;
                        
busyIconTimer.start();
                    }
                    
progressBar.setVisible(true);
                    
progressBar.setIndeterminate(true);
                } else if (
"done".equals(propertyName)) {
                    
busyIconTimer.stop();
                    
statusAnimationLabel.setIcon(idleIcon);
                    
progressBar.setVisible(false);
                    
progressBar.setValue(0);
                } else if (
"message".equals(propertyName)) {
                    
String text = (String)(evt.getNewValue());
                    
statusMessageLabel.setText((text == null) ? "" text);
                    
messageTimer.restart();
                } else if (
"progress".equals(propertyName)) {
                    
int value = (Integer)(evt.getNewValue());
                    
progressBar.setVisible(true);
                    
progressBar.setIndeterminate(false);
                    
progressBar.setValue(value);
                }
            }
        });
    }

    @
Action
    
public void showAboutBox() {
        if (
aboutBox == null) {
            
JFrame mainFrame AlumnosnocheydiaApp.getApplication().getMainFrame();
            
aboutBox = new AlumnosnocheydiaAboutBox(mainFrame);
            
aboutBox.setLocationRelativeTo(mainFrame);
        }
        
AlumnosnocheydiaApp.getApplication().show(aboutBox);
    }

    
/** 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">//GEN-BEGIN:initComponents
    
private void initComponents() {

        
mainPanel = new javax.swing.JPanel();
        
titulonombre = new javax.swing.JLabel();
        
nombre = new javax.swing.JTextField();
        
jnocturno = new javax.swing.JRadioButton();
        
jdiurno = new javax.swing.JRadioButton();
        
matricular = new javax.swing.JButton();
        
cerrar = new javax.swing.JButton();
        
retirar = new javax.swing.JButton();
        
jScrollPane1 = new javax.swing.JScrollPane();
        
listadiurno = new javax.swing.JList();
        
titulolistamañana = new javax.swing.JLabel();
        
titulolistanoche = new javax.swing.JLabel();
        
jScrollPane2 = new javax.swing.JScrollPane();
        
listanocturno = new javax.swing.JList();
        
jLabel1 = new javax.swing.JLabel();
        
jLabel2 = new javax.swing.JLabel();
        
totaldiurno = new javax.swing.JTextField();
        
totalnocturno = new javax.swing.JTextField();
        
copiardiurno = new javax.swing.JButton();
        
copiartododiurno = new javax.swing.JButton();
        
copiarnocturno = new javax.swing.JButton();
        
copiartodonocturno = new javax.swing.JButton();
        
menuBar = new javax.swing.JMenuBar();
        
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        
javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        
javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        
statusPanel = new javax.swing.JPanel();
        
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        
statusMessageLabel = new javax.swing.JLabel();
        
statusAnimationLabel = new javax.swing.JLabel();
        
progressBar = new javax.swing.JProgressBar();

        
mainPanel.setName("mainPanel"); // NOI18N

        
org.jdesktop.application.ResourceMap resourceMap org.jdesktop.application.Application.getInstance(alumnosnocheydia.AlumnosnocheydiaApp.class).getContext().getResourceMap(AlumnosnocheydiaView.class);
        
titulonombre.setFont(resourceMap.getFont("titulonombre.font")); // NOI18N
        
titulonombre.setText(resourceMap.getString("titulonombre.text")); // NOI18N
        
titulonombre.setName("titulonombre"); // NOI18N

        
nombre.setText(resourceMap.getString("nombre.text")); // NOI18N
        
nombre.setName("nombre"); // NOI18N

        
jnocturno.setFont(resourceMap.getFont("jnocturno.font")); // NOI18N
        
jnocturno.setText(resourceMap.getString("jnocturno.text")); // NOI18N
        
jnocturno.setName("jnocturno"); // NOI18N
        
jnocturno.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
jnocturnoActionPerformed(evt);
            }
        });

        
jdiurno.setFont(resourceMap.getFont("jdiurno.font")); // NOI18N
        
jdiurno.setText(resourceMap.getString("jdiurno.text")); // NOI18N
        
jdiurno.setName("jdiurno"); // NOI18N
        
jdiurno.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
jdiurnoActionPerformed(evt);
            }
        });

        
matricular.setFont(resourceMap.getFont("matricular.font")); // NOI18N
        
matricular.setText(resourceMap.getString("matricular.text")); // NOI18N
        
matricular.setName("matricular"); // NOI18N
        
matricular.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
matricularActionPerformed(evt);
            }
        });

        
cerrar.setFont(resourceMap.getFont("cerrar.font")); // NOI18N
        
cerrar.setText(resourceMap.getString("cerrar.text")); // NOI18N
        
cerrar.setName("cerrar"); // NOI18N
        
cerrar.addMouseListener(new java.awt.event.MouseAdapter() {
            public 
void mouseClicked(java.awt.event.MouseEvent evt) {
                
cerrarMouseClicked(evt);
            }
        });

        
retirar.setFont(resourceMap.getFont("retirar.font")); // NOI18N
        
retirar.setText(resourceMap.getString("retirar.text")); // NOI18N
        
retirar.setName("retirar"); // NOI18N
        
retirar.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
retirarActionPerformed(evt);
            }
        });

        
jScrollPane1.setName("jScrollPane1"); // NOI18N

        
listadiurno.setName("listadiurno"); // NOI18N
        
jScrollPane1.setViewportView(listadiurno);

        
titulolistamañana.setFont(resourceMap.getFont("titulolistamañana.font")); // NOI18N
        
titulolistamañana.setText(resourceMap.getString("titulolistamañana.text")); // NOI18N
        
titulolistamañana.setName("titulolistamañana"); // NOI18N

        
titulolistanoche.setFont(resourceMap.getFont("titulolistanoche.font")); // NOI18N
        
titulolistanoche.setText(resourceMap.getString("titulolistanoche.text")); // NOI18N
        
titulolistanoche.setName("titulolistanoche"); // NOI18N

        
jScrollPane2.setName("jScrollPane2"); // NOI18N

        
listanocturno.setName("listanocturno"); // NOI18N
        
jScrollPane2.setViewportView(listanocturno);

        
jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        
jLabel1.setName("jLabel1"); // NOI18N

        
jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        
jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        
jLabel2.setName("jLabel2"); // NOI18N

        
totaldiurno.setText(resourceMap.getString("totaldiurno.text")); // NOI18N
        
totaldiurno.setName("totaldiurno"); // NOI18N

        
totalnocturno.setName("totalnocturno"); // NOI18N

        
copiardiurno.setFont(resourceMap.getFont("copiardiurno.font")); // NOI18N
        
copiardiurno.setText(resourceMap.getString("copiardiurno.text")); // NOI18N
        
copiardiurno.setName("copiardiurno"); // NOI18N
        
copiardiurno.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
copiardiurnoActionPerformed(evt);
            }
        });

        
copiartododiurno.setFont(resourceMap.getFont("copiartododiurno.font")); // NOI18N
        
copiartododiurno.setText(resourceMap.getString("copiartododiurno.text")); // NOI18N
        
copiartododiurno.setName("copiartododiurno"); // NOI18N

        
copiarnocturno.setFont(resourceMap.getFont("copiarnocturno.font")); // NOI18N
        
copiarnocturno.setText(resourceMap.getString("copiarnocturno.text")); // NOI18N
        
copiarnocturno.setName("copiarnocturno"); // NOI18N

        
copiartodonocturno.setFont(resourceMap.getFont("copiartodonocturno.font")); // NOI18N
        
copiartodonocturno.setText(resourceMap.getString("copiartodonocturno.text")); // NOI18N
        
copiartodonocturno.setName("copiartodonocturno"); // NOI18N
        
copiartodonocturno.addActionListener(new java.awt.event.ActionListener() {
            public 
void actionPerformed(java.awt.event.ActionEvent evt) {
                
copiartodonocturnoActionPerformed(evt);
            }
        });

        
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        
mainPanel.setLayout(mainPanelLayout);
        
mainPanelLayout.setHorizontalGroup(
            
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addGroup(mainPanelLayout.createSequentialGroup()
                .
addContainerGap()
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .
addGroup(mainPanelLayout.createSequentialGroup()
                        .
addComponent(titulonombre)
                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .
addComponent(nombrejavax.swing.GroupLayout.PREFERRED_SIZE133javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
addContainerGap(183Short.MAX_VALUE))
                    .
addGroup(mainPanelLayout.createSequentialGroup()
                        .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
addGroup(mainPanelLayout.createSequentialGroup()
                                    .
addComponent(matricular)
                                    .
addGap(414141))
                                .
addGroup(javax.swing.GroupLayout.Alignment.TRAILINGmainPanelLayout.createSequentialGroup()
                                    .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED37Short.MAX_VALUE)
                                    .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .
addComponent(jScrollPane1javax.swing.GroupLayout.PREFERRED_SIZE85javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .
addComponent(jdiurnojavax.swing.GroupLayout.Alignment.TRAILING)
                                        .
addGroup(mainPanelLayout.createSequentialGroup()
                                            .
addComponent(jLabel1)
                                            .
addGap(222)
                                            .
addComponent(totaldiurno00Short.MAX_VALUE)))
                                    .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                            .
addGroup(javax.swing.GroupLayout.Alignment.TRAILINGmainPanelLayout.createSequentialGroup()
                                .
addComponent(titulolistamañana)
                                .
addGap(343434)))
                        .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .
addGroup(mainPanelLayout.createSequentialGroup()
                                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .
addComponent(jnocturno)
                                    .
addGroup(mainPanelLayout.createSequentialGroup()
                                        .
addGap(989898)
                                        .
addComponent(titulolistanoche))
                                    .
addGroup(mainPanelLayout.createSequentialGroup()
                                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .
addComponent(copiartodonocturnojavax.swing.GroupLayout.Alignment.TRAILINGjavax.swing.GroupLayout.DEFAULT_SIZE56Short.MAX_VALUE)
                                            .
addComponent(copiarnocturnojavax.swing.GroupLayout.Alignment.TRAILINGjavax.swing.GroupLayout.DEFAULT_SIZE56Short.MAX_VALUE)
                                            .
addComponent(copiartododiurnojavax.swing.GroupLayout.DEFAULT_SIZE56Short.MAX_VALUE)
                                            .
addComponent(copiardiurnojavax.swing.GroupLayout.DEFAULT_SIZE56Short.MAX_VALUE))
                                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .
addGroup(mainPanelLayout.createSequentialGroup()
                                                .
addComponent(jLabel2)
                                                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .
addComponent(totalnocturnojavax.swing.GroupLayout.DEFAULT_SIZE53Short.MAX_VALUE))
                                            .
addComponent(jScrollPane2javax.swing.GroupLayout.PREFERRED_SIZE85javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .
addGap(100100100))
                            .
addGroup(javax.swing.GroupLayout.Alignment.TRAILINGmainPanelLayout.createSequentialGroup()
                                .
addGap(121212)
                                .
addComponent(retirarjavax.swing.GroupLayout.PREFERRED_SIZE76javax.swing.GroupLayout.PREFERRED_SIZE)
                                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED54Short.MAX_VALUE)
                                .
addComponent(cerrarjavax.swing.GroupLayout.PREFERRED_SIZE75javax.swing.GroupLayout.PREFERRED_SIZE)
                                .
addGap(333333))))))
        );
        
mainPanelLayout.setVerticalGroup(
            
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addGroup(mainPanelLayout.createSequentialGroup()
                .
addContainerGap()
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(titulonombre)
                    .
addComponent(nombrejavax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(jnocturno)
                    .
addComponent(jdiurno))
                .
addGap(111111)
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(matricular)
                    .
addComponent(cerrar)
                    .
addComponent(retirar))
                .
addGap(888)
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(titulolistamañana)
                    .
addComponent(titulolistanoche))
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADINGfalse)
                    .
addComponent(jScrollPane100Short.MAX_VALUE)
                    .
addComponent(jScrollPane2javax.swing.GroupLayout.Alignment.TRAILING00Short.MAX_VALUE)
                    .
addGroup(mainPanelLayout.createSequentialGroup()
                        .
addComponent(copiardiurno)
                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .
addComponent(copiartododiurno)
                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .
addComponent(copiarnocturno)
                        .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .
addComponent(copiartodonocturno)))
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .
addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(totalnocturnojavax.swing.GroupLayout.PREFERRED_SIZE19javax.swing.GroupLayout.PREFERRED_SIZE)
                    .
addComponent(jLabel2)
                    .
addComponent(jLabel1)
                    .
addComponent(totaldiurnojavax.swing.GroupLayout.PREFERRED_SIZE19javax.swing.GroupLayout.PREFERRED_SIZE))
                .
addGap(303030))
        );

        
menuBar.setName("menuBar"); // NOI18N

        
fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        
fileMenu.setName("fileMenu"); // NOI18N

        
javax.swing.ActionMap actionMap org.jdesktop.application.Application.getInstance(alumnosnocheydia.AlumnosnocheydiaApp.class).getContext().getActionMap(AlumnosnocheydiaView.class, this);
        
exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        
exitMenuItem.setName("exitMenuItem"); // NOI18N
        
fileMenu.add(exitMenuItem);

        
menuBar.add(fileMenu);

        
helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        
helpMenu.setName("helpMenu"); // NOI18N

        
aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        
aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        
helpMenu.add(aboutMenuItem);

        
menuBar.add(helpMenu);

        
statusPanel.setName("statusPanel"); // NOI18N

        
statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        
statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        
statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        
statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        
progressBar.setName("progressBar"); // NOI18N

        
javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        
statusPanel.setLayout(statusPanelLayout);
        
statusPanelLayout.setHorizontalGroup(
            
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addComponent(statusPanelSeparatorjavax.swing.GroupLayout.DEFAULT_SIZE380Short.MAX_VALUE)
            .
addGroup(statusPanelLayout.createSequentialGroup()
                .
addContainerGap()
                .
addComponent(statusMessageLabel)
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED210Short.MAX_VALUE)
                .
addComponent(progressBarjavax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE)
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .
addComponent(statusAnimationLabel)
                .
addContainerGap())
        );
        
statusPanelLayout.setVerticalGroup(
            
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .
addGroup(statusPanelLayout.createSequentialGroup()
                .
addComponent(statusPanelSeparatorjavax.swing.GroupLayout.PREFERRED_SIZE2javax.swing.GroupLayout.PREFERRED_SIZE)
                .
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                .
addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .
addComponent(statusMessageLabel)
                    .
addComponent(statusAnimationLabel)
                    .
addComponent(progressBarjavax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE))
                .
addGap(333))
        );

        
setComponent(mainPanel);
        
setMenuBar(menuBar);
        
setStatusBar(statusPanel);
    }
// </editor-fold>//GEN-END:initComponents

    
private void cerrarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cerrarMouseClicked
    //Inicio coddigo mensaje de confirmacion al salir
      
int answer JOptionPane.showConfirmDialog(null,"Desea salir del programa?""Esta saliendo del programa"JOptionPane.YES_NO_OPTION);
      if (
answer == JOptionPane.YES_OPTION)
      {
       
System.exit(0);
      }
    
//Fin codigo mensaje de confirmacion al salir
    
}//GEN-LAST:event_cerrarMouseClicked

    
private void matricularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matricularActionPerformed
         //captura del curso
        
String alumno=nombre.getText();
       
//Verificar captura null
        
if(alumno.equals("") )
        {
          
JOptionPane.showMessageDialog(null"El campo nombre no puede estar vacio!!""Ha ocurrido un error!!!"JOptionPane.INFORMATION_MESSAGE);
          
nombre.requestFocus();
        }
          else
          {
            if (
this.objmañana.contains(alumno)||this.objnoche.contains(alumno))
            {
              
JOptionPane.showMessageDialog(null,alumno.toUpperCase()+" ya se encuentra registrado","Atencion",JOptionPane.ERROR_MESSAGE);
            }
             else 
//adicionar datos
             
{
                if(
jdiurno.isSelected())
                {
                   
//quitar seleccion al boton nocturno
                   
jnocturno.setSelected(false);
                   
//adicionar elementos
                   
this.objmañana.addElement(alumno);
                   
//asignar objeto al control lista
                   
this.listadiurno.setModel(objmañana);
                   
//captura del tamaño del objeto
                   
int cantidadd=this.objmañana.getSize();
                   
//muestra la cantidad de elementos en el cuadro de texto
                    
totaldiurno.setText(cantidadd "");
                   
//limpia y ubica el cursor al inicio
                    
nombre.setText("");
                    
nombre.requestFocus();
                }
                  else
                  {
                    if(
jnocturno.isSelected())
                   {
                       
jdiurno.setSelected(false);
                       
this.objnoche.addElement(alumno);
                       
//asignar objeto al control lista
                       
this.listanocturno.setModel(objnoche);
                       
//captura del tamaño del objeto
                       
int cantidadn=this.objnoche.getSize();
                        
//muestra la cantidad de elementos en el cuadro de texto
                        
totalnocturno.setText(cantidadn "");
                       
//limpia y ubica el cursor al inicio
                       
nombre.setText("");
                       
nombre.requestFocus();
                   }
                  }
             }
          }
    }
//GEN-LAST:event_matricularActionPerformed

    
private void jdiurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jdiurnoActionPerformed
        
if(jdiurno.isSelected())
        {
            
jnocturno.setSelected(false);
        }
    }
//GEN-LAST:event_jdiurnoActionPerformed

    
private void jnocturnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jnocturnoActionPerformed
       
if(jnocturno.isSelected())
        {
            
jdiurno.setSelected(false);
        }
    }
//GEN-LAST:event_jnocturnoActionPerformed

    
private void copiardiurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copiardiurnoActionPerformed
      // TODO add your handling code here:
    
}//GEN-LAST:event_copiardiurnoActionPerformed

    
private void retirarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_retirarActionPerformed
      //guardar la cantidad de objetos
      
int cantidaddiurno this.objmañana.getSize();
      
// guardar la posicion del elemento que se selecciona
      
int indicediurno this.listadiurno.getSelectedIndex();
      
//verificar si la lista esta vacia
      
if(cantidaddiurno==0)
      {
          
//si esta vacio
          
JOptionPane.showMessageDialog(null"No existen elementos para borrar""La accion no se puede realizar"JOptionPane.ERROR_MESSAGE);
      }
        else
        {
          
//si no se selecciono ningun objeto
          
if(indicediurno<0)
          {
             
JOptionPane.showMessageDialog(null"No ha seleccionado ningun elemento""La accion no se puede realizar"JOptionPane.ERROR_MESSAGE);
          }
            else 
//si selecciono un objeto
            
{
             
int answer JOptionPane.showConfirmDialog(null,
             
"Desea eliminar el elemento seleccionado?""Esta eliminando un objeto"JOptionPane.YES_NO_OPTION);
              if (
answer == JOptionPane.YES_OPTION)
              {
                
this.objmañana.remove(indicediurno);
                
//restar un valor al numero de elementos
                
totaldiurno.setText(this.objmañana.getSize()+"");
              }
            }
        }
    }
//GEN-LAST:event_retirarActionPerformed

    
private void copiartodonocturnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copiartodonocturnoActionPerformed
          
listadiurno.clearSelection();

    }
//GEN-LAST:event_copiartodonocturnoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    
private javax.swing.JButton cerrar;
    private 
javax.swing.JButton copiardiurno;
    private 
javax.swing.JButton copiarnocturno;
    private 
javax.swing.JButton copiartododiurno;
    private 
javax.swing.JButton copiartodonocturno;
    private 
javax.swing.JLabel jLabel1;
    private 
javax.swing.JLabel jLabel2;
    private 
javax.swing.JScrollPane jScrollPane1;
    private 
javax.swing.JScrollPane jScrollPane2;
    private 
javax.swing.JRadioButton jdiurno;
    private 
javax.swing.JRadioButton jnocturno;
    private 
javax.swing.JList listadiurno;
    private 
javax.swing.JList listanocturno;
    private 
javax.swing.JPanel mainPanel;
    private 
javax.swing.JButton matricular;
    private 
javax.swing.JMenuBar menuBar;
    private 
javax.swing.JTextField nombre;
    private 
javax.swing.JProgressBar progressBar;
    private 
javax.swing.JButton retirar;
    private 
javax.swing.JLabel statusAnimationLabel;
    private 
javax.swing.JLabel statusMessageLabel;
    private 
javax.swing.JPanel statusPanel;
    private 
javax.swing.JLabel titulolistamañana;
    private 
javax.swing.JLabel titulolistanoche;
    private 
javax.swing.JLabel titulonombre;
    private 
javax.swing.JTextField totaldiurno;
    private 
javax.swing.JTextField totalnocturno;
    
// End of variables declaration//GEN-END:variables

    //definicion de objetos
    
DefaultListModel objmañana = new DefaultListModel();
    
DefaultListModel objnoche = new DefaultListModel();
    
// fin definicion de objetos
    
private final Timer messageTimer;
    private final 
Timer busyIconTimer;
    private final 
Icon idleIcon;
    private final 
Icon[] busyIcons = new Icon[15];
    private 
int busyIconIndex 0;

    private 
JDialog aboutBox;

con los botones centrales


se debe copiar uno o todos los valores de la lista diurna a la nocturna o vicecersa y quitar dicho valor de la lista de origen, pero estos si no tengo ni la mas minima idea de como programarlos, lei en otros sitios y me dice que con arrays, pero ni idea

Agradezco a quien me pueda ayudar con mis problemas


Última edición por Rekker; 19-may-2011 a las 13:58
Responder Citando
Los siguientes 3 usuarios agradecen a Rekker por este mensaje:
baduser (19-may-2011), hackdie (22-may-2011), jchierro (29-may-2011)
Antiguo 24-may-2011     #2
Predeterminado

Hola Rekker, me parece que ese mensaje te salta porque efectivamente no hay elementos en la lista diurno porque el boton retirar esta programado solo para evaluar el diurno y no he visto por ningun lado la programacion para el nocturno.

int cantidaddiurno = this.objmañana.getSize(); ===>solo estas evaluando una lista, me parece q la diurna y entonces programas todo en base a ella..


if(cantidaddiurno==0)
{
//si esta vacio
JOptionPane.showMessageDialog(null, "No existen elementos para borrar", "La accion no se puede realizar", JOptionPane.ERROR_MESSAGE);
}
----

programar los botones q muestras no es nada del otro mundo si haces el [>] veras que el [<] es la viceversa igual para los demas...
y por cierto dices:

"El codigo que tengo es este:
Código PHP:"
y bueno dejame decirte q estas programando en JAVA, no en PHP

Espero haberte dado alguna pequeña ayuda, ya q me seria mas facil si tengo la app asi en codigo para abrirlo con algun IDE Java como Netbeans, si gustas puedes escribirme un mensaje, quizas a 4 dias de haber posteado esto, ya solucionaste tu problema.
Responder Citando
Los siguientes 3 usuarios agradecen a D'angela por este mensaje:
baduser (24-may-2011), Rekker (26-may-2011), VJEVans (24-may-2011)
Antiguo 12-dic-2012     #3
Predeterminado

Ver MensajeIniciado por D'angela Ver Mensaje
Hola Rekker, me parece que ese mensaje te salta porque efectivamente no hay elementos en la lista diurno porque el boton retirar esta programado solo para evaluar el diurno y no he visto por ningun lado la programacion para el nocturno.

int cantidaddiurno = this.objmañana.getSize(); ===>solo estas evaluando una lista, me parece q la diurna y entonces programas todo en base a ella..


if(cantidaddiurno==0)
{
//si esta vacio
JOptionPane.showMessageDialog(null, "No existen elementos para borrar", "La accion no se puede realizar", JOptionPane.ERROR_MESSAGE);
}
----

programar los botones q muestras no es nada del otro mundo si haces el [>] veras que el [<] es la viceversa igual para los demas...
y por cierto dices:

"El codigo que tengo es este:
Código PHP:"
y bueno dejame decirte q estas programando en JAVA, no en PHP

Espero haberte dado alguna pequeña ayuda, ya q me seria mas facil si tengo la app asi en codigo para abrirlo con algun IDE Java como Netbeans, si gustas puedes escribirme un mensaje, quizas a 4 dias de haber posteado esto, ya solucionaste tu problema.
ayudame con el codigo de los botones xfa
Responder Citando
Antiguo 13-dic-2012     #4
Predeterminado

Ver MensajeIniciado por luiskbeza Ver Mensaje
ayudame con el codigo de los botones xfa
Compañero, nuestra amiga no viene al foro desde el 03-jul-2011 asi que tendras que esperara ayuda de alguien mas....

salu2
Responder Citando
Antiguo 26-may-2011     #5
Predeterminado

D'angela ya solucione el problema de eliminar (aunque a medias) ahora cuando le doy retirar no me muestra el aviso de que no se selecciono nada.
En cuanto a lo de los botones de copiar ya lo logre, aunque aun no puedo con los de copiar todo.
En cuanto a donde dice codigo php (es cierto es Java, pero la etiqueta en que se envuelve es [php] ya que en esta te muestra el codigo con colores)

Responder Citando
Respuesta


(0 miembros y 1 visitantes)
 

Normas de Publicación
No puedes crear nuevos temas
No puedes responder mensajes
No puedes subir archivos adjuntos
No puedes editar tus mensajes

Los Códigos BB están Activado
Las Caritas están Activado
[IMG] está Activado
El Código HTML está Desactivado

Ir al Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
CSI: Miami jchierro Series TV 2 11-may-2020 00:01
¿Sexo Virtual? Qué es, cómo se practica, etc. cardavid Sexualidad 41 25-jun-2017 19:31
Horóscopo para 2011 Eloy58 Off-Topic 6 09-ene-2011 05:06
Pornografía, grave atentado contra la dignidad humana jamespoetrodriguez Sexualidad 22 04-sep-2010 20:00
Ponderación del Ego-Centrismo. JesRICART Intercambiossentimentales 1 08-dic-2009 00:36


Desarrollado por: vBulletin® Versión 3.8.1
Derechos de Autor ©2000 - 2025, Jelsoft Enterprises Ltd.
Ad Management by RedTyger