Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to implement Sortcuts in JTable?

 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, all
i searched forums on this topic but not found..
i created JTable that has 8 colums.
i need to implement shortcut such for moving from first colum to last colum by pressing ctrl+(left arrow key) , so that user will be able to see data from first and last column without moving horizontal scroll bar..

please help me..

thanks;-)
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way of doing it is by using key bindings
You will need to define your own bindings and when triggered reorder the columns as required.
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, maneesh thanks for reply .

i got your point.
you told about re-ordering columns, why to do so?
can't we make something that moves horizontal scroll bar automatically to last column?
can you help in this?

 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the feeling you wanted to display the last column adjacent to the first column. My bad!
Check out JTable#getCellRect() and JComponent#scrollRectToVisible() methods which you can use for programmatic scrolling
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi , maneesh can you show example that uses
JTable#getCellRect() and JComponent#scrollRectToVisible() methods
.
please help
thanks;-)
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, we do not hand out ready made code here at the ranch.
Show us what you have got and we will help you point in the right direction.
While posting your code make sure it is sscce code Please do click on the link to find out what sscce means.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic