473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JTextPane - get location of a selection

Hello,

I have a little problem that causes a lot of trouble to my application :).

I've got a JTextPane (but I can change it to anything that can edit a
StyledDocument if it will help) and would like to mark some parts of the
text with different background colours. The selections to mark are
chosen by the user by selecting text and using a keyboard shortcut. So
far, no problem. But additionally I would like to add a "label" to each
such selection. Such a label must not be contained in the text edited.
So I decided to draw the labels on the component graphics.

The problem is when the user selects some text I have got the starting
and ending indices of the selection while to draw a label I need a
position relative to the top left corner of the text field (the labels
must be drawn near the selections chosen). Is there a way of getting
that information out of a JTextPane or any similar text edit box?

Or maybe, there is another way of displaying such labels instead of
drawing them on the component canvas?

Thanks for any help,
Grzegorz Kaczor
Apr 18 '06 #1
0 3420

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tony Burrows | last post by:
I have a JTextPane with several styles. The style data is loaded from/ saved to a file. I can modify the styles at run-time and the new styles are saved to disk. The next time the app is run...
2
by: ENIZIN | last post by:
I am having an interesting problem where I am simply trying to put in country selection popup window on my site. When the user closes the window the popup should call the...
0
by: clase | last post by:
Hi everyone, I need your help! :) I need to build a widget that manages (read, write, edit) XML files. My idea is to build this new component on JTextPane; it allows to use RTM and HTML files so...
2
by: Vish | last post by:
Hi, I am trying to move controls around in a form based on user selection on a combo-box. So i hard coded the location and distances of where and how much to move controls by in my program....
5
by: Alan Little | last post by:
Do a search at this site: http://www.mindsift.com/ Select a non-sponsored link, then give the site a rating. The rating frame closes. Now click your "back" button. If you're using IE, you'll...
1
by: linksterman | last post by:
i have searched and searched to find the answer to this problem, but alas, it eluded me and i had to turn in my project without autoscrolling (which sucks since it is a chat client) i had to use...
4
by: Yellowfin Team | last post by:
Location Intelligence where to from here? Most people have heard of location intelligence tools such as Google Maps, or Geographic Information Systems (GIS). Indeed, mapping technology is used...
5
by: HxRLxY | last post by:
I am an email client. I want to be able to send the emails in rich-text format, so the GUI uses a JTextPane as the Text Component in which the user's message is entered. The problem is that when I...
2
hsriat
by: hsriat | last post by:
Can I change the DefaultStyledDocument of a JTextPane dynamically? What I want to implement is like a document selector. Selecting an item from the list changes the text inside the JTextPane to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.