• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with JTable

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody !

I want to embbed a JTable in my application, that is having variable number of columns in different rows. For example,

row #1 has 3 columns,
row #2 has 1 column,
row #3 has 5 columns,
row #4 has 6 columna,
row #5 has 3 columns,
row #6 has 2 columns,
row #7 has 3 columns,
row #8 has 1 column
-------------------
-------------------
and so on...

I have only the information that how many columns are there in the particular row, but I don't know how to have varying number of columns for different rows.

Can you put some light over this matter?
Thanks in advance...


Paras
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to the Swing/AWT forum where they talk about JTable all the time.

So please post your replies there. Thanks!
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the data source for your JTable?
 
Code Snooker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I am making my own Table model, which is a n X 6 array.
It contains data something like.

"ioeeuiurw.... upto 80 chars" NULL NULL NULL NULL NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" "iye"
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"ioeeuiurw.... upto 80 chars" NULL NULL NULL NULL NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" "99034"
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"ioeeuiurw.... upto 80 chars" NULL NULL NULL NULL NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" NULL
"1" "20.00" "100.00" "xyz" "abx" "oee"

so as the row #1 has only one value then it must show only one column of length of 80 chars, whereas row #2 has 5 values, so it must have 5 columns, and each column may have different precize length but no more than 20 chars each. And total length in each row of all columns must not exceed greater than 80. And so as the above example.

Do you some idea to solve this problem...
If yes then plz. answer it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic