Updating the Line number on status bar.

Hi all,
I have developed an editor using swing, however I have used the JTextpane class to display the text. I had did of trouble with features such as go to line as this class does not support methods such as getLineCount in the JTextArea class. However I over came this by writing the method shown below.
The problem is that I want to show the current line number on the status bar. When do I call this method? After every '\n'?
The setLine Number method is below.
Thanks for your help
Ciara
public void setLineNumber(int num) {
int lineNum = 1;
int lastNewline = 0;
char text[] = editor.getText().toCharArray();
if (num < 1)
return;
if (num == 1) {
editor.setCaretPosition(0);
return;
int i;
for (i = 0; i < text.length; i++) {
     if (text[i] == '\n') {
     lastNewline = i;
     lineNum++;
     if (num == lineNum) {
     editor.requestFocus();
     editor.setCaretPosition(lastNewline + 1);
     return;
}     

Perhaps extending a PlainDocument is better, if line
numbers are meaningful for your application.
About your method, mind that getText can be quite dear,
so it is better not to call it if you don't need it.
For a more efficient alternative, look at Document.getText(int offset, int length, Segment txt)It uses a Segment (un unguarded string) pointing directly
into the document, which you can use much like a char
array.
As to your question, I would define a CaretListener
so as to update the status bar when the caret moves.

Similar Messages

  • I updated to ios 5.1, after updating, now my screen is stuck with the apple logo and status bar and isn't doing anything....HELP

    I updated to ios 5.1, after updating, now my screen is stuck with the apple logo and status bar and isn't doing anything....HELP

    The typical fix if the progress bar totally freezes - meaning no movement at all for more than 20 minutes - and iTunes will no recognize the device - is to try to put the iPad into recovery mode. That is explained here.
    iPad: Unable to update or restore
    However, don't jump the gun. Keep an eye on the progress bar and if it is moving at all - even very slowly - let it go for a while. I'm updating my iPod touch first and the progress bar is moving but very slowly.

  • How to read a file and save the line number of  the last line read?

    Hi,
    I am using RandomAccessFile and file as my class. I am trying to read a log file as it gets updated and print it out to a java window. i so far have the framework setup but dont know how to save the last line number so.
    i need this variable so i dont reprint out the same line numbers to the java window. please advise.
    thanks!

    hi,
    i now have the line number of the last line read, but now when i reopen the file, how can i skip that number of lines?
    thanks,

  • IPad 2 update/firmware 6.1.3 status bar stuck

    It won't let me update the iPad to the newest update.
    The apple logo and status bar screen comes up, but it gets stuck around 10% everytime.
    It's already in DFU mode.
    Any help would be appreciated.

    I'm saying to wait a bit longer. If it were mine, I would want it to work in every aspect and fashion. I will ocassionaly have connection issues on mine, but only occasionally. I can usually resolve them on the spot.
    It sounds odd to me that it would start working with your home network all of suddent without making any changes. However, I've had similiar experiences with computers and electronic devices in general. Having trouble connecting to one particular network, other than at home, would be something that I could live with. Having trouble with many, I could not live with.
    How did you restore it last time? If you used itunes then try directly on the ipad. Do the opposite of what you did before.
    Be aware, this might put you back at square one again with the wifi issue at home.
    But if it were me, I would restore back to factory settings again, just to satisfy my own curiousity.
    How to restore
    Via itunes
    http://support.apple.com/kb/HT1414
    via device
    settings/general/reset/erase all content and settings

  • Removing the 'Warning Java Applet' Status Bar

    Hi,
    I've written an applet that does not require access outside the sandbox so doesn't need signing. However, it pops up an instance of Window, and because it's not signed the window has a status bar across the bottom which says 'Warning Java Applet' or something similar depending on the browser. Is there any way to remove this status bar without signing the applet or changing the security settings of the browser. I guess it must be added to the window so maybe it's just a component that can be removed, but how?
    Thanks in advance

    Today the Security Warning sign appeared at the bottom of my computer screen - how do I get rid of it. I do have Java whose icon used to be in the lower right hand section of my screen - along with all the other icon programs that I have.
    Now the icon is no longer down on the bottom right of the screen, but in the middle with a Security Warning -(the wording) next to the jave icon.
    This is really annoying me - how can I get rid of it, and - why did it appear here?
    Anxiously awaiting your reply.
    Donna

  • Show the object and the line number, where the error happens in Forms

    Hi!
    Al lot of our programmer use the ugly when others clause to raise messages like "error <sqlcode> happens in ....". Often this hides the really error in some underlying procedures. Is it possible to call the error stack from forms like in 10g database dbms_utility.format_error_backtrace? Actually FRM-40735 hides all this information. This should be work for client and database pl/sql errors!
    With kind regards

    First of all, send every programmer in your organization a message to STOP doing that. I am afraid there is nothing you can do when you have to call some stupid code from your form that contains the when others then... sequence.
    Below is an email I sent out just two months ago. I'll share it with you:
    Hi _______,
    I looked over the _________ package to try to determine why it was so difficult to find the source of the problem. The problem was that the line number reported when the job failed was line 326, which is the Raise command at the end of the __xyz__ procedure.
    When someone writes:
          exception when others then raise;it causes line number reporting to fail when an unexpected Oracle error is encountered. Furthermore, the line does absolutely no good, because Oracle will automatically raise unhandled errors without that code.
    The only thing that code does is cause problems when someone looks for the source of a failure. Without that code, job failures can be located in just a few minutes.
    That same code sequence is repeated three times in the _________ package. The problem may also exist in the __abc___... functions that the _______.lookup_xxxl function calls, since no line numbers were reported from there, either. It would be very helpful if you would remove the problem code, and PLEASE instruct everyone on your staff to never use that sequence anywhere.
    - - - - - - - - - - - - - - - - - - - - - - end of email - - - - - - - - - - - - - - - - - - - - - -
    Now, in addition, you can trap FRM-40735 in your on-error trigger and then display the message found in DBMS_ERROR_TEXT. In fact, you might try the format_error_backtrace from there, too.

  • OracleSOA - File Adapter - Correct mechanism to get the line number from the file

    We are using Oracle SOA process to read data from a file, process the data and write it to the database. SOA process is created using Oracle File Adapter to read the data, Oracle BPEL to transform & process the data and Oracle DB Adapter to write the data into the database.
    Oracle File Adapter uses native schema to process the fixed length data in the file. The number of rows in the file may exceed more than 500,000, to support processing of large files we use chunk size in the file adapter as 4000 rows. In each read operation, file adapter reads the data that matches to the schema, there might be few rejected rows as well.
    Oracle File Adapter property - jca.file.LineNumber gives me only the line number till what line the data is read. Is there any way to get the line number in the xml message, which exactly matches to the line number in the file.?
    Flat File Format: (Every file has one header, trailer and multiple data lines),
    HEADER02 -
    L01
    L01
    L01
    TRAILER02
    Line number is one of the crucial requirement in the development of the SOA service, this is used to back trace the information from which source and line the data has come.

    Hi Anshul,
    Thanks for sharing your thoughts.
    I am using DB adapter to insert the data into db.
    While doing the xsl transformation I can get the index of the message using position(), but that is not the correct way as there can be rejected lines by the file adapter.
    Even if I maintain a local counter variable, it will not consider rejected lines and increment that, which is not correct.
    Thanks,
    Ravindra

  • How to get the line number of source file?

    Hi,
    What is the equivalent in Java of the __LINE__ and __FILE__ macros in C? I want to print out the line number and the file name where the instruction is being executed.
    Thanks,

    If you are doing this because you're implementing your own debug logging, have a look at Log4J.
    You can configure it to log classnames, method names and line numbers of the code you're executing.

  • 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.

  • Getting the Height of Android Status Bar

    Hello,
    is it possible to get the Height of Android Status Bar ?
    thanks

    Hi Shongrunden,
    The above solution will not work when testing on the desktop as Capabilities.screenResolutionY returns the actual screen resolution of the host machine and not that of the emulated device.
    I too would really appreciate a method to obtain the devices status bar height (i.e Capabilities.statusBarHeight) for calulating component width and height upfront.
    Regards,
    Scott.

  • How can i update the phone number associated with my iMessage and FaceTime on my macbook air?

    I recently moved to the US from Canada and have a new US #.  I have updated the phone number on my apple ID but the iMessage and FaceTime on my macbook air are still connected to my old Canadian phone number.  How can I update this?  Thanks so much!

    Associate your mobile number with your Apple ID, if you haven't already done so.
    Sign out of iMessage on the Mac:
              Messages ▹ Preferences ▹ Accounts ▹ Sign out
    and on the iPhone:
              Settings ▹ Messages ▹ Send & Receive ▹ Apple ID ▹ Sign out
    Then, on the phone, tap
              Use Your Apple ID for iMessage
    Sign back into iMessage on both devices and test.
    Credit for this solution to ASC member SmittyLove and to Glenn Fleishman of tidbits.com.

  • How to update the telephone number for a contact person in VAP2.

    hi,
          I want to update the telephone number for a particular contact person in VAP2 from custom transaction. I tried for BDC,
    but it was not updating. Could you plz any one help to solve this issue.

    Try these bapis;
    BAPI_CUSTOMER_CHANGEFROMDATA
    BAPI_CUSTOMER_CHANGEFROMDATA2
    BAPI_ADDRESSORG_CHANGE
    or BAPI_ADDRESSPERS_CHANGE
    Edited by: deniz kaylan on Apr 30, 2010 8:55 AM

  • How to turn on the line number in NWDS?

    The NWDS is based on the very old version of Eclipse. If you open the java source you can't see the line number. I try toturn it on. How?

    Hi
    If you want to navigate to the specified Line Number you can use the following Short cut
    Ctrl + L  [in NWDS]
    Regards
    Chaitanya.A

  • Function Module to update the sales order header status

    Hi,
      I am looking for a function module to update the Sales order header status.
      Pls. let me know if anybody has used any FM to update the SO status.
    Thanks,

    By mentioning status do you mean Object status or Document status??
    For Object status you may use FM: STATUS_MAINTAIN
    For document status it changes according to flow.
    Regards
    Eswar

  • LC 8.0 Win2003server installation with turnkey. how to update the serial number

    good morning
    could anybody give me an idea howw to upadet the serail number of a trial version of livecycle 8.0. adobe gave me a LC 8.0serial number. the serial number had expired. I update it with configuration manager with a new serial number , adobe gave me, it worked. but immediatly after i updated th e8.0 version with the sp2 of LC 8.0. and the serial number went back to th eold one. and when i try the configuration manager , i gave me no screen wher i can update the serial number.
    help me please.
    best regard.
    JPW

    good morning
    could anybody give me an idea howw to upadet the serail number of a trial version of livecycle 8.0. adobe gave me a LC 8.0serial number. the serial number had expired. I update it with configuration manager with a new serial number , adobe gave me, it worked. but immediatly after i updated th e8.0 version with the sp2 of LC 8.0. and the serial number went back to th eold one. and when i try the configuration manager , i gave me no screen wher i can update the serial number.
    help me please.
    best regard.
    JPW

Maybe you are looking for

  • Can you pass parameters from one application component to another?

    I want to have a page of portlets showing applications components (small forms, reports etc) with co-ordinated information. That is, I want the user to enter a single criterion in a portlet and then I want all the portlets to respond by querying the

  • Tricky query with multiple hierarchial sub queries

    Here's a pussle that I cannot solve. Who can help me? Given table F (records form a binary tree with levels 0, 1, and 2): Id IdParent F1 null F2 F1 F3 F2 F4 F2 F5 F1 F6 F5 F7 F5 and given table D (records form a similar binary tree with levels 0, 1,

  • Help with quicktime mpeg-2 download plss

    i am having problems with my avid softwares due to incompatibility with my os (leopard) now i've bootcamp windows in my system for the meantime so i can run my new applications.. i may have to transfer the mpeg-2 (that i've recently purchased ) add o

  • Saving in Mail

    This may be a very dumb question, but with Tiger I could choose ( by right clicking) to save mail in one of the two accounts I have set up in Mail or "On my Mac". Now when I right click I can save to either of my two accounts but the on my mac featur

  • Switching an upgrade with a phone from a soon to be deactivated device

    So this is my situation, we have a MiFi device that is due for an upgrade. I have a phone that is not charging anymore and my upgrade isn't for a couple months. I know I can transfer the upgrade to another phone so that isn't my question. We finally