Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how do i get the Row and coloumn of A JTextPane.

Posted on 2004-09-21
6
Medium Priority
?
374 Views
Last Modified: 2012-05-05
I have to get a line of string from JTextPane.
   ie, when we  clicked the mouse right button in the TextPane, the correspoding  line should be displayed . how can i get it?  I tryied to get the Row, Colomn of the JTextPane. but i could not get the Row and Coloumn.
 can you solve this prob?
0
Comment
Question by:djegamsc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:nesnemis
ID: 12119891
I'm not quite sure if you can do that, but if you add a mouselistener and selectd your text first you can use getSelectedText();

Else you can check the mouseposition when you rightclick and calculate the rowNo from that
0
 
LVL 92

Expert Comment

by:objects
ID: 12120038
you could try something like:

int caret = pane.getCaretPosition();
Rectangle rect = pane.modelToView(caret);
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12124036
approximately not accurate

Font font = pane.getFont();
int lineno = evt.getY()/font.getSize();
0
 
LVL 1

Author Comment

by:djegamsc
ID: 12168781

 Hello friends,
     Thanks for your reply.
  Actually wht i did to solve this problem is,
     I calculated line no with help of  some calculation of StartPos, EndPos of the line  by using getCarePosition();
 then Using this startPos, endPos  , we can do Select by using TextPane.select(startPos,endPos);


 

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12446004
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question