简体   繁体   中英

Table header is not shown using Eclipse

A table header is not shown using Eclipse. How to solve the problem? Only data coming from the database successfully. So I attached below what I tried. 在此处输入图像描述

This is the code that I used to display the data from the database:

void table_load() {
    try {
        pst = con.prepareStatement("select * from registation");
        rs = pst.executeQuery();
        table_1.setModel(DbUtils.resultSetToTableModel(rs));
    
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

table_1 = new JTable();
table_1.setBounds(448, 62, 383, 296);
frmStudentCrud.getContentPane().add(table_1);

table header is not shown

frmStudentCrud.getContentPane().add(table_1);

The header is only shown when you add the table to a scroll pane and add the scroll pane to the frame.

Your code should be:

//frmStudentCrud.getContentPane().add(table_1);
JScrollPane scrollPane = new JScrollPane( table_1 );
frmStudentCrud.getContentPane().add( scrollPane );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM