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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple JTable question

Status
Not open for further replies.

Impaled

Programmer
Apr 11, 2005
6
US
I should start by saying, I'm new to java programming.

I have a JTable, and I guess it is their default behavior to allow users to click and hold the header of a column and move the column around. I have looked everywhere online, and I must not be wording it right, because I can not figure out how to stop this behavior. I have tried pretty much everything I can think of.

It is in a scroll pane. Thank you ahead of time for any replies :)
 
The JTable-API is a nice place to search for hours and days.
Code:
 class UnmoveableTableColumnModel extends DefaultTableColumnModel
{
	public UnmoveableTableColumnModel ()
	{
		super ();
	}
	
	public void moveColumn (int columnIndex, int newIndex)
	{
		System.err.println ("movin blocked from " + columnIndex + " to " + newIndex);
	}
}

// usage:
	table.setColumnModel (new UnmoveableTableColumnModel ());

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top