一个关于jtable放置在jscrollpane的问题?

hojialiang 2002-04-08 05:39:45
每当这样时,jtable的列宽度总是以jscrollpane的宽度等分,如何令jtable宽度大于jscrollpane?
...全文
45 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hojialiang 2002-04-09
  • 打赏
  • 举报
回复
给笑天子 20分
SuperMMX 2002-04-08
  • 打赏
  • 举报
回复
当然不是, 是 JTable 缺省的 resize 模式不一样.

void setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.

static int AUTO_RESIZE_ALL_COLUMNS
During all resize operations, proportionately resize all columns.

static int AUTO_RESIZE_LAST_COLUMN
During all resize operations, apply adjustments to the last column only.

static int AUTO_RESIZE_NEXT_COLUMN
When a column is adjusted in the UI, adjust the next column the opposite way.

static int AUTO_RESIZE_OFF
Do not adjust column widths automatically; use a scrollbar.

static int AUTO_RESIZE_SUBSEQUENT_COLUMNS
During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior.

剩下的就不用多说什么了.

另外: column 的宽度, 缺省情况下用的都是 TableColumn 的 PreferredSize
最好使用这个来确定宽度.
lianyunzxp 2002-04-08
  • 打赏
  • 举报
回复
我感觉好象jtable的宽度没法大于jscrollpane的宽度,大了岂不是出来滚动条了
如果你要是想改变jtable的列宽度
tbl.getColumnModel().getColumn(1).setWidth(100);//改变第一列的宽度

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧