在 JTable 中查看标题?

发布于 2024-08-24 13:48:22 字数 319 浏览 2 评论 0原文

将 JTable 添加到 JFrame 时,我无法查看 JTable 中的标头。

     String[] col={"Name","ID","Marks"};
     Object[][] data={{"venkat",201,450},{"Ramesh",102,450},{"Rahul",2,430},    {"Thiman",4,434}};
     table=new JTable(data,col);

上面的代码未在 JFrame 中设置标头。 如何在 JTable 中添加视图标题,同时将其添加到 JFrame 中......?

I can't view header in JTable while adding it into a JFrame..

     String[] col={"Name","ID","Marks"};
     Object[][] data={{"venkat",201,450},{"Ramesh",102,450},{"Rahul",2,430},    {"Thiman",4,434}};
     table=new JTable(data,col);

The above code doesn't set header in JFrame.
How to add view header in JTable while adding it into JFrame.....?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我一向站在原地 2024-08-31 13:48:22

您需要将表添加到滚动窗格,或者在需要的位置显式添加标题,

JScrollPane scroller = new JScrollPane(table);

然后将滚动窗格添加到 gui

You need to add your table to a scroll pane, or explicitly add the header where you need it

JScrollPane scroller = new JScrollPane(table);

then add the scroll pane to your gui

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文