表格的列标题在面板中不可见

时间:2016-05-24 19:12:41

标签: java

以下代码可能正常工作,列名称显示为

    JScrollPane sp = new JScrollPane(table);

    frame.add(sp, BorderLayout.CENTER);

    try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url, user, password);
        String str = "select * from patient ";

        PreparedStatement pst = conn.prepareStatement(str);
        ResultSet rs = pst.executeQuery();
        table.setModel(DbUtils.resultSetToTableModel(rs));


    } catch (Exception exc) {
        exc.printStackTrace();
    }

但是使用此代码时,列名称不可见

try {

   Class.forName("com.mysql.jdbc.Driver");

    Connection conn = DriverManager.getConnection(url, user, password);
      String str = "select * from staff";

        PreparedStatement pst = conn.prepareStatement(str);
        ResultSet rs = pst.executeQuery();
        table.setModel(DbUtils.resultSetToTableModel(rs));

    } catch (Exception exc) {
你可以帮我吗?

谢谢

0 个答案:

没有答案