java - 参数数组字符串Jframe

标签 java swing compiler-errors

嗨,我正在尝试在 Jdialog 中打印主框架中选定行的值。
我正在尝试这个,但是当我在主框架中调用方法(“m.SetRecoger)时,它显示了这个错误:

“类 Modificar 中的方法 SetRecoger 不能应用于给定类型;
必需:字符串[]
发现:没有参数
原因:实际参数列表和形式参数列表的长度不同”

完整代码:

我有jtable的主框架:
公共(public)类 DniFrame 扩展 javax.swing.JFrame {

/**
 * Creates new form DniFrame
 */
public DniFrame() {

    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.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTable2 = new javax.swing.JTable();
    jButton1 = new javax.swing.JButton();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenuItem3 = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
            formWindowOpened(evt);
        }
    });

    jTable2.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null},
            {null, null, null, null}
        },
        new String [] {
            "Nif", "Nom", "Cognoms", "Telefon"
        }
    ));
    jScrollPane2.setViewportView(jTable2);

    jButton1.setText("Actualizar Datos");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 593, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap())
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 379, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jMenu1.setText("Aplicació");

    jMenuItem1.setText("Sortir");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem1);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Base de Dades");
    jMenu2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenu2ActionPerformed(evt);
        }
    });

    jMenuItem2.setText("Afegir");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem2);

    jMenuItem4.setText("Modificar");
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem4ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem4);

    jMenuItem3.setText("Eliminar");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem3);

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

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

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           

    dispose();


}                                          

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    new afegir(this, true).setVisible(true);


}                                          

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
modify(); 
Modificar m=new Modificar(this, true);
m.SetRecoger();
new Modificar(this, true).setVisible(true);


}                                          

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {                                           

    DefaultTableModel modelo = (DefaultTableModel) this.jTable2.getModel();
    int i = jTable2.getSelectedRow();

    if (i == -1) {
        JOptionPane.showMessageDialog(null, "Debes selecioonar una fila");

    } else {

        int ax = JOptionPane.showConfirmDialog(null, "Estás seguro de que quieres eliminar este registro?");
        if (ax == JOptionPane.YES_OPTION) {
            JOptionPane.showMessageDialog(null, "Has seleccionado SI.");

           String dni = (String) jTable2.getValueAt(i, 0);
           modelo.removeRow(jTable2.getSelectedRow());

        try {
            Class.forName("com.mysql.jdbc.Driver");
            try (Connection conexion = DriverManager.getConnection("jdbc:mysql://192.168.100.128/mibase", "asis", "titanic24")) {
                Statement comando = conexion.createStatement();
                comando.executeUpdate("delete  from dades_pers where nif = '" + dni + "'");
            }
            JOptionPane.showMessageDialog(null, "Registro borrado");
        } catch (ClassNotFoundException e) {
            JOptionPane.showMessageDialog(null, "No se ha podido eliminar el registro");

        } catch (SQLException ex) {
            Logger.getLogger(DniFrame.class.getName()).log(Level.SEVERE, null, ex);
        }   






        } else if (ax == JOptionPane.NO_OPTION) {
            JOptionPane.showMessageDialog(null, "Has seleccionado NO.");
        }



    }


}                                          

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

    try {

        Class.forName("com.mysql.jdbc.Driver");
        Connection conexion = DriverManager.getConnection("jdbc:mysql://192.168.100.128/mibase", "asis", "titanic24");
        Statement comando = conexion.createStatement();
        ResultSet result = comando.executeQuery("select * from dades_pers");
        ResultSetMetaData rsMD = result.getMetaData();
        int numcolumnas = rsMD.getColumnCount();
        DefaultTableModel modelo = new DefaultTableModel();
        this.jTable2.setModel(modelo);

        for (int x = 1; x <= numcolumnas; x++) {
            modelo.addColumn(rsMD.getColumnLabel(x));

        }

        while (result.next()) {
            Object[] fila = new Object[numcolumnas];
            for (int i = 0; i < numcolumnas; i++) {
                fila[i] = result.getObject(i + 1);
            }
            modelo.addRow(fila);

        }

    } catch (ClassNotFoundException e) {
    } catch (SQLException sqe) {
    }

//TODO 在此处添加您的处理代码:
}
private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:
}                                      

private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  

    añadirTabla();


}                                 

public void añadirTabla() {

    try {

        Class.forName("com.mysql.jdbc.Driver");
        Connection conexion = DriverManager.getConnection("jdbc:mysql://192.168.100.128/mibase", "asis", "titanic24");
        Statement comando = conexion.createStatement();
        ResultSet result = comando.executeQuery("select * from dades_pers");
        ResultSetMetaData rsMD = result.getMetaData();
        int numcolumnas = rsMD.getColumnCount();
        DefaultTableModel modelo = new DefaultTableModel();
        this.jTable2.setModel(modelo);

        for (int x = 1; x <= numcolumnas; x++) {
            modelo.addColumn(rsMD.getColumnLabel(x));

        }

        while (result.next()) {
            Object[] fila = new Object[numcolumnas];
            for (int i = 0; i < numcolumnas; i++) {
                fila[i] = result.getObject(i + 1);
            }
            modelo.addRow(fila);

        }

    } catch (ClassNotFoundException e) {
    } catch (SQLException sqe) {
    }

}

public String [] modify() {

    String[] registros = new String[4];
    int i = jTable2.getSelectedRow();

    if (i == -1) {
        JOptionPane.showMessageDialog(null, "Debes selecioonar una fila");
        new Modificar(this, true).setVisible(false);
    } else {

        registros[0] = (String) jTable2.getValueAt(i, 0).toString();
        registros[1] = (String) jTable2.getValueAt(i, 1).toString();
        registros[2] = (String) jTable2.getValueAt(i, 2).toString();
        registros[3] = (String) jTable2.getValueAt(i, 3).toString();   
    }
    return registros;
}

/**
 * @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 {
        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(DniFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(DniFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(DniFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(DniFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new DniFrame().setVisible(true);
        }
    });

}

// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTable2;
// End of variables declaration                   

}

//jdialog(第二帧);

公共(public)类 Modificar 扩展 javax.swing.JDialog {
private DniFrame p;

/**
 * Creates new form Modificar
 */
public Modificar(java.awt.Frame parent, boolean modal) {
   super(parent, modal);   
   this.p= (DniFrame)parent;
    initComponents();
}


public void SetRecoger(String[] v) {
    String nif = v[0];
    String nom = v[1];
    String cognom =v[2];
    String tel = v[3];

String []datos ={nif,nom,cognom,tel};

    jTextField5.setText(nif);
    jTextField6.setText(nom);
    jTextField7.setText(cognom);
    jTextField8.setText(tel);


}

/**
 * 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() {

    jPanel2 = new javax.swing.JPanel();
    jLabel5 = new javax.swing.JLabel();
    jTextField5 = new javax.swing.JTextField();
    jTextField6 = new javax.swing.JTextField();
    jTextField7 = new javax.swing.JTextField();
    jTextField8 = new javax.swing.JTextField();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    jLabel5.setText("Nom");

    jTextField5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField5ActionPerformed(evt);
        }
    });

    jTextField6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField6ActionPerformed(evt);
        }
    });

    jTextField7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField7ActionPerformed(evt);
        }
    });

    jTextField8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField8ActionPerformed(evt);
        }
    });

    jLabel6.setText("NIF");

    jLabel7.setText("Cognoms");

    jLabel8.setText("Telefon");

    jButton2.setText("Desar les dades");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jButton3.setText("Tancar");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Estat"));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
            .addContainerGap())
    );

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(31, 31, 31)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(78, 78, 78)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(10, 10, 10)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addContainerGap(23, Short.MAX_VALUE))
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(17, 17, 17)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(15, 15, 15)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    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()
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 10, Short.MAX_VALUE))
    );

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

private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {                                            


}                                           

private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {                                            

}                                           

private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {                                            
    // TODO add your handling code here:
}                                           

private void jTextField8ActionPerformed(java.awt.event.ActionEvent evt) {                                            


}                                           

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

    try {

        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(afegir.class.getName()).log(Level.SEVERE, null, ex);
    }

    try {
        Connection conexion = DriverManager.getConnection("jdbc:mysql://192.168.100.128/mibase", "asis", "titanic24");

        Statement comando = conexion.createStatement();

        String nif    = jTextField5.getText();
        String nom    = jTextField6.getText();
        String cognom = jTextField7.getText();
        String tel    = jTextField8.getText();


        comando.executeUpdate("UPDATE dades_pers SET nom= '" + nom + "',cognoms='" + cognom + "',telefon= '" + tel + "' where nif= '" + nif + "'");
        conexion.close();
        jLabel1.setText("Datos Modificados  correctamente");

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error al modificar los datos" + e);

    }


}                                        

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    dispose();
}                                        

//
/**
 * @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 {
        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(Modificar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Modificar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Modificar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Modificar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the dialog */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            Modificar dialog = new Modificar(new javax.swing.JFrame(), true);
            dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                @Override
                public void windowClosing(java.awt.event.WindowEvent e) {
                    System.exit(0);
                }
            });
            dialog.setVisible(true);
        }
    });

}

// Variables declaration - do not modify                     

谢谢!!

最佳答案

您正在调用方法 SetRecoger在您的 DniFrame不向方法传递任何参数。

您在 Modificar 中定义的方法对话框需要一个字符串数组作为参数。

public void SetRecoger(String[] v) {....}

由于您的modify()方法返回一个字符串数组,试试这个:
String[] mod = modify(); 
Modificar m = new Modificar(this, true);
m.SetRecoger(mod);
new Modificar(this, true).setVisible(true);

关于java - 参数数组字符串Jframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21867934/

相关文章:

java - 在JavaFX中,如何在不失去第一个阶段焦点的情况下打开另一个阶段?

java - 试图从 Django 服务器获取 JSON 数据到 Android 但获取 HTML

java - JTable编辑模式

java - 动态添加按钮到 JFrame 或 LayeredPane

java - 使用来自 Jlabel 的自定义子类时 GridBagLayout 堆叠标签

linux - fatal error : pthread/pthread_impl. h : No such file or directory #include <pthread/pthread_impl. h>

java - Apple 最近的 Java 更新删除了 Java 首选项,如何从 shell 更改?

java - 如何通过 Package.getPackage(...) 访问包?

compiler-errors - 无法将libsvm与OCaml一起使用

c - 双数组 - C 中的编译时错误