• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Freeze Pane in JTable

 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JTable that has many number of columns with the CheckBox at the first column of each row. I can delete / commit changes by selecting the check box at the the first column. Since my Jtable has many columns, users have to navigate to the far left to check the CheckBox after making modifications in the row.

Is there a Freeze Pane (as in Microsoft Excel) for columns concept in JTable? The JTable is in a scroll pane so if I move to the far right of the JTable will the check box first column also come along?

Note - I use CheckBoxRenderer to get the CheckBox in the first column.

Thanks,
John
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try Rob Camick's Fixed Column Table.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you could customize your contentpane to add 2 Jtables, one with checkbox and 2nd Jtabel with rest of the columns, when you scroll your horizontal bar, capture the mouse click event and reset the coordinates for Jtable1 to be in a visiable area.....

Sounds more complicated then previous post...but this also resolves your issue.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried Rob Camick's Fixed Column Table but ran to some issues.

1. Since my first column Header is rendered by CheckBoxRenderer. Now if I check CheckBox in the first column header currently it selects all the check box in the first column (its a Check All / Deselect All) Check Box. This functionality does not work if I integrate with FixedColumnTable code like below



2. Some of the check boxes in the bottom go missing in the first column - Please see attached Screen Shot.

3. The first column goes till the scroll pane length and not stop with JTable's length - Please see attached Screen Shot.

I will try the second solution ( making 2 Jtables in my code) and let you know the results.

Thanks both of you for your replies.


JTable.JPG
[Thumbnail for JTable.JPG]
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I fixed the issues i ran while trying to implement Rob Camick's FixedColumnTable. My bad - the issues were due to my custom main table configurations & were rather easy to fix.

Ok now the stupid fixes -

1. Removed CheckBoxRenderer from my main table & gave it to the Fixed Table
2. Made the row height of both main table & Fixed Table to be the same. This ensures check box & other columns were in same line
3. Changed Fixed Table's Background to match the main table background + scrollpane background and thus the grey shade went away.

One more issue if faced & fixed ->
4. While sorting on the main table, the sort does not apply to the checkbox column in the Fixed Table. Solution is to assign the main table sorter to the Fixed Table Sorter.

Thanks to Darryl Bruke to lead me to the solution & Arun for giving an alternative.

I would like to leave the modified code here.


 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I found this post very useful as it met my requirements. But i am blocked only at one point.
Grey colour is not getting removed from my fixed Table.
I am attaching the screenshots. please let me know, how this can be achieved.
Grey-color-tobe-removed.jpg
[Thumbnail for Grey-color-tobe-removed.jpg]
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try fixed.setFillsViewportHeight(true);
 
Sharad Kharya
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked.
Just curious to know. can't the 1 horizontal scrollbar is viewable commonly in fixed + main table. And keep 1st column as fixed.
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic