Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages
Started by George
Wed, 21 Apr 2004 19:21
JTextArea question
Author: George
Date: Wed, 21 Apr 2004 19:21
Date: Wed, 21 Apr 2004 19:21
11 lines
1315 bytes
1315 bytes
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? TIA. George
Re: JTextArea question
Author: Paul Furbacher [TeamB]
Date: Thu, 22 Apr 2004 15:01
Date: Thu, 22 Apr 2004 15:01
54 lines
2508 bytes
2508 bytes
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.
Re: JTextArea question
Author: 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads