I've spent quite some time searching for this and I've only found the GroupableHeader
code. I need one header over 2 columns in a 2 column JTable
. How can this be done without the use of the infamous GroupableHeader
, while keeping the default look and feel of the `JTableHeader?
This is a graphical representations of what I have in mind:
_________________________
| Table Header |
|-----------------------|
| | |
|-----------|-----------|
| | |
|-----------|-----------|
This depends on what eaxctly you want to achieve.
I did something similar by creating my own JTableHeader, which was essentially just a JPanel
.
On it I placed "group" headers on the top row, over the columns I wanted to "group".
Then I cheated and used the existing tables row header and added it to the second row below the header.
This requires some slight of hand, as you need to know the columns you want to group/span and their widths. You also need to monitor for changes in their widths and update the header appropriately.
Most of the implementations I've seen use their own UI implementation, personally I don't like this as it undoes the work of the look and feel you're using.
You could have a look at this which demonstrates a number of interesting things you can do with JTable
s as well multi-column spanning, but again, it's using it's own UI to get it to work.
The implementation we've begin using at work works in the same way and the problem I have with it is that you can see the mouse resize cursor within the group header, which, to me, isn't really what you want the user to see
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With