import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.sql.*;
import java.awt.event.*;
import java.awt.Rectangle;
import javax.swing.JTable;
import java.awt.ComponentOrientation;
import javax.swing.table.*;
public class select extends JFrame 
{
//health h;
String choose1="a",choose2="a",choose3,choose4,choose5,choose6,choose7,choose8,choose9,choose10,choose11="";;
String[] sex={"不限","男","女"};
String[] addressxian={"诏安县"};
String[] addresszhen={"不限","南诏镇","桥东镇","梅岭镇","四都镇","金星乡","梅洲乡","深桥镇","白洋乡","西潭乡","建设乡","红星乡","太平镇","官陂镇","霞葛镇","秀篆镇"};
//String[] addresscun={"不限","01村","02村","03村","04村","05村"};
String[][]addresscun=new String[][]{{"不限"},
{"不限","东关社区","南关社区","西关社区","北关社区","东北社区","东门社区","城内社区","西门社区","澹园社区","文峰社区","光良社区","秀峰社区","贸易加工区 ","五一村","梅峰村" },
{"不限","甲洲村","林家村","林巷村","西沈村","西浒村","村东村","村西村","村中村","外凤村","内凤村","西山村","牙头村","下寮村","桥头村","桥园村","溪雅村","澳头村","仙塘村","含英村","东霞村","林中村","西霞村","洪洲村" ,"西山农场"},
{"不限","悬钟村","腊洲村","下傅村","田厝村","下河村","南门村","东门村","赤石湾","宫口村","林厝村","高坑村","峰岐村","寮雅村","田中央","石城村" },
{"不限","四都圩","外埕村","马城村","城楼村","奇材村","后港村","港口村","林头村","西张村","山后村","盐仓村","林土乾村","石溪村","上湖村","西峤村","东峤村","田美村","东梧村","西梧村","东葛头村"},
{"不限","田朴村","湖内村","黎明村","新东亭村","公子店村","院前村","邱城村","虫寻寮村","金星农场","湖内林场"},
{"不限","梅溪村","梅山村","梅洲村","梅东村","梅西村","梅北村","梅南村","梅洲农场"},
{"不限","仕江村","岸屿村","平屿村","港头村","后林村","双港村","万田村","白厝村","新厝村","新溪村","上寨村","溪南村","下园村","凤寮村","考湖村","深桥村","郭寮村","西坑村","庄上村","径尾村","后埔村","埔上村","溪园村","树尾村","寨口村","大美村","新寨村","赤水溪村"},
{"不限","湖美村","麻园村","东山村","塘西村","桥安村","兰里村","白石村","深湖村","下径村","玉楼村","上蕴村","汀洋村","旧宙村","搭桥村","阳山村 "},
{"不限","桔林村","上陈村","新春村","新厝村","潭光村","潭东村","后陈村","军寮村","新安村","青山村","沈寨村","东上营村","美营村","福兴村","岑头村","山河村","龙坑村"},
{"不限","三林村","江亩坑村","马头村","坪路村","长埔村","月港村","水头村","万石溪村","建设农场"},
{"不限","庙兜村","圆林村","进水村","坪林村","六洞村","新林村","石楼村","楼仔村","红星农场"},
{"不限","太平村","科下村","麻寮村","雪里村","河边村","文山村","白叶村","新营村","榕城村","雄鸡村","走马村","元中村","林塘村","大布村","山前村","新联村","新楼村","景坑村","厚径村"},
{"不限","龙岗村","马坑村","凤狮村","采下村","下官村","陂龙村","吴坑村","光亮村","光坪村","大边村","官北村","新坎村","新径村","地凹村","龙际村","公田村","林畲村"},
{"不限","五通村","溪东村","嗣下村","南陂村","天桥村","庄溪村","庵下村","坑河村","华河村"},
{"不限","际岭村","河美村","寨坪村","乾东村","石东村","青龙山村","东径村","注湖村","陈龙村","焕塘村","彩山村","北坑村","顶安村","隔背村","寨坪村","上洋村","堀龙村","岭下溪林场"}
};
String[] study={"不限","文盲","小学","初中","高中","大学(专)","大学以上"};
String[] hukou={"不限","农业户口","非农业户口"};
String[] job={"不限","就业","未就业","务农"};
String[] degree={"不限","一级","二级","三级","四级","五级"};
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JTextArea jTextArea = null; 
private JLabel jlabel = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JCheckBox jCheckBox = null;
private JCheckBox jCheckBox1 = null;
private JTextField jTextField1 = null;
private JLabel jLabel1 = null;
private JCheckBox jCheckBox2 = null;
public JTextField jTextField2 = null;
private JLabel name = null;
private JCheckBox jCheckBox3 = null;
private JCheckBox jCheckBox4 = null;
private JLabel jLabel2 = null;
private JComboBox jComboBox = null;
private JLabel jLabel3 = null;
private JComboBox jComboBox1 = null;
private JComboBox jComboBox2 = null;
private JComboBox jComboBox3 = null;
ComboBoxModel modecun=null;  //  @jve:decl-index=0:
private JLabel jLabel4 = null;
private JLabel jLabel5 = null;
private JLabel jLabel6 = null;
private JComboBox jComboBox4 = null;
private JLabel jLabel7 = null;
private JCheckBox jCheckBox5 = null;
private JCheckBox jCheckBox6 = null;
private JComboBox jComboBox5 = null;
private JLabel jLabel8 = null;
private JCheckBox jCheckBox7 = null;
private JComboBox jComboBox6 = null;
private JLabel jLabel9 = null;
private JCheckBox jCheckBox8 = null;
private JLabel jLabel10 = null;
private JComboBox jComboBox7 = null;
private JButton jButton = null;
   /* TableModel dataModel = new AbstractTableModel() { 
public int getColumnCount() { return 6; } 
public int getRowCount() { return 6;} 
public Object getValueAt(int row, int col) { return new Integer(row*col); } };*/
public ResultSetTableModel model;
public JScrollPane scrollPane;
public JFrame jf=new JFrame("表格输出");
//public JFrame jf;
public ResultSetMetaData rsmd;
private JComboBox tableNames = new JComboBox();
public int getColumnCount() { return 6; } 
public select() {
super();
initialize();
}
private void initialize() {
this.setSize(800, 600);
this.setContentPane(getJContentPane());
this.setTitle("查询");
//System.out.println(jTextField2.getText());
}
private JPanel getJContentPane() {
if (jContentPane == null) 
{
jLabel10 = new JLabel();
jLabel10.setBounds(new Rectangle(73, 217, 60, 25));
jLabel10.setText("伤残等级");
jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(611, 169, 56, 25));
jLabel9.setText("就业情况");
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(319, 169, 59, 25));
jLabel8.setText("户口性质");
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(73, 169, 60, 25));
jLabel7.setText("文化程度");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(762, 121, 33, 25));
jLabel6.setText("村");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(610, 121, 41, 25));
jLabel5.setText("镇/乡");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(488, 121, 25, 15));
jLabel4.setText("县");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(319, 121, 51, 25));
jLabel3.setText("所在地");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(73, 121, 60, 25));
jLabel2.setText("性别");
name = new JLabel();
name.setBounds(new Rectangle(611, 73, 44, 25));
name.setText("姓名");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(319, 69, 60, 25));
jLabel1.setText("出生时间");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(73, 73, 60, 25));
jLabel.setText("编号");
jlabel = new JLabel();
jlabel.setText("     查  询");
jlabel.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 36));
jlabel.setBounds(new Rectangle(305, -6, 151, 64));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jlabel, null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), null);
jTextField.setEnabled(false);
jContentPane.add(getJCheckBox(), null);
jContentPane.add(getJCheckBox1(), null);
jContentPane.add(getJTextField1(), null);
jTextField1.setEnabled(false);
jContentPane.add(jLabel1, null);
jContentPane.add(getJCheckBox2(), null);
jContentPane.add(getJTextField2(), null);
jTextField2.setEnabled(false);
jContentPane.add(name, null);
jContentPane.add(getJCheckBox3(), null);
jContentPane.add(getJCheckBox4(), null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJComboBox(), null);
jComboBox.setEnabled(false);
jContentPane.add(jLabel3, null);
jContentPane.add(getJComboBox1(), null);
jComboBox1.setEnabled(false);
jContentPane.add(getJComboBox2(), null);
jComboBox2.setEnabled(false);
jContentPane.add(getJComboBox3(), null);
jComboBox3.setEnabled(false);
jContentPane.add(jLabel4, null);
jContentPane.add(jLabel5, null);
jContentPane.add(jLabel6, null);
jContentPane.add(getJComboBox4(), null);
jComboBox4.setEnabled(false);
jContentPane.add(jLabel7, null);
jContentPane.add(getJCheckBox5(), null);
jContentPane.add(getJCheckBox6(), null);
jContentPane.add(getJComboBox5(), null);
jComboBox5.setEnabled(false);
jContentPane.add(jLabel8, null);
jContentPane.add(getJCheckBox7(), null);
jContentPane.add(getJComboBox6(), null);
jComboBox6.setEnabled(false);
jContentPane.add(jLabel9, null);
jContentPane.add(getJCheckBox8(), null);
jContentPane.add(jLabel10, null);
jContentPane.add(getJComboBox7(), null);
jComboBox7.setEnabled(false);
jContentPane.add(getJButton(), null);
//jContentPane.add(jf,null);
}
return jContentPane;
}
class DATEModel extends DefaultComboBoxModel
    {
        DATEModel(String[] DATE)
        {
            for (int i = 0; i < DATE.length; i++)
            {
                addElement(DATE[i]);
            }
        }
    }
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
}
return jTextArea;

解决方案 »

  1.   

    private JTextField getJTextField() {
    if (jTextField == null) {
    jTextField = new JTextField();
    jTextField.setBounds(new Rectangle(145, 73, 86, 22));

    }
    return jTextField;
    }//编号
    /*private JCheckBox getJCheckBox() {
    if (jCheckBox == null) {
    jCheckBox = new JCheckBox();
    jCheckBox.setBounds(new Rectangle(42, 73, 20, 20));
    }
    return jCheckBox;
    }//编号*/
    private JCheckBox getJCheckBox() {
    if (jCheckBox == null) {
    jCheckBox = new JCheckBox();
    jCheckBox.setBounds(new Rectangle(42, 73, 20, 20));
    jCheckBox.addItemListener(new bianhao());
    }
    return jCheckBox;
    }
    class bianhao implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox)
    {
    jTextField.setEnabled(true);
    choose1="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox)
    {
    jTextField.setEnabled(false);
    choose1="";

    }
    }
    }
    }
    //身份证
    private JCheckBox getJCheckBox1() {
    if (jCheckBox1 == null) {
    jCheckBox1 = new JCheckBox();
    jCheckBox1.setBounds(new Rectangle(282, 73, 20, 20));
    jCheckBox1.addItemListener(new shengfenzheng());
    }
    return jCheckBox1;
    }
    class shengfenzheng implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox1)
    {
    jTextField1.setEnabled(true);
    choose2="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox1)
    {
    jTextField1.setEnabled(false);
    choose2="";
    }
    }
    }
    }
    private JTextField getJTextField1() {
    if (jTextField1 == null) {
    jTextField1 = new JTextField();
    jTextField1.setBounds(new Rectangle(388, 73, 133, 22));
    }
    return jTextField1;
    }
    //姓名
    private JCheckBox getJCheckBox2() {
    if (jCheckBox2 == null) {
    jCheckBox2 = new JCheckBox();
    jCheckBox2.setBounds(new Rectangle(587, 73, 20, 20));
    jCheckBox2.addItemListener(new xinming());
    }
    return jCheckBox2;
    }
    class xinming implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox2)
    {
    jTextField2.setEnabled(true);
    choose3="aa";

    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox2)
    {
    jTextField2.setEnabled(false);
    choose3="";
    }
    }
    }
    }
    private JTextField getJTextField2() {
    if (jTextField2 == null) {
    jTextField2 = new JTextField();
    jTextField2.setBounds(new Rectangle(667, 73, 101, 24));
    }
    return jTextField2;
    }
    private JCheckBox getJCheckBox3() {
    if (jCheckBox3 == null) {
    jCheckBox3 = new JCheckBox();
    jCheckBox3.setBounds(new Rectangle(42, 121, 20, 20));
    jCheckBox3.addItemListener(new sex());
    }
    return jCheckBox3;
    }
    class sex implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox3)
    {
    jComboBox.setEnabled(true);
    choose4="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox3)
    {
    jComboBox.setEnabled(false);
    choose4="";
    }
    }
    }
    }
    private JCheckBox getJCheckBox4() {
    if (jCheckBox4 == null) {
    jCheckBox4 = new JCheckBox();
    jCheckBox4.setBounds(new Rectangle(282, 121, 20, 20));
    jCheckBox4.addItemListener(new from());
    }
    return jCheckBox4;
    }
    class from implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox4)
    {
    jComboBox1.setEnabled(true);
    jComboBox2.setEnabled(true);
    jComboBox3.setEnabled(true);
    choose5="aa";
    choose6="aa";
    choose7="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox4)
    {
    jComboBox1.setEnabled(false);
    jComboBox2.setEnabled(false);
    jComboBox3.setEnabled(false);
    choose5="";
    choose6="";
    choose7="";
    }
    }
    }
    }
    private JComboBox getJComboBox() {
    if (jComboBox == null) {
    jComboBox = new JComboBox();
    ComboBoxModel modesex=new DATEModel(sex);
    jComboBox=new JComboBox(sex);
    jComboBox.setBounds(new Rectangle(145, 121, 86, 18));

    }
    return jComboBox;
    }
    private JComboBox getJComboBox1() {
    if (jComboBox1 == null) {
    jComboBox1 = new JComboBox();
    ComboBoxModel modeaddressxian=new DATEModel(addressxian);
    jComboBox1=new JComboBox(addressxian);
    jComboBox1.setBounds(new Rectangle(388, 121, 86, 18));

    }
    return jComboBox1;
    }
      

  2.   

    private JComboBox getJComboBox2() {
    if (jComboBox2 == null) 
    {
    jComboBox2 = new JComboBox();
    //ComboBoxModel modesex=new DATEModel(addresszhen);
    ComboBoxModel modezhen=new DATEModel(addresszhen);
    jComboBox2=new JComboBox(addresszhen);
    jComboBox2.setBounds(new Rectangle(518, 121, 86, 18));
    //jComboBox2.addItemListener(new cun());
    }
    return jComboBox2;
    }

    private JComboBox getJComboBox3() {
    if (jComboBox3 == null) {
    jComboBox3 = new JComboBox();
    modecun=new DATEModel(addresscun[0]);
    //ComboBoxModel modesex=new DATEModel(addresscun);
    jComboBox3=new JComboBox(modecun);
    jComboBox3.setBounds(new Rectangle(667, 121, 86, 18));
    jComboBox2.addItemListener(new cun());
    }
    return jComboBox3;
    }
    public class cun implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange() == e.SELECTED)
    {
    jComboBox3.removeAllItems();
        String Z = (String)jComboBox2.getSelectedItem();
        System.out.println(Z);
    for(int i=0;i<16;i++)
    {
    if(Z==addresszhen[i])
    {
    modecun=new DATEModel(addresscun[i]);
    jComboBox3.setModel(modecun);
    }
        }
    }
    }
    }
    private JComboBox getJComboBox4() {
    if (jComboBox4 == null) {
    jComboBox4 = new JComboBox();
    ComboBoxModel modestudy=new DATEModel(study);
    jComboBox4=new JComboBox(study);
    jComboBox4.setBounds(new Rectangle(145, 169, 86, 18));
    }
    return jComboBox4;
    }
    private JCheckBox getJCheckBox5() {
    if (jCheckBox5 == null) {
    jCheckBox5 = new JCheckBox();
    jCheckBox5.setBounds(new Rectangle(42, 169, 20, 20));
    jCheckBox5.addItemListener(new culture());
    }
    return jCheckBox5;
    }
    class culture implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox5)
    {
    jComboBox4.setEnabled(true);
    choose8="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox5)
    {
    jComboBox4.setEnabled(false);
    choose8="";
    }
    }
    }
    }
    private JCheckBox getJCheckBox6() {
    if (jCheckBox6 == null) {
    jCheckBox6 = new JCheckBox();
    jCheckBox6.setBounds(new Rectangle(282, 169, 20, 20));
    jCheckBox6.addItemListener(new hukou());
    }
    return jCheckBox6;
    }
    class hukou implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox6)
    {
    jComboBox5.setEnabled(true);
    choose9="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox6)
    {
    jComboBox5.setEnabled(false);
    choose9="";
    }
    }
    }
    }
    private JComboBox getJComboBox5() {
    if (jComboBox5 == null) {
    jComboBox5 = new JComboBox();
    ComboBoxModel modesex=new DATEModel(hukou);
    jComboBox5=new JComboBox(hukou);
    jComboBox5.setBounds(new Rectangle(388, 169, 86, 18));
    }
    return jComboBox5;
    }
    private JCheckBox getJCheckBox7() {
    if (jCheckBox7 == null) {
    jCheckBox7 = new JCheckBox();
    jCheckBox7.setBounds(new Rectangle(587, 169, 20, 20));
    jCheckBox7.addItemListener(new job());
    }
    return jCheckBox7;
    }
    class job implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox7)
    {
    jComboBox6.setEnabled(true);
    choose10="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox7)
    {
    jComboBox6.setEnabled(false);
    choose10="";
    }
    }
    }
    }
    private JComboBox getJComboBox6() {
    if (jComboBox6 == null) {
    jComboBox6 = new JComboBox();
    ComboBoxModel modesex=new DATEModel(job);
    jComboBox6=new JComboBox(job);
    jComboBox6.setBounds(new Rectangle(667, 169, 86, 18));
    }
    return jComboBox6;
    }
    private JCheckBox getJCheckBox8() {
    if (jCheckBox8 == null) {
    jCheckBox8 = new JCheckBox();
    jCheckBox8.setBounds(new Rectangle(42, 217, 20, 20));
    jCheckBox8.addItemListener(new degress());
    }
    return jCheckBox8;
    }
    class degress implements ItemListener
    {
    public void itemStateChanged(ItemEvent e)
    {
    if(e.getStateChange()==e.SELECTED)
    {
    if(e.getSource()==jCheckBox8)
    {
    jComboBox7.setEnabled(true);
    choose11="aa";
    }
    }
    if(e.getStateChange()==e.DESELECTED)
    {
    if(e.getSource()==jCheckBox8)
    {
    jComboBox7.setEnabled(false);
    choose11="";
    }
    }
    }
    }
    private JComboBox getJComboBox7() {
    if (jComboBox7 == null) {
    jComboBox7 = new JComboBox();
    ComboBoxModel modesex=new DATEModel(degree);
    jComboBox7=new JComboBox(degree);
    jComboBox7.setBounds(new Rectangle(145, 217, 86, 18));
    }
    return jComboBox7;
    }
    private JButton getJButton() 
    {
    if (jButton == null) {
    jButton = new JButton();
    jButton.setBounds(new Rectangle(660, 210, 60, 30));
    jButton.setFont(new Font("Dialog", Font.BOLD, 12));
    jButton.setText("查询");
    jButton.addActionListener(new show());
    }
    return jButton;
     }
    public 
    class show implements ActionListener
    {
    public void actionPerformed(ActionEvent e)
    { String t;
    String st1,st2,st3;
    String str="";
    String condiction="";
    boolean clsstatus=false;
    //JTextArea ta=new JTextArea();
    //ta.setLineWrap(true);
    TextArea ta=new TextArea();
    TextField tf=new TextField();
    Frame f=new Frame("查询结果");
    f.setLayout(new BorderLayout(30,30));
    Panel p=new Panel();
    //JPanel p = new JPanel();

    f.addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e) 
    {
    System.exit(0);
    }
    }); try{ 
             Class.forName("com.mysql.jdbc.Driver");//加载驱动程序 
             System.out.println("OK,DownLoad the driver"); 
             Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/disable","root","a");
             con.setCatalog("disable"); 
             Statement stmt = con.createStatement();
             System.out.println("GOOD,Connect the DataBase"); 
             //ps = con.prepareStatement(SQL);
             st1=jTextField.getText();
             //System.out.println(st1);
             st2=jTextField1.getText();
             st3=jTextField2.getText();
             String xiala1=(String)jComboBox.getSelectedItem();
             System.out.println("good1");
             String xiala2=(String)jComboBox2.getSelectedItem();
             System.out.println("good2");
             String xiala3=(String)jComboBox3.getSelectedItem();
             System.out.println("good3");
             String xiala4=(String)jComboBox4.getSelectedItem();
             System.out.println("good4");
             String xiala5=(String)jComboBox5.getSelectedItem();
             String xiala6=(String)jComboBox6.getSelectedItem();
             String xiala7=(String)jComboBox7.getSelectedItem();
             System.out.println(xiala1);
             /*if(choose1.equals(""))
             {
              condiction="";
            
             }*/
            
             if((st1!=null)&&(!st1.equals(""))&&(!choose1.equals("")))
             {
              condiction="id="+"'"+st1+"'";
             }
             else
              condiction="";
             
             if((st2!=null)&&(!st2.equals(""))&&(!choose2.equals("")))
             {          
              if(condiction.equals(""))
             {
              condiction=condiction+"birthday="+"'"+st2+"'";
             }
              else
              {
              condiction=condiction+" and birthday="+"'"+st2+"'";
              }
             }
             if((st3!=null)&&(!st3.equals(""))&&(!choose3.equals("")))
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"name="+"'"+st3+"'";
             }
              else
              {
              condiction=condiction+" and name="+"'"+st3+"'";
              }
             }
             if(xiala1.equals("不限")||(choose4.equals("")))
             {
              condiction=condiction+"";
             }
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"sex="+"'"+xiala1+"'";
             }
              else
              {
              condiction=condiction+" and sex="+"'"+xiala1+"'";
              }
             }

             if(xiala2.equals("不限")||(choose5.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"address="+"'"+xiala2+"'";
             }
              else
              {
              condiction=condiction+" and address="+"'"+xiala2+"'";
              }
             }
      

  3.   

             //村级的限制
             if(xiala3.equals("不限")||xiala2.equals("不限")||(choose7.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"address1="+"'"+xiala3+"'";
             }
              else
              {
              condiction=condiction+" and address1="+"'"+xiala3+"'";
              }
             }
             //文化限制
             if(xiala4.equals("不限")||(choose8.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"study="+"'"+xiala4+"'";
             }
              else
              {
              condiction=condiction+" and study="+"'"+xiala4+"'";
              }
             }
             //户口
             if(xiala5.equals("不限")||(choose9.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"hukou="+"'"+xiala5+"'";
             }
              else
              {
              condiction=condiction+" and hukou="+"'"+xiala5+"'";
              }
             }
             //就业情况
             if(xiala6.equals("不限")||(choose10.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"job="+"'"+xiala6+"'";
             }
              else
              {
              condiction=condiction+" and job="+"'"+xiala6+"'";
              }
             }
             //等级
             if(xiala7.equals("不限")||(choose11.equals("")))
             {
              condiction=condiction+"";
             } 
             else
             {
              if(condiction.equals(""))
             {
              condiction=condiction+"dengji="+"'"+xiala7+"'";
             }
              else
              {
              condiction=condiction+" and dengji="+"'"+xiala7+"'";
              }
             }
             condiction=condiction+";";
            System.out.println(condiction);
            //ResultSet rs = stmt.executeQuery("select *from health where "+condiction);
            ResultSet rs = stmt.executeQuery("select id,birthday,name from health where "+condiction);
            model=new ResultSetTableModel(rs);
            JTable table=new JTable(model);
            scrollPane=new JScrollPane(table);
            jf.add(scrollPane,BorderLayout.CENTER);
            jf.validate();
            //p.add(tableNames);
    jf.add(p, BorderLayout.NORTH);
    //String tableName = (String) tableNames.getSelectedItem();
    //String[] tableName ={"编号","出生日期","姓名"};
    //jf.add(new JScrollPane(changeMsg), BorderLayout.SOUTH);
    try
    {

    //获取数据库的MetaData对象
    DatabaseMetaData meta = con.getMetaData();
    //创建Statement
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    //查询当前数据库的全部数据表
    ResultSet tables = meta.getTables(null, null, null, new String[] { "TABLE" });
    //将全部数据表添加到JComboBox中
    while (tables.next())
    {
    tableNames.addItem(tables.getString(3));
    }
    tables.close();
    }
    catch(Exception e1)
    {

    } jf.pack();
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.setVisible(true);
      while(rs.next())
    {
       clsstatus=false;
    System.out.println(rs.getString(1) + "\t"
    + rs.getString(2) + "\t"
    + rs.getString(3));
    //t=rs.getString(1) + "\t"
    //+ rs.getString(2) + "\t"
    //+ rs.getString(3);
    //str=str+t+"\n";
    //ta.setText(str);
    //JTable table = new JTable(dataModel);
    }
               // p.add(ta);
    //f.add(p);
    //f.pack();
        //f.setVisible(true);
      jContentPane.add(jf);
    }
    catch(Exception ee)
    {
    System.out.print("a");
    }

    }

    }
    }
    class ResultSetTableModel extends AbstractTableModel
    {  
    private ResultSet rs;
    private ResultSetMetaData rsmd;
    //构造器,初始化rs和rsmd两个属性
    public ResultSetTableModel(ResultSet aResultSet)
    {
    rs = aResultSet;
    try
    {  
    rsmd = rs.getMetaData();
    }
    catch (SQLException e)
    {  
    e.printStackTrace();
    }
    }
    //重写getColumnName方法,用于为该TableModel设置列名
    public String getColumnName(int c)
    {  
    try
    {  
    return rsmd.getColumnName(c + 1);
    }
    catch (SQLException e)
    {  
    e.printStackTrace();
    return "";
    }
    }
    //重写getColumnCount方法,用于设置该TableModel的列数
    public int getColumnCount()
    {  
    try
    {  
    return rsmd.getColumnCount();
    }
    catch (SQLException e)
    {  
    e.printStackTrace();
    return 0;
    }
    }
    //重写getValueAt方法,用于设置该TableModel指定单元格的值
    public Object getValueAt(int r, int c)
    {  
    try
    {  
    rs.absolute(r + 1);
    return rs.getObject(c + 1);
    }
    catch(SQLException e)
    {  
    e.printStackTrace();
    return null;
    }
    }
    //重写getColumnCount方法,用于设置该TableModel的行数
    public int getRowCount()
    {  
    try
    {  
    rs.last();
    return rs.getRow();
    }
    catch(SQLException e)
    {  
    e.printStackTrace();
    return 0;
    }
    }
    }
      

  4.   

    黏贴忘了带问题了,不好意思各位!
    我是个初学者,被老师叫去合作开发一个软件
    java我们都没开课,只是自己看书看了几天。
    都是东参考西参考的,自己都觉得有点乱
    现在要把查询出来的结果放到主界面的下方去!
    哎。。我只是个初学者,什么基础都没有,很多都按书上说的做的,,,,很混乱
    谢谢各位帮忙!!!
      

  5.   


    关注此贴如果没得到解决可以找我。。 qq联系即可。代码太长,必须使用IDE才行。。