Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to customize JTable to look something like this?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to make a professional JTable style for the sales report. Any good links that can get me started?
The major question is how do I set the value of individual cell?

table layout.png
[Thumbnail for table layout.png]
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your app a GUI or just a report? If the latter then I suggest you look into Jasper Report and build the layout.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
it needs both a gui and a printed one
i wonder how to control individual cell width color indentation underlining etc
thanks
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the top 2 sections can be a bunch of labels or text output. The real table is the one at the bottom... also I see you have a + in one those columns allowing user to expand/collapse. This you will need a JTree inside JTable.

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote: I see you have a + in one those columns allowing user to expand/collapse. This you will need a JTree inside JTable.

Right. You need to use a tree-table component for that. SwingX(from SwingLabs) provides a JXTreeTable component for the same - I think NetBeans has a Outline component for the same.

And for the coloring, you need to write custom renderers. You can read about renderers here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic