Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Add Header names to my columns at JTable?  RSS feed

 
Adrian Pena
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I have my database in MySQL, I'm trying to display this on a table, I already achieved that the size of my table is the same as my database, but my columns are like A, B, C, D, E, F, Gand so on, and I want to give them names.
Since my parameters for the table are ints, I can't use a String Array for teh columns, it won't let me, I have to have both String arrays, or ints, and I use ints due the size of the table.

How can I add a header to each column?
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since my parameters for the table are ints, I can't use a String Array for teh columns, it won't let me,


Of course you can use a String Array for the column names.

Read the JTable API again. Take a look at the different constructors and pick the appropriate on. Or you can use a DefaultTableModel for your table, which also supports a number of constructors.

I would suggest you also follow the link from The JTable API on "How to Use Tables", which provides working examples.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:the link from The JTable API on "How to Use Tables"

(Off-topic: It's interesting how Oracle managed to put redirects in place down to the level of individual pages of the Java Tutorial when they moved it from java.sun.com to docs.oracle.com, but for so much other stuff they didn't bother, or got it wrong. I'm mentioning that because my local javadocs still point to java.sun.com.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!