Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / May 2004

Tip: Looking for answers? Try searching our database.

Moving between JTextPanes with TAB key?

Thread view: 
eeyimaya - 26 May 2004 16:06 GMT
Hello,

I have a panel in which I placed 4 JTextPanes. I want to move cursor
with TAB key between JTextPanes but when I pressed TAB it inserts TAB
char.

How could I achieve to move between JTextPanes with TAB key?

Thanks....
Morten Alver - 26 May 2004 16:59 GMT
> I have a panel in which I placed 4 JTextPanes. I want to move cursor
> with TAB key between JTextPanes but when I pressed TAB it inserts TAB
> char.
>
> How could I achieve to move between JTextPanes with TAB key?

I'm not sure if this is the most compact code to do it, but:

 HashSet keys =  new
HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
 keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB")) ;                
ta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
keys) ;
 keys = new
HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
 keys.add(KeyStroke.getKeyStroke("shift pressed TAB")) ;
 ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
keys) ;

--
Morten
Morten Alver - 26 May 2004 17:01 GMT
>  HashSet keys =  new
> HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
[quoted text clipped - 9 lines]
>  ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
> keys) ;

... and assume that "ta" is your JTextArea.

--
Morten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.