Article View: borland.public.jbuilder.java.swing
Article #437Re: Swap TAB and Ctrl-TAB for JTextArea
From: Magnus
Date: Mon, 16 May 2005 19:32
Date: Mon, 16 May 2005 19:32
49 lines
2355 bytes
2355 bytes
Thanks Lori,
I will go for the simple:
textArea.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
if(ke.getKeyCode() == KeyEvent.VK_TAB)
{
ke.consume();
[nextComponent].requestFocus();
}}});
It seems to work pretty good.
I also wanted to implement SHIFT-TAB but couldn't find any
KeyEvent.[SHIFT-TAB] so I went to:
http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
Now, this example didn't even read tabs...
I will investigate later,
Thanks again.
Lori M Olson [TeamB] wrote:
> Magnus wrote:
>
>> Hi,
>>
>> I would like to swap the behavior of the TAB function for a JTextArea.
>> I constantly use TAB to go to next focus and always get caught in the
>> text area.
>>
>> I might be bad at finding the simplest thing but I have searched the
>> web, my java books, jbuilder help, ... but can't find any help on this
>> subject. (I found some questions on Google news but no replies).
>>
>> Magnus
>
>
> Doing a Google search on "JTextArea" and "tab" yields many solutions
> from the ridiculously simple:
>
> http://www.devx.com/tips/Tip/13866
>
> To the insanely complex:
>
> http://forums.java.sun.com/thread.jspa?threadID=609727&messageID=3342601
>
Technical Details
Message-ID:
<4288f55a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4288af18@newsgroups.borland.com> <4288beb7@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,21a389bc4e56d7b7 X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 16 May 2005 15:32:48 -0400 From: Magnus <magnus_bjorkman@iwon.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en, sv MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: Swap TAB and Ctrl-TAB for JTextArea References: <4288af18@newsgroups.borland.com> <4288beb7@newsgroups.borland.com> In-Reply-To: <4288beb7@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 71.0.99.227 Message-ID: <4288f55a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1116271962 71.0.99.227 (16 May 2005 12:32:42 -0700) Lines: 49 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail