相关疑难解决方法(0)

JTable不会显示列标题

我有以下代码来实例化一个JTable:该表提供了正确数量的行和列,但没有列上标题的标志.

public Panel1()
{
    int  nmbrRows;

    setLayout(null);
    setBackground(Color.magenta);
    Vector colHdrs;

    //create column headers

    colHdrs = new Vector(10);
    colHdrs.addElement(new String("Ticker"));

    // more statements like the above to establish all col. titles       

    nmbrRows = 25;
    DefaultTableModel tblModel = new DefaultTableModel(nmbrRows, colHdrs.size());
    tblModel.setColumnIdentifiers(colHdrs);

    scrTbl = new JTable(tblModel);
    scrTbl.setBounds(25, 50, 950, 600);
    scrTbl.setBackground(Color.gray);
    scrTbl.setRowHeight(23);    
    add(scrTbl);

//rest of constructor
...

}
Run Code Online (Sandbox Code Playgroud)

将此与其他制表代码进行比较,我没有看到任何缺失的步骤,但必须缺少某些内容.

java swing jtable

76
推荐指数
3
解决办法
10万
查看次数

标签 统计

java ×1

jtable ×1

swing ×1