Re: How to merge cells in an irregular fashion within a JTable?
Tuesday, January 15, 2002 01:22 AM
I already managed to obtain a prototype working with low efficiency though!
So far I´ve realised (I would appreciate if someone could check this) that cell merging in a JTable (and probably with any other swing component)can only be done at a low level, that is, rewriting the paint method launched by the UI that paints that specific component.
As it is an irregular shape what I´m trying to show, no other component (such JLabels of JTextfields) can be attached to it for presentation purposes. I decided to simply paint a set of filled rectangles (one per column) and this would make up my particular cell.
For displaying a cell text, I would use the Graphics.drawString method, calculating what coordinates the text should be placed to.
This seems a really tedious work (and in fact it is) but I can´t think of anything else...
Many serious doubts come up to my head now... for example, what the hell is happening with CellRenderers. As I´m not using JComponents for cell representation... are the being called anyway? How can I get rid of this if that happens?
The paint method in the BasicTableUI class is being called a few times before the JTable is displayed...
Finally, this approach seems to work for small tables, such like 20x20 cells or so... but for my specific purpose (and this involves painting a 1440x90 raster) it goes EXTREMELy slow... any ideas?