JEditorPane - getting Selected Text or Active Line number

Is there any predefined method that will give me the current line selected or the line at which the cursor is?
I am displayed a piece of java code in my JEditorPane, the user can browse through the entire file.. and I need to call an event when a user selects/double clicks a particular module name or based on the current line number where the cursor is. Is there any simple technique to get the line number or the current highlighted text?
I am relatively new to JEditorPane. Also If you think I shoudl go upon writing an actionListener, a mouse of keyboard... please let me know how to go about it. I keep getting confused.
Thanks,
Sirish

In the future, Swing related questions should be posted in the Swing forum.
there any simple technique to get the line number Well, a JEditorPane is typically used for displaying HTML. So does a line number make sense when you don't know the contents of the HTML. If you simply have lines of text then you should be using a JTextArea or a JTextPane.
Check out this posting for a method to return the line number at a give caret postion:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=608220
or the current highlighted text?Read the API. A get??? method will do what you want.

Similar Messages

  • Help - JEditorPane drag selected text behavior/problem

    Hi All,
    I'm working at adding new functionality to the JEditorPane. Everything was going ok, but I noticed this interesting behavior that hopefully there is a solution to.
    When you select some text in the JEditorPane with the mouse and then drag the selected text to another location, the text moves just fine. However, depeding on when you drag the text, something interesting happens.
    Here is the senerio. While the text is already selected you noticed the cursor blinking.
    (1) If you drag the selected text while the blinking cursor IS visible, the cursor will continue to blink after you drag the text to its destination.
    (2) If you drag the selected text while the blinking cursor IS NOT visible, the cursor will be invisible after you drag the text to its destination.
    So (2) is really the problem. The only way I've been able to get the cursor to start blinking again is to issue a cut, copy or paste method from the JEditorPane object.
    Has anyone else found this problem and maybe a solution to it. I've disabled all the extra stuff I extended on the JEditorPane class, but it didn't seem to make a difference.
    Thanks.
    Justin Circelli

    There are several approaches. You can add FocusListener to the drop target or drag source and put your code in focusGained() or focusLost() accordingly.
    Another way is to return focus to the drag source if DnD failed as you tried. First check whether mouseReleased(0 is invoked. If it's invoked try to put your code into SwingUtilities.invokeLater()
    regards
    Stas

  • ABAP Editor - Get selected text

    Hi experts,
    I created a menu exit in se38 and i wanted to retrieve the text that was selected in the editor once the menu item has been clicked.
    Is that possible?
    Thanks.
    FARTAL.

    This only provides the full text of the text box... I was hoping to get the selected text...
    Now, I know that the selected text is lost when the field loses focus, but I also know that the selected text remains selected until after the exit event fires fully.
    To test this, thow an 'xfa.host.messageBox("is it still selected?")' into the exit event of a text box... Run the form, write a line, select a part of it, then exit the text box. You'll get an alert, and the text is still selected. The way I see it, this would be as good a time as any to get the selected text, I just need to know how.
    I've tried several javascript methods, but they were all designed for web browsers. The only thing else that is similar that I can find is the selStart/selEnd attributes that get filled  with the selection indexes on the change event. I'm just now looking at how these attributes work.
    Does anyone know if it's possible to use these attributes to get the selected indexes on exit?
    Thanks again for any help.
    - Scott

  • Get selected text from af:inputText

    Hi,
    I am using an <af:inputText> component, within which I would want to know if any text has been selected.
    InputText.getValue() would give me the total value that is there within the inputText component. But if I have selected a part of the text, I would like to get hold of that.
    Is there a way in ADF, to get that selected Text ?
    Thanks,
    Pawan.

    Hi,
    If I am to use javascript, can i directly use the IE/FF (browser-specific) code to get hold of the selected text ?
    The ADF javascript API doesn't seem to have a way to get the selected text.
    Thanks,
    Pawan.

  • How to get selected text values in a textarea by mouse click?

    Hi Everyone,
    What I am trying to do is to click on some texts in a textarea, then get the selected text value.
    If you guys have used an accounting software called Simply Accounting, you might understand better.
    I list all my customer names in a textarea. What I want is, when I click on one customer, another GUI pops up with this customer's information. My problem is that I don't know how to get the selected text value from a textarea.
    Could anyone give a hand here? Thank you in advance.

    Is there some reason you aren't using a JList or
    JTable to display
    the user names/information?Thank you for es5f2000's reply. You just gave me a better idea! There is not a particular reason I have to use TextArea to list my customers. As long as the component can make my idea alive, I definitely use it. Still, if there is any way to get a selected text value, it will help me a lot with my project. Thank you.

  • How to get the texts for each line item for Sales order in a smartform

    I'm createing a smart form in which i need to display certain texts for each line item of a sales order. How can i get those??
    I'm trying with the table STXH and FM read_text... but i'm not clear how and what i'm getting... can anybody pls help me.....

    Hi There,
    But then i will be getting only the value. i want to link that against the particular material of the Purchase Order.
    Like for ex:
    PO No.  Material Code        Line Item        Basic        Excise       Tax       Inv Value
    0000001 5000251                010               100           16         4.64      120.64
    0000001 5000252                020               200           32         9.28      241.28
    Can u help me on this?
    Regards,
    Jitesh

  • How to insert text from saved text file using line number to indesign document to specific cursor point?

    i'm using indesign for make books. always i need insert quotes from some holy books. so i need to insert text using verse number

    i'm not asking about
    b
    u
    l
    l
    e
    t and
    n
    u
    m
    b
    e
    r
    i
    n
    g
    sorry for my bad english
    my target is simply insert pre typed sorted texts using the verse number. for example. i have Holy Quran full text . it have about 6000 verse. suppose i need chapter 3, verse 5 in to my paragraph. manually i goto that text file and copy the text paste it here. but i need it automatically using page number/ verse number/ unique id. script / addins .
    approximately like "data merge " in design.

  • Logic to get same text for 2 line items

    hi all,
    i have an issue in my report,
    i have a final internal table. fileds in the table are
    bukrs  belnr gjahr buzei  sgtxt
    0010  12345  2008  01      text
    0010  12345  2008  02      -
    now the problem is if the belnr is same thn in the final internal table the above sgtxt shoud come for second line item if the second line item is initial ,i shoud get the output as
    bukrs  belnr gjahr buzei  sgtxt
    0010  12345  2008  01      text
    0010  12345  2008  02      text
    please help me how to write code for this

    Hi,
    Use this :
    Loop at itab.
    if itab-sgtext is initial .
    read table itab into wa with key bukrs  =  itab-bukrs
                                       belnr = itab-bukrs
                                       gjahr = itab-bukrs
                                        buzei = itab-bukrs
                                        sgtext <> space.
    if sy-subrc eq 0.
    itab-sgtext = wa-sgtext.
    modify itab transporting sgtext.
    endif.
    endif.
    endloop.
    Hope this helps.
    Rgds,
    Sandeep

  • Inserting text at a specific line number.

    Hello,
    My need is to insert specific text at a line number to be determined at run time. I know how to write to new files and append to existing ones, but I have not been able to find any documentation displaying how to traverse to a specific line in a text file. More specifically, of course I know how to use looping constructs, but I have seen no file I/O classes with a "skip line" method to get to my insertion point.
    Thank you.

    depending on the size of the files read them into a buffer use a loop to get to a specific point and write back to file.*
    Note I am sure there are many better ways to do this but this was the first thing that came to mind that would be easy for a new person to get.

  • Text is selected one or two lines away from where cursor is located

    I'm viewing a PDF in Adobe Digital Editions 4.0, and when I try to select text, it actually selects text 1-2 lines off from where the cursor (I-bar) is located.  This makes highlighting text extremely difficult.  The PDF was created in Acrobat from a .docx file.  I've also tried creating the PDF from MS Word for Mac 2011.  Same problem.
    If I try opening the very same PDF file in Adobe Reader, the cursor highlights text just fine.  If I open it in Preview, it works fine too.  Just won't work in Adobe Digital Editions.
    System:  Mac OS 10.10 Yosemite

    You say your Powerbook but your profile indicates a MacBook Pro. Sounds more like a hardware issue than anything else. Post over in the hardware forum area of the Mac you have.

  • Ways to get the line number in sapscript form?

    Hi, all.
    May I know whether that there are ways to get the line number in sapscript form?
    For example, I want to get to know the certain line number in the MAIN window.
    Thanks in advance.

    Thanks Naimesh Patel  .
    Is there anyway to get the PENDING_LINES  value in the script?
    Because i can't modify the standard print program, i can only edit the Sapscript Form and add in some extra subroutine only.
    tnx.

  • Everytime I get an email, I get a text message from Verizon

    I posted this in the Apple forum. I think it may go here instead, maybe? Anyway ...I had the Droid 4, but decided I wanted the Iphone, so i switched yesterday. Once activated, within minutes, i started getting a text message from the number 625-0. The text message always says VZWNMN:1 It's always the same text message, from the same number. When it started, I hadn't had any new apps or email accounts set up on my Iphone. I have read stuff about this via google. The majority says its something to do with the mail set up on my phone. It started before i set my email accounts up. However, I did have my accounts set up on my Droid 4 that i returned. I had done a factory reset before turning that phone in though, so they should have been deleted. Now every time I get an email I get that text. I have unlimited texting, so the pricing isn't an issue. I don't like receiving random texts though. Any help would be greatly appreciated. I have replied to the text with "stop, unsubscribe, delete, ..." and various others that one would normally use.

    I was one of the folks saing its on your email side but this explanation is a lot better and now I agree its obviously not your email thats the issue...
    try this
    1.  Login to your Verizon account.
    2.  Click on “Account” at the top and then “Change Features” from the bottom right.
    3.  Select the device you would like to remove the service from.
    4.  Then scroll down until you find “Contact Management” and click “Remove

  • Problem selecting text in PDF created by MS Word for Mac 2011

    I'm viewing PDFs in Adobe Digital Editions 4.0, and when I try to select text, the text that actually gets selected is 1-2 lines BELOW where the cursor (I-bar) is located.  This makes highlighting text extremely difficult.  This only seems to happen with PDFs that were created in MS Word for Mac 2011 and viewed in Adobe Digital Editions.
    If I try opening the very same PDF file in Adobe Reader, the cursor highlights text just fine.  If I open it in Preview, it works fine too.  It just won't work when viewing the PDF in Adobe Digital Editions.
    System:  Mac OS 10.10 Yosemite
    I have not been able to find any info on this issue anywhere, and if anyone knows a fix or workaround, I would greatly appreciate the help.

    DHodges wrote:
    Thanks; this last reply came closest to 'solving' the issue. While I selected font sub, it at first had no affect on the document.
    I then went back to prefs and set the compatability dropdown from 'Custom' (where it had defaulted) to 'Word 2004-2007', assuming these docs were created from a recent past Windows.
    I 'Saved As' a Word for Mac " .docm "
    Whoa... the extensions mean something. Your original problem (document shows bold, italic, underline, but tables and other complex formatting are lost) sounds as though the document was being exported as a .RTF, a Rich Text Format file. If you save as a .DOCM, that's a Word Macro Enabled Document. Regular Word 2007, 2008, 2010 and 2011 docs are .DOCX. Regular Word 97 through 2004 docs are .DOC. You need to save that document as a .DOCX or a .DOC or you're gonna have problems later.
    - and the documents appear normal (though I had to switch one to 'Portrait' as it for some reason wanted to display in landsacpe.
    Normally you'd have to select page orientation.
    So, poor testing on my part. I have no idea which of the above steps fixed it but I'm guessing the 'Save As' to my version of Word.
    If so, it would appear the 'Compatability' feature was not working at least on these two documents.
    Word's compatibility feature is supposed to ensure that a document you produce is compatible with the target version of Word. If you turn the compatibility stuff on then you will be warned if you are using Word 2007 through 2011 and you use a feature that earlier versions of Word do not have. Microsoft shipped a translator which works with Office 2003 and 2004 and which allows Word 2003 or 2004 to read Word 2007, 2008, 2010, or 2011 documents (.DOCX) and to save them as Word 97 through 2004 documents (.DOC) _as long as they don't have any incompatible features_. Word's compatibility features doesn't do much for .RTFs or for .DOCMs.

  • How to read current line number in function module sourrce code?

    Hi All,
    How to read current line number in function module sourrce code?
    regards,
    Anuj

    If you have new editor you would be able to see the line number. 
    Or in the Dump screen - there is a button called Debugger - click that you would be able to see the code where dump has occured..  you would be able to find the line number from there.
    To get the new editor with line number , you need to change the settingsin SE38.
    Regards
    Vivek

  • INCLUDE BDCRECX1 not displaying selection text in selection screen.

    In my BDC program in using INCLUDE BDCRECX1, When i execute program in selection screen i am not getting selection texts.
    what is the problem?

    You are not getting selection texts because you have not maintained text symbols in your BDC program,

Maybe you are looking for

  • Upgrade to Version 7.1 (11D167)

    My iPad (retina) has slowed down since the upgrade to Version 7.1 (11D167) and I am not sure but think the battery is not lasting as long. When I say slow down I mean that some pictures (which never gave me probs) are now taking a loooong time to loa

  • Why is the Nike   apps different on the iTouch and iPod nano

    Can someone explain why Apple put different apps on iTouch and iPod nano and call it only Nike +. There are obvious difference in the apps. I want the app that stores heart information...but the Nike + app on the iTouch only records distance ran. Why

  • Switching your Primary Monitor - SOLVED

    EDIT : Of course, I solved this right after I posted the question. In the System Preferences > Displays > Arrangement panel, you can drag the menu bar to the second monitor. Hello all, I was wondering if there is a way to switch which monitor Tiger u

  • Using UPDATE in reporting

    Hi all,       I require the procedure to use UPDATE DB table in reporting , Such as in case of LFA1, I want to update LFA1 directly and change some of the mentioned fieldss to Hardcoded values and some of them are to be initilased from the internal t

  • ICR PROCESS 003 : FBICR3

    Hi experts, When I execute the document selection, even if I select two SL partner or more, the result is the same. I don't understand why I have documents that are duplicated after execute selection and assignment transactions. Is it a bug or bad se