aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to implement  Sortcuts in JTable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to implement  Sortcuts in JTable?" Watch "How to implement  Sortcuts in JTable?" New topic
Author

How to implement Sortcuts in JTable?

Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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

Joined: Feb 24, 2009
Posts: 127

hi , maneesh can you show example that uses
JTable#getCellRect() and JComponent#scrollRectToVisible() methods
.
please help
thanks;-)
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to implement Sortcuts in JTable?