Forums Register Login

Freezing and Unfreezing rows and columns in JTable

+Pie Number of slices to send: Send
Hi,
We have an requirement in which we need to freeze and unfreeze columns and rows in JTable. This should work similar to that of MSExcel in which a user can select cell and right clicks and freezes/unfreezes the rows/columns.
If anyone has any solution please reply to this .
Thanks in advance,
+Pie Number of slices to send: Send
Do you mean by freezing that the cell is not editable if freezed, and editable if not freezed?
In this case, I'd suggest:
1. MouseListener on JTable that listens for the Popup trigger - if the event is catched, the popup menu for the specific cell is shown.
2. The Popup menu provides the functionality to set an editable cell uneditable or vice versa. If the user selects the action the model is changed appropriately:
for example:
label each cell using new Point(row, col). build a list with all points labeling the editable cells. Add and remove the points whenever a cell is freezed/unfreezed.
Important: after changing the model you need to fire the appropriate event (fireCellUpdated(row, col) or whatever) such that the table updates itself.
hope this was of some help
Chantal
+Pie Number of slices to send: Send
Thanks for replying.
But what my problem is totally different. On selection of particular cell , the columns and rows has to be freezed. This means the entire rows to the top of the selected cell and the entire columns to the left of the selected cell
should be static and should not take part in scrolling.Only the rows that appears below the selected cell and the columns that appears to the right of the selected cell should be scrollable.
This should be exactly same of that MSExcel in MSOFFICE. In MSExcel, you can select a particular cell, and go windows menu and select freeze pane option. Once you select Freeze option you then scroll the sheet. You can notice the difference.
This is what is the requirement in my project.
Prashanth
+Pie Number of slices to send: Send
sorry, I don't use MS Excel.
what you are describing seems to make sense for very large tables. I imagine MS Excel gives it's users the possibility to create large tables. as it is a tool for creating tables this might make sense, but in a swing gui, in most cases, tables mirror the result of a sql query. so why not reduce the result of the query to be more concise?
chantal
Beauty is in the eye of the tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3475 times.
Similar Threads
JTable
jtable
ColumnSpan in JTable
JTable
JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:37:58.