Ingreso: agosto-2010
Ubicación: Frente al pc
Mensajes: 474
Sexo: 
País: 
|
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 = 0; i < busyIcons.length; i++) { busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); } 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(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(183, Short.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(41, 41, 41)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jdiurno, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(jLabel1) .addGap(2, 2, 2) .addComponent(totaldiurno, 0, 0, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addComponent(titulolistamañana) .addGap(34, 34, 34))) .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(98, 98, 98) .addComponent(titulolistanoche)) .addGroup(mainPanelLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(copiartodonocturno, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE) .addComponent(copiarnocturno, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE) .addComponent(copiartododiurno, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE) .addComponent(copiardiurno, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.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(totalnocturno, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(100, 100, 100)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(retirar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE) .addComponent(cerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(33, 33, 33)))))) ); mainPanelLayout.setVerticalGroup( mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(titulonombre) .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jnocturno) .addComponent(jdiurno)) .addGap(11, 11, 11) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(matricular) .addComponent(cerrar) .addComponent(retirar)) .addGap(8, 8, 8) .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.LEADING, false) .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.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(totalnocturno, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(totaldiurno, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30)) );
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(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) .addGroup(statusPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(statusMessageLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 210, Short.MAX_VALUE) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.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(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(statusMessageLabel) .addComponent(statusAnimationLabel) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(3, 3, 3)) );
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
|