|
-
Apr 12th, 2004, 04:11 PM
#2
Addicted Member
How custom?
Hello
I think i know what you mean, so here we go
The JTable can take any number of cell renderers, and these are assigned to the column type, e.g. if the column is representing String.class, then you can register a renderer with the Jtable to just render the String column:
Code:
setDefaultRenderer(String.class, new MyStringRenderer)
This means that whenever the table trys to render an object of type String it will use the MyStringRenderer.
You then have to implement MyStringRenderer, now if you choose to implement DefaultTableCellRenderer then you only have to play with one method, and its pretty much a JLabel underneath it all, so you can change the colour of the text and backgrounds etc.. i'm sure you get the picture.
Suns Java site is pretty good for this: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
Now i wasn't sure if you wanted entire columns rendered or individual cells, if you wanted individual cells then you could implement a Renderer and use the Column and Row coordinates to decide what was in it, or use the Object to determine what you were looking at. you'd then simply register it in on the JTable against the Object.class, and i think.. and don't hold me to this, that it will try and render everything for you!
helpful? or have i missed the point?!
Andy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|