JTable列标题不可见 [英] JTable column header not visible

查看:107
本文介绍了JTable列标题不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列标题在我的JTable中不可见我创建了一个JPanel并将JTable添加到JPanel。

column header not visible in my JTable i have created a JPanel and added the JTable to the JPanel.

Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3"},
                { "Row2-Column1", "Row2-Column2", "Row2-Column3"} };
            Object columnNames[] = { "Column One", "Column Two", "Column Three"};
            JTable jTable = new JTable(rowData, columnNames); 


推荐答案

JTable的API声明:

The API for JTable states:


请注意,如果您希望在独立视图中使用JTable(在JScrollPane的
之外)并希望显示标题,您可以获得它使用
getTableHeader()并单独显示。

"Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed, you can get it using getTableHeader() and display it separately."

或者只需将表格添加到滚动窗格,然后添加你的滚动窗格到面板......

Or just add the table to a scrollpane, and add your scrollpane to the panel...

这篇关于JTable列标题不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆