2014-02-18 3 views
-2

안녕하세요, Jdialog에서 주 프레임에서 선택한 행의 값을 인쇄하려고합니다. 이 시도하고 있지만이 오류를 보여주는 주 프레임에서 메서드 ("m.SetRecoger")를 호출 할 때 :매개 변수 배열 문자열 Jframe

"메서드 Modifiedar의 SetRecoger는 주어진 형식에 적용 할 수 없습니다. 이 필요합니다 : 문자열 [] 를 찾을 수 없습니다 : 인수 이유는 실제와 형식 인수 목록의 길이가 다른 경우 "

전체 코드는 :

내가 JTable가이 메인 프레임 : 공용 클래스 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 (두 번째 프레임);

공용 클래스 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      

감사합니다!

+4

더 나은 도움말은 빨리하는 [MCTaRE] (http://stackoverflow.com/help/mcve) (최소를 게시 완전한 테스트되고 읽을 수있는 예). –

+0

BTW - 올바른 생각을 가진 누구도 오류를 찾기 위해 655 줄의 코드 (표준 코드 서식을 사용하기에는 너무 깁니다)를 통해 트롤링 할 사람은 없습니다. 좁히세요! –

+0

@AndrewThompson 내 왼쪽 마음에 있어야합니다 : P하지만 나는 당신과 동의합니다 ... 스크롤했을 때 갑자기 나타났습니다 –

답변

1

메소드에 인수를 전달하지 않고 DniFrameSetRecoger 메소드를 호출하고 있습니다.

Modificar 대화 상자에서 정의한 메서드는 String 배열을 인수로 필요로합니다. 당신의 modify() 방법은 문자열 배열을 반환하기 때문에

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

이 시도 :

String[] mod = modify(); 
Modificar m = new Modificar(this, true); 
m.SetRecoger(mod); 
new Modificar(this, true).setVisible(true);