JList embedded inside JTextArea
1 posts in topic
Flat View  Flat View

Posted By:   Mehul_Shah
Posted On:   Friday, June 13, 2003 04:55 PM


Is it possible for some sort of selection list such as, JList to be embedded into a JTextArea? So if a user types and as they hit a certain keyword, this list bethat word drops down?

I was trying to override the TextUI with a UI of my own component, but it did not allow me.

Are there any classes or methods which might be able to do this?

Please help, need answer within 3 days. Thanks.

Re: JList embedded inside JTextArea

Posted By:   Bahman_Barzideh  
Posted On:   Sunday, June 15, 2003 01:25 PM

You cannot embed a JComponent in a JTextArea. JTextPane does allow you to
embed one or more JCompoents (including JLists) in it.

You might also want to consider a diffenrent approach. In particular one using a pop-up
window that is displayed when the mouse is over certain words
in the text area (much the same way Microsoft's Word shows
auto complete). If so, you would need to develop a class
that implements the MouseMotionListener (and most
probably the MouseListener) interface(s) and
install it on the text area. You can then detect movement
of the mouse on the text and determine what portion of
the text you are over and whether a pop-up window is required and if so what its contents should be.
You can also develop a specialized Document for your text component. This will allow you to examine each piece of text before it is added to/deleted from the text compoent.
You can then decide whether or not the popup should be shown based on the text the user is typing.

What you are after is doable, but involves a fair amount of work!
About | Sitemap | Contact