import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;import javax.swing.ComboBoxEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class DeleteStaff implements ActionListener
{
      JDialog dialog;
      //JTextField tf=new JTextField();
     
    
      public DeleteStaff(JFrame jf)   
      {
       dialog=new JDialog(jf,"Staff Delete");
       Container dialogPane = dialog.getContentPane();
       dialogPane.setLayout(new GridLayout(2,2));
       dialogPane.add(new JLabel("Please input StaffNo:",SwingConstants.CENTER));
       //dialogPane.add(tf);
       try{ 
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  
    Connection con;
  
   con = DriverManager.getConnection("jdbc:odbc:MS","test","1234");
  
    Statement stmt;
  
   stmt = con.createStatement();
  
    ResultSet rs=stmt.executeQuery("Select * From Person");
    int i=0;
           while(rs.next())
    {
    
    i++;
    }
    int n;
    n=i;
    String data[]=new String[n];
    while(rs.next())
    {
    data[i]=rs.getInt("ID")+" ";
    }
       JComboBox combo=new JComboBox(data);
       combo.setEditable(true);
       ComboBoxEditor editor=combo.getEditor();
       combo.configureEditor(editor, "please choose or input the ID");
       stmt.close();
       con.close();
       
    
       dialogPane.add(combo);
       JButton b1=new JButton("EnSure");
       dialogPane.add(b1);
       JButton b2=new JButton("Cancle");
       dialogPane.add(b2);
       b1.addActionListener(this);
      b2.addActionListener(this);
       dialog.setBounds(200,150,500,100);
       dialog.setVisible(true);
       
       }
   catch(Exception ex){}
    
      }
      public void actionPerformed(ActionEvent e)
      {
       String cmd=e.getActionCommand();
       if(cmd.equals("EnSure"))
       {
       try
       { 
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection con=DriverManager.getConnection("jdbc:odbc:MS","test","1234");
     String sq="DELETE FROM Person WHERE ID=?";
    
     PreparedStatement pstmt=con.prepareStatement(sq);
     int ID=Integer.parseInt(combo.getSelectedItem().toString());
     pstmt.setInt(1, ID);
     pstmt.executeUpdate();
     pstmt.close();
     con.close();
     JOptionPane.showMessageDialog(dialog,"Delete Success","Success",JOptionPane.INFORMATION_MESSAGE);
       }
       catch(Exception ex){}
       }
       else if(cmd.equals("Cancle"))
       {
       dialog.dispose();
       }
      }
}
红色的一行是错误的