🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #540

Swap Enter and Ctrl-Enter for JTextArea

#540
From: John T. Dow
Date: Thu, 16 Jun 2005 04:01
22 lines
1917 bytes
Recently there was a discussion of "Swap TAB and Ctrl-TAB for 
JTextArea". I want to swap Enter and Ctrl-Enter also.

Using keyPressed and keyReleased events I have been able to get Tab and 
Enter to leave the field.

However, I don't know how to make Ctrl-Enter put an "Enter" into the 
text, that is, a hard return.

That's where I need help. It seems that you can't use setKeyChar in 
keyReleased or keyPressed events, only in keyTyped events. But trying 
e.setKeyChar((char)KeyEvent.VK_ENTER) doesn't work.

By the way, my client wants this behavior (his legacy app behaves that 
way) so it doesn't matter what's standard. Actually, it's not 
unreasonable for him to expect to lean on the tab or enter key to move 
through the fields - that is, all fields should behave the same. Text 
areas are used for comments, which sometimes have paragraph breaks.

Thanks.

John
Technical Details
Message-ID: <42b0f990$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,e83a8bc1bbbfe4c9,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 16 Jun 2005 00:01:15 -0400
From: "John T. Dow" <jtdpppoe@earthlink.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Swap Enter and Ctrl-Enter for JTextArea
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 151.201.42.212
Message-ID: <42b0f990$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1118894480 151.201.42.212 (15 Jun 2005 21:01:20 -0700)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail