Article View: borland.public.jbuilder.java.swing
Article #522Re: Swap TAB and Ctrl-TAB for JTextArea
From: Tony
Date: Thu, 02 Jun 2005 04:19
Date: Thu, 02 Jun 2005 04:19
40 lines
2221 bytes
2221 bytes
> 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:
>
I am sure you have figured it out by now, but I was facing the same
problem today and thought it might be useful for someone:
I added the following code to the constructor of the small wrapper class
(TTextArea) which extends the JTextArea
this.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ke)
{
if (ke.getKeyCode() == KeyEvent.VK_TAB &&
ke.isShiftDown())
{
ke.consume();
TTextArea.this.transferFocusBackward();
}
else if (ke.getKeyCode() == KeyEvent.VK_TAB)
{
ke.consume();
TTextArea.this.transferFocus();
}
}
});
Tony.
Technical Details
Message-ID:
<429e88f0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4288af18@newsgroups.borland.com> <4288beb7@newsgroups.borland.com> <4288f55a$1@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 From: "Tony" <aoganesi_a^t_yahoo_._com> Newsgroups: borland.public.jbuilder.java.swing References: <4288af18@newsgroups.borland.com> <4288beb7@newsgroups.borland.com> <4288f55a$1@newsgroups.borland.com> Subject: Re: Swap TAB and Ctrl-TAB for JTextArea Date: Wed, 1 Jun 2005 21:19:55 -0700 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 NNTP-Posting-Host: 69.33.38.98 Message-ID: <429e88f0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1117686000 69.33.38.98 (1 Jun 2005 21:20:00 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail