调整列宽后垂直滚动条消失
我在 scrollPane
中有一个表格。我的表中有 6 列。我希望最后两列比其他列更宽。但是当我设置列的大小后,垂直滚动条消失了。如果我注释掉重置列宽度的代码,一切都会恢复正常。谁能告诉我这有什么问题吗?多谢!!
我复制了几个相关的尺寸:
table.setPreferredScrollableViewportSize(new Dimension(900, 500));
feedback = new JScrollPane(table);
feedback.setMinimumSize(new Dimension(900, 400));
调整列大小的代码:
TableColumn column = null;
for (int i = 0; i < 6; i++) {
column = table.getColumnModel().getColumn(i);
if (i == 4) {
column.setPreferredWidth(250); //third column is bigger
} else {
if (i==5) {
column.setPreferredWidth(250);
}
else {
column.setPreferredWidth(100);
}
}
}
I hava a table in a scrollPane
. There are 6 columns in my table. I want the last 2 columns to be wider than other columns. But after I set the size of the columns, the vertical scroll bar disappeared. If I comment out the code for resetting the columns width, everything goes back to normal. Could anyone tell me what's the problem of this? Thanks a lot!!
I copied several related dimentions blow:
table.setPreferredScrollableViewportSize(new Dimension(900, 500));
feedback = new JScrollPane(table);
feedback.setMinimumSize(new Dimension(900, 400));
the code to resize the columns:
TableColumn column = null;
for (int i = 0; i < 6; i++) {
column = table.getColumnModel().getColumn(i);
if (i == 4) {
column.setPreferredWidth(250); //third column is bigger
} else {
if (i==5) {
column.setPreferredWidth(250);
}
else {
column.setPreferredWidth(100);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法重现您所描述的问题。这可能是您的布局有问题,或者可能需要 设置滚动条策略。
I am unable to reproduce the problem you describe. It may a problem with your layout, or it may require Setting the Scroll Bar Policy.