Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change width of JTable in JScrollPane ??

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi!

I have a JTable in a JScrollPane. After a lot of research I finally managed to set the columns width for the table. But how can I change the width of the table itself?

I already tried:

Code:
	ttmCorrections		= new TisTableModel(vecCorrections, vecCorr_Headers);
	tableCorrections	= new JTable(ttmCorrections);
	tableCorrections.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	setColumnWidth(new int[]{200, 200, 200, 200, 200, 200, 200, 200, 200});
	scrollPane_CorrTable	= new JScrollPane(tableCorrections);
	scrollPane_CorrTable.getViewport().setViewSize(new Dimension(300,300));

But the setViewSize() methode doesn't seam to have any impact on the size of the JScrollPane at all.
I put the JScrollPane in a JPanel with GridBagLayout... might this be the problem?

I am really fishing in the dark...

Cheers

frag

patrick.metz@epost.de
 
Ok.... forget it. I have not seen the JScrollPane's setPreferredSize(Dimension) methode. After some hours of research in several forums and in the Java API you really go mad.

Sorry for the question. :-(


frag

patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top