Java 参数数组字符串Jframe
您好,我正试图在Jdialog中打印主框架中选定行的值。 我正在尝试这个,但是当我在主框架中调用方法(“m.SetRecoger”)时,它显示了这个错误:Java 参数数组字符串Jframe,java,swing,compiler-errors,Java,Swing,Compiler Errors,您好,我正试图在Jdialog中打印主框架中选定行的值。 我正在尝试这个,但是当我在主框架中调用方法(“m.SetRecoger”)时,它显示了这个错误: private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
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
“类Modificar中的方法SetRecoger无法应用于给定类型;
必需:字符串[]
找到:没有参数
原因:实际参数列表和正式参数列表长度不同”
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
完整代码:
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
我拥有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) {
}
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
/**
*创建新表单DniFrame
*/
公共DniFrame(){
初始化组件();
}
/**
*从构造函数中调用此方法来初始化表单。
*警告:不要修改此代码。此方法的内容始终为
*由表单编辑器重新生成。
*/
@抑制警告(“未选中”)
//
私有组件(){
jPanel1=newjavax.swing.JPanel();
jScrollPane2=newjavax.swing.JScrollPane();
jTable2=newjavax.swing.JTable();
jButton1=newjavax.swing.JButton();
jMenuBar1=newjavax.swing.JMenuBar();
jMenu1=newjavax.swing.JMenu();
jMenuItem1=newjavax.swing.JMenuItem();
jMenu2=newjavax.swing.JMenu();
jMenuItem2=newjavax.swing.JMenuItem();
jMenuItem4=newjavax.swing.JMenuItem();
jMenuItem3=newjavax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(新java.awt.event.WindowAdapter(){
已打开公共无效窗口(java.awt.event.WindowEvent evt){
窗体窗口打开(evt);
}
});
jTable2.setModel(新的javax.swing.table.DefaultTableModel(
新对象[][]{
{null,null,null,null},
{null,null,null,null},
{null,null,null,null},
{null,null,null,null}
},
新字符串[]{
“Nif”、“Nom”、“Cognoms”、“Telefon”
}
));
jScrollPane2.setViewportView(jTable2);
jButton1.setText(“实现数据”);
jButton1.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout=新的javax.swing.GroupLayout(jPanel1);
setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpanellayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2,javax.swing.GroupLayout.DEFAULT\u SIZE,593,Short.MAX\u值)
.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(jpanellayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2,javax.swing.GroupLayout.PREFERRED\u SIZE,379,javax.swing.GroupLayout.PREFERRED\u 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\u SIZE,Short.MAX\u VALUE))
);
jMenu1.setText(“aplicció”);
jMenuItem1.setText(“Sortir”);
jMenuItem1.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jMenuItem1执行的操作(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuBar1.add(jMenu1);
jMenu2.setText(“基本数据”);
addActionListener(新的java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jMenu2ActionPerformed(evt);
}
});
jMenuItem2.setText(“Afegir”);
jMenuItem2.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jMenuItem2ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem2);
jMenuItem4.setText(“Modificar”);
jMenuItem4.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);
jMenuItem3.setText(“Eliminar”);
jMenuItem3.addActionListener(新的java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jMenuItem3执行的操作(evt);
}
});
jMenu2.add(jMenuItem3);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout=newjavax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(布局);
layout.setHorizontalGroup(
createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1、javax.swing.GroupLayout.Alignment.TRAILING、javax.swing.GroupLayout.DEFAULT\u SIZE、javax.swing.GroupLayout.DEFAULT\u SIZE、Short.MAX\u值)
);
layout.setVerticalGroup(
createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1、javax.swing.GroupLayout.Alignment.TRAILING、javax.swing.GroupLayout.DEFAULT\u SIZE、javax.swing.GroupLayout.DEFAULT\u SIZE、Short.MAX\u值)
);
包装();
}//
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt){
处置();
}
私有void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt){
String[] mod = modify();
Modificar m = new Modificar(this, true);
m.SetRecoger(mod);
new Modificar(this, true).setVisible(true);