djegamsc
asked on
how do i get the Row and coloumn of A JTextPane.
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?
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?
you could try something like:
int caret = pane.getCaretPosition();
Rectangle rect = pane.modelToView(caret);
int caret = pane.getCaretPosition();
Rectangle rect = pane.modelToView(caret);
approximately not accurate
Font font = pane.getFont();
int lineno = evt.getY()/font.getSize();
Font font = pane.getFont();
int lineno = evt.getY()/font.getSize();
ASKER
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,e
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Else you can check the mouseposition when you rightclick and calculate the rowNo from that