Re: JList embedded inside JTextArea
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!