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

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

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.

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?

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.

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

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

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

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??

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.