---
title: "swing 调整table列宽"
author: "hzhlu"
date: "2011-09-27T11:25:18Z"
tags: []
categories: ["编程语言"]
slug: "swing-table"
draft: false
lastmod: "2011-09-27T11:25:18Z"
id: 1181397
url: "https://hzhlu.iteye.com/blog/1181397"
---

	/**
	 * 调整列宽
	 */
	private void adjustColumnWidth() {
		// Tweak the appearance of the table by manipulating its column model
		TableColumnModel colmodel = table.getColumnModel();

		// Set column widths
		colmodel.getColumn(0).setPreferredWidth(20);
		colmodel.getColumn(1).setPreferredWidth(20);
		colmodel.getColumn(2).setPreferredWidth(40);
		colmodel.getColumn(3).setPreferredWidth(80);
		colmodel.getColumn(4).setPreferredWidth(200);
		colmodel.getColumn(5).setPreferredWidth(5);
	}