954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Jtable

I am trying to insert a jtable into another jtable is that possible. Please help

kahilw
Newbie Poster
12 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

if u want to create the table inside a cell, i don't see any reason why it is not possible to create!

orko
Junior Poster
164 posts since Apr 2006
Reputation Points: 46
Solved Threads: 11
 

I'm sure that it is possible, yes, but the real question would be why? There is probably a more appropriate arrangement of your UI elements that would be less troublesome.

When embedding components into a JTable, there are many cases where you will have to make sure events are forwarded along to the embedded component so they behave as you expect them to. JButtons and click events as an example of this. The JTable will process these events for itself first and may not pass them along to your component as you would expect.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

Tell us exactly what your UI is to accomplish so that we might possibly find a better alternative for you other than inserting a table into a table.

Unless you mean just merge two tables?

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 
Tell us exactly what your UI is to accomplish so that we might possibly find a better alternative for you other than inserting a table into a table. Unless you mean just merge two tables?



I have a table that is populated with data. the table consist of 6 columns. I then went in a inserted blank row in every other row. Instead of inserting a blank row I am trying to insert a component such as a textfield or a table with only one column so that the table has data in the first line consisting of 6 columns and after that there is a blank space in the next row and so on.

kahilw
Newbie Poster
12 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

What is the intended purpose of the blank row? It doesn't sound as if you need to insert another table for anything.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
What is the intended purpose of the blank row? It doesn't sound as if you need to insert another table for anything.

I need a long string of information to be placed in the blank row, do you have any suggestions if you don't think that I need a another table inserted there

kahilw
Newbie Poster
12 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

I am trying to insert a jtable into another jtable is that possible. Please help

kahilw
Newbie Poster
12 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

i still can't understand how u r gonna insert table inside of another table. ... :-S... do u wanna say dat u want to insert the table inside of a cell??

orko
Junior Poster
164 posts since Apr 2006
Reputation Points: 46
Solved Threads: 11
 
I need a long string of information to be placed in the blank row, do you have any suggestions if you don't think that I need a another table inserted there


Even inserting another table in the row will not produce the effect you want, which I assume is a cell that spans all of the columns. The JTable just isn't put together that way.

It may be possible to create your own implementations of TableModel and TableColumnModel (which may or may not require further extension of JTable and JTableHeader, but I am thinking it wouldn't), which effectively manage two separate models for the table to display. That is the only way I can see you getting the desired effect if you must stick with a JTable.

If you don't need the info on the blank row to be visible at all times, but rather when a data row is selected, you could place that info in a separate text area.

If you need to maintain the spreadsheet-type feel and interaction is limited to navigation, JEditorPane or JTextPane with HTML might work out for you, since that output would be easy with HTML tables and HyperlinkListener can be used to provide some interactivity with the data.

Those are the only suggestions that come to mind without knowing the full scope of your data display and interaction needs.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
i still can't understand how u r gonna insert table inside of another table. ... :-S... do u wanna say dat u want to insert the table inside of a cell??


Placing a table into a cell could also work, how could I go about doing that

kahilw
Newbie Poster
12 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

The same way you'd do it for placing any other type of component in a cell. I'd suggest reading up on table cell renderer, do a little google searching and see what you come up with.

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You