• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JTable header doesn't show

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got a JTable which is supposed to have headers, but they don't show!
I have:
public String getColumnName( int c ){return headers[c];}
where headers in an array of strings. This function is in my custom model which extends abstractTableModel. I've done this in another part of my code and it works. Why it doesn't work this time is beyond me! Have any ideas?
Thanks!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your problem related to getting a valid value out of the headers array, or that the JTable component in a container is not displaying the headers on the table?
If the first, you may need to post more of your code.
If the second, try putting the JTable in a JScrollPane.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dear,
The solution of ur problem is that just u have the the tablemodel on JTable and the syntax is
jtable1.setModel(customTableModel);
note . customTableModel is the object of defaulttablemodle or any table model.....
Is it ur solution.
Vishal
 
Kate Zoy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, turns out I just forgot to put it in a JScrollPane! That is the only line of code different to my other JTables and I didn't even notice! Thanks so much maggie!
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic