我感觉好象jtable的宽度没法大于jscrollpane的宽度,大了岂不是出来滚动条了
如果你要是想改变jtable的列宽度
tbl.getColumnModel().getColumn(1).setWidth(100);//改变第一列的宽度

解决方案 »

  1.   

    当然不是, 是 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
    最好使用这个来确定宽度.