Article View: borland.public.jbuilder.java.swing
Article #1051Re: JTextArea question
From: George
Date: Thu, 22 Apr 2004 15:42
Date: Thu, 22 Apr 2004 15:42
72 lines
2922 bytes
2922 bytes
Thanks for the help....your suggestions helped me to solve the problem. Just for reference: public Point getMagicCaretPosition() returns the position relative to the component. public Point getLocationOnScreen() gives the origin of the component relative to screen. Thanks again. George "Paul Furbacher [TeamB]" <pfurbacher@mac.com> wrote in message news:4087de4d$1@newsgroups.borland.com... > George wrote: > > > I have a JTextArea in which a user types SQL Commands. I'd like to provide > > a token-completion feature i.e when the user types CTRL-space I want to > > bring up a window with a list box of certain database object names (similar > > to what JBuilder provides in the editor). > > > > My problem is where to position this window. How can I go from the caret > > location of the JTextArea to the x-y coordinates needed to position the > > window? > > Well, the problem should be solvable by drilling > down in the relevant component hierarchies: > > Just looking at the JTextField/JTextComponent API, there's > > public Caret getCaret() > > > Looking at Caret, there's > > public Point getMagicCaretPosition() > > > If the returned point is relative to the > component itself, do the math after getting > the origin of the component. There are > a number of relevant Component methods: > > public Point getLocation() > > public Point getLocationOnScreen() > > > That's how I would proceed in trying to > solve the problem. I don't have the time > to test whether these would actually solve > your problem. Give it a try. > > > -- > > > Paul Furbacher (TeamB) > > Save time, search the archives: > http://www.borland.com/newsgroups/ngsearch.html > > Is it in Joi Ellis's Faq-O-Matic? > http://www.visi.com/~gyles19/fom-serve/cache/1.html > > Finally, please send responses to the newsgroup only. > That means, do not send email directly to me. > Thank you.
Technical Details
Message-ID:
<4087e787$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4086c951$1@newsgroups.borland.com> <4087de4d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,36cb0f214b8bd976 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-04-22 09:01:02 PST From: "George" <geo_54321@yahoo.com> Newsgroups: borland.public.jbuilder.java.swing References: <4086c951$1@newsgroups.borland.com> <4087de4d$1@newsgroups.borland.com> Subject: Re: JTextArea question Date: Thu, 22 Apr 2004 11:42:27 -0400 Lines: 74 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 63.119.115.129 Message-ID: <4087e787$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1082648455 63.119.115.129 (22 Apr 2004 08:40:55 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail