Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

Displaying a "floating" JLabel at the caret position

Thread view: 
cyberiapc@gmail.com - 30 Jan 2005 10:55 GMT
Hi everyone,

I've got a JTextArea that serves as a very basic XSLT editor. One of
its functions is to allow the user to input elements via accelarators
(e.g. Ctrl+Shift+t inserts a <xsl:template> element). Is it possible to
display a component, such as a JLabel, at the position of the caret in
the JTextArea? The intention is to populate it with information about
what letter inserts what element)

Because my JFrame's LayoutManager is set to BorderLayout, I don't see
how I'd be able to position the JLabel at specific x,y coordinates
relative to the caret.

Thanks for any pointers.
Andrey Kuznetsov - 30 Jan 2005 11:19 GMT
> I've got a JTextArea that serves as a very basic XSLT editor. One of
> its functions is to allow the user to input elements via accelarators
> (e.g. Ctrl+Shift+t inserts a <xsl:template> element). Is it possible to
> display a component, such as a JLabel, at the position of the caret in
> the JTextArea?
yes

> Because my JFrame's LayoutManager is set to BorderLayout, I don't see
> how I'd be able to position the JLabel at specific x,y coordinates
> relative to the caret.
create JWindow with JFrame as owner and add to it you JLabel..
JWindow will be always on top.

Signature

Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Paul van Rossem - 31 Jan 2005 07:36 GMT
> Hi everyone,
>
[quoted text clipped - 10 lines]
>
> Thanks for any pointers.

Why don't you use tooltips? If I understand your problem correctly, this
would be exactly what you need. And you don't have to re-invent the
wheel, keeping things consistent for your users.
Tooltips can be generated dynamically by overriding String
JComponent.getToolTipText(MouseEvent), if that's what you are concerned
about. And if you need to you can even format them with HTML.
<http://java.sun.com/docs/books/tutorial/uiswing/components/tooltip.html>
Paul.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.