Ciao a tutti...ho una form che visualizza l'elenco degli utenti di un sito...ho inserito due pulsanti per spostarmi avanti e indietro tramite un iterator. Il problema è che se per esempio premo avanti poi per tornare all'utente precedente devo premere il pulsante indietro 2 volte...Vi posto il codice per capire meglio:

codice:
package org.apache.esme.form;

import java.util.List;
import java.util.ListIterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import org.apache.esme.api.RestMetodi;
import org.apache.esme.model.AllUsers;

/**
 *
 * @author gabriele
 */
public class FrmUsers extends javax.swing.JFrame {
    
    JFrame frmIndex;
    RestMetodi pRestMetodi;
    ListIterator it;
    List users;
    
    private void acquisisci() {
        try {
            users = pRestMetodi.getUsers();
            } catch (Exception ex) {
                Logger.getLogger(FrmUsers.class.getName()).log(Level.SEVERE, null, ex);
            }
            it = users.listIterator();
            AllUsers us = (AllUsers)it.next();
            pnlUsers1.showUsers(us);
       
    }

    /** Creates new form FrmUsers */
    public FrmUsers() {
        initComponents();
        frmIndex = new JFrame();
        pRestMetodi = new RestMetodi();
    }
    
    public FrmUsers(JFrame p_frmIndex) {
        initComponents();
        pRestMetodi = new RestMetodi();
        acquisisci();
        frmIndex = p_frmIndex;
    }

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

        BtnIndietro = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        pnlUsers1 = new org.apache.esme.form.PnlUsers();
        BtnNext = new javax.swing.JButton();
        BtnPrev = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        BtnIndietro.setText("Indietro");
        BtnIndietro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnIndietroActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 24));
        jLabel1.setText("ELENCO UTENTI ESME");

        BtnNext.setText(">");
        BtnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnNextActionPerformed(evt);
            }
        });

        BtnPrev.setText("<");
        BtnPrev.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnPrevActionPerformed(evt);
            }
        });

        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()
                .addContainerGap(123, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(115, 115, 115))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(75, Short.MAX_VALUE)
                .addComponent(pnlUsers1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(61, 61, 61))
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(BtnPrev, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                .addGap(304, 304, 304)
                .addComponent(BtnNext, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                .addGap(46, 46, 46))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(204, Short.MAX_VALUE)
                .addComponent(BtnIndietro, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(199, 199, 199))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(pnlUsers1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnPrev)
                    .addComponent(BtnNext))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                .addComponent(BtnIndietro)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    private void BtnIndietroActionPerformed(java.awt.event.ActionEvent evt) {                                            
        this.setVisible(false);
        frmIndex.setVisible(true);
        frmIndex.setEnabled(true);   
    }                                           

    private void BtnNextActionPerformed(java.awt.event.ActionEvent evt) {                                        
         if (it.hasNext()) {
           AllUsers us = (AllUsers)it.next();
           pnlUsers1.showUsers(us);    
        }
        else {
           JOptionPane.showMessageDialog(null, "Non esiste un elemento successivo", "Elemento non esistente", JOptionPane.ERROR_MESSAGE);
        }
    }                                       

    private void BtnPrevActionPerformed(java.awt.event.ActionEvent evt) {                                        
        if (it.hasPrevious()) {
           AllUsers us = (AllUsers)it.previous();
           pnlUsers1.showUsers(us);    
        }
        else {
           JOptionPane.showMessageDialog(null, "Non esiste un elemento precedente", "Elemento non esistente", JOptionPane.ERROR_MESSAGE);
        }
    }                                       

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
       

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmUsers().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton BtnIndietro;
    private javax.swing.JButton BtnNext;
    private javax.swing.JButton BtnPrev;
    private javax.swing.JLabel jLabel1;
    private org.apache.esme.form.PnlUsers pnlUsers1;
    // End of variables declaration