在swing的Jtable初始化中已经添加过数据,查询一条或者多条数据,Jtbale里数据不更新

import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Vector;
import java.awt.event.ActionEvent;

//创建主窗口
public class mainFace {

private JFrame mainframe;
private JTextField chepaiField;
private Vector cars;
private SelectCar sc=new SelectCar() ;
private JTable ResultTable;
private JScrollPane scrollPaneForRusultTable ;
private DefaultTableModel tableModel;
private Vector<String> columnNames=new Vector<>();
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                mainFace window = new mainFace();
                window.mainframe.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public mainFace() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {

    mainframe = new JFrame();
    mainframe.setTitle("阜建路段客车升降档查询系统");
    mainframe.getContentPane().setLayout(null);

    JLabel chepauLable = new JLabel("请输入车牌");
    chepauLable.setBounds(54, 32, 80, 15);
    mainframe.getContentPane().add(chepauLable);

    chepaiField = new JTextField();
    chepaiField.setBounds(144, 29, 99, 21);
    mainframe.getContentPane().add(chepaiField);
    chepaiField.setColumns(10);


    //查询按钮
    JButton selectButton = new JButton("查询");
    selectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(chepaiField.getText().length()<1)
            {
                /*chepaiField(车牌)输入长度小于1,表示未输入车牌,弹出对话框*/
                  JOptionPane.showMessageDialog(null, "查询所有车辆","未输入车牌",JOptionPane.ERROR_MESSAGE);
                //长度小于1,查询所有车牌
                cars=null;
                cars=sc.selectAll();
            }
            else
            {
                //长度不小于1,执行查询指定车牌的车
                cars=null;
                cars=sc.selectCar(chepaiField.getText());       
            }   
            ResultTable=null;
            ResultTable = new JTable(cars,columnNames);
            scrollPaneForRusultTable.setViewportView(ResultTable);


        }
    });

    selectButton.setBounds(285, 28, 93, 23);
    mainframe.getContentPane().add(selectButton);


    System.out.println("1");
    Vector<String> columnNames=new Vector<>();
    columnNames.addElement("序号");
    columnNames.addElement("车牌");
    columnNames.addElement("车类型");
    columnNames.addElement("座位数");
    columnNames.addElement("查询方式");
    columnNames.addElement("备注");
    columnNames.addElement("添加人");
    columnNames.addElement("图片");
    //={"序号","车牌","车型","座位数","查询方式","录入人","录入时间","备注"};//列名字
    Vector tableValue=sc.selectAll();
    ResultTable = new JTable(tableValue,columnNames);
    //创建显示表格滚动的面板
    scrollPaneForRusultTable = new JScrollPane();
    scrollPaneForRusultTable.setBounds(60, 90, 800, 800);
    mainframe.getContentPane().add(scrollPaneForRusultTable);
    scrollPaneForRusultTable.setViewportView(ResultTable);

    //单机ResultTable窗体弹出对话框
    ResultTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    ResultTable.addMouseListener(new MouseAdapter()
            {
                public void mouseClicked(MouseEvent e)
                {

                    JOptionPane.showMessageDialog(null, ResultTable.getValueAt(ResultTable.getSelectedRow(),1),"错误提示",JOptionPane.ERROR_MESSAGE);
                    /*if(e.getClickCount()==2)
                    {
                        System.out.println(x);
                    }*/
                }
            });


    //结果显示的表窗体
    /*
    String[] columnNames={"序号","车牌","车型","座位数","查询方式","录入人","录入时间","备注"};
    tableModel.addColumn(columnNames);
    cars=sc.selectAll();
    tableModel.addRow(cars);*/
    mainframe.setBounds(100, 100, 1000, 1000);
    mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}


https://zhidao.baidu.com/question/471267100.html