This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to have JTable with cells spanning on multiple columns? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to have JTable with cells spanning on multiple columns? " Watch "How to have JTable with cells spanning on multiple columns? " New topic
Author

How to have JTable with cells spanning on multiple columns?

Nam Ha
Ranch Hand

Joined: Aug 05, 2011
Posts: 50

Hi my friends,

The question which I am going to post here was posted on Oracle Java forum about 2 weeks ago. However I did not get any answer so please allow me to re-post it here. Hope some experienced guys can help me.

I want to have my table with a cell spans on two columns, like merged cell in Excel.
I found an example here:

http://www.java2s.com/Code/Java/Swing-Components/MultiSpanCellTableExample.htm

But I were not able to get it works, it throws some exception at runtime:



Any help?

Many thanks,
Nam


Java Object Creation
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
some time back this was the fix (unsure if still relevant)

In class: AttributiveCellTableModel,
In method: public void setDataVector( Vector newData, Vector columnNames )

Change the line:
setColumnIdentifiers(columnNames);

To the line:
columnIdentifiers = columnNames;
Nam Ha
Ranch Hand

Joined: Aug 05, 2011
Posts: 50

Hi Micheal,

I followed you suggestion, and it worked!

Great!

Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to have JTable with cells spanning on multiple columns?
 
Similar Threads
Gui button with calendar popup
Moving editable columns in a JTable
problem relating to jpanel background image
Exporting some data to excel
Icon needed in JTableHeader for Sorting