How to update caret position in status bar ?

Hello, I'm trying to display 'Line Number & Position' in my status bar, I'm not sure how to proceed from here.
How would I update this to occur on every keystroke?
SSCCE
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.EtchedBorder;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.Utilities;
public class test extends JFrame
     private static final long serialVersionUID = 1L;
     private JTextPane pane;
     @SuppressWarnings("unused")
     public static void main(String[] args)
          test t = new test();
     public test()
          super("test");
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
          this.setLayout(new BorderLayout());
          this.add(textPane(), BorderLayout.CENTER);
          this.add(statusBar(), BorderLayout.SOUTH);
          this.pack();
          this.setVisible(true);
     private JTabbedPane textPane()
          pane = new JTextPane();
          JTabbedPane tab = new JTabbedPane();
          tab.addTab("  Query  ", null, pane, "Query");
          tab.setMnemonicAt(0, KeyEvent.VK_1);
          return tab;
     private Box statusBar()
          Box sBar = Box.createHorizontalBox();
          JTextField linePosField = new JTextField(15);
          linePosField.setBackground(Color.LIGHT_GRAY);
          linePosField.setEditable(false);
          linePosField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
          linePosField.setText(String.format("%s %d %s %d", "Line:",
                    getCaretRowPosition(pane), "Pos:",
                    getCaretColumnPosition(pane)));
          sBar.add(linePosField);
          return sBar;
      * Return the current line number at the Caret position.
     public int getCaretRowPosition(JTextPane textPane)
          int caretPosition = textPane.getCaretPosition();
          Element root = textPane.getDocument().getDefaultRootElement();
          return root.getElementIndex( caretPosition ) + 1;
      * Return the current Caret position.
     public int getCaretColumnPosition(JTextPane textPane)
          int offset = textPane.getCaretPosition();
          int column;
          try {
               column = offset - Utilities.getRowStart(textPane, offset);
          } catch (BadLocationException e) {
               column = -1;
          return column;
}Edited by: G-Unit on Oct 17, 2010 4:08 AM

Sorry, Found CaretListener(): Updated code;
private JTabbedPane textPane()
   pane = new JTextPane();
   pane.addCaretListener(new CaretListener() {
      public void caretUpdate(CaretEvent e)
         linePosField.setText(String.format("%s %d %s %d", "Line:",
            getCaretRowPosition(pane), "Pos:",
            getCaretColumnPosition(pane)));
   JTabbedPane tab = new JTabbedPane();
   tab.addTab("  Query  ", null, pane, "Query");
   tab.setMnemonicAt(0, KeyEvent.VK_1);
   return tab;
}Now I just have to figure out how to add a panel for line number to sit adjacent to my text area without throwing the whole window out of proportion. I tried adding some context menu buttons to sit next to it, and for some reason they seemed to want to grow by 500x the size specified and destroyed the whole look of the app. :s maybe I will just make do with status bar line numbers.
Edited by: G-Unit on Oct 17, 2010 4:35 AM

Similar Messages

  • I recently updated to Firefox (desktop) 6.0.2 & love it but please can you tell me an EASY way HOW I can I get the status bar to display at the bottom so I can see the status of my downloads, safe sites & that sync is either in progress or finished.

    Windows 7 64-bit
    Firefox v. 6.0.2
    Norton 360 v.5

    Firefox has a status panel that shows you what is happening during page loading, and also shows the destinations of links when you mouse over them. The status bar showed that as well. You really do not lose that information. I found that I like the addons bar better than the status bar because I could put more buttons on it.

  • How to update the service order status at meter level

    Hi
    I need to fetch one open service order and update the retrieved open service order status at meter level.
    I am trying to do it through BAPI_ALM_ORDER_MAITAIN but i am not able to do it.
    Please let  me know the process how to update.
    Thanks & Regards
    Pallavi

    Hi,
    Check if this code works ...
    REPORT zbapi .
    DATA t_meth TYPE TABLE OF bapi_alm_order_method.
    **Internal table for Operation (BAPI)
    DATA t_oper TYPE TABLE OF bapi_alm_order_operation.
    DATA t_comp TYPE TABLE OF bapi_alm_order_component.
    **Internal Table for Opertaions UP (BAPI)
    DATA t_comp_up TYPE TABLE OF bapi_alm_order_component_up.
    **Internal table for BAPI Return code
    DATA t_ret TYPE TABLE OF bapiret2.
    ***WORK AREA DECLARATIONS
    **Work Area for Hedaer
    DATA:wa_header TYPE caufvdb,
    wa_meth TYPE bapi_alm_order_method,
    wa_op TYPE afvgb,
    wa_comp TYPE resbb,
    wa_comp1 TYPE bapi_alm_order_component,
    wa_comp_up TYPE bapi_alm_order_component_up,
    wa_oper TYPE bapi_alm_order_operation.
    PARAMETERS:TEST.
    ****Fill Method Internal table
    CLEAR wa_meth.
    wa_meth-method = 'SAVE'.
    APPEND wa_meth TO t_meth.
    wa_meth-refnumber = sy-tabix.
    wa_meth-objecttype = 'COMPONENT'.
    wa_meth-method = 'CHANGE'.
    wa_meth-objectkey(12) = '000004000104'.
    wa_meth-objectkey+12(4) = '0010'.
    wa_meth-objectkey+16(4) = '0010'.
    APPEND wa_meth TO t_meth.
    **Component Internal table
    wa_comp1-reserv_no = '0000001072'.
    wa_comp1-res_item = '0001'.
    wa_comp1-activity = '0010'.
    wa_comp1-item_number = '0010'.
    wa_comp1-special_stock = 'B'.
    wa_comp1-requirement_quantity = '15'.
    wa_comp1-stge_loc = '0001'.
    wa_comp1-backflush = 'X'.
    APPEND wa_comp1 TO t_comp.
    **Component Update Internal table
    wa_comp_up-special_stock = 'X'.
    wa_comp_up-backflush = 'X'.
    wa_comp_up-requirement_quantity = 'X'.
    wa_comp_up-stge_loc = 'X'.
    APPEND wa_comp_up TO t_comp_up.
    **Call Bapi
    BREAK-POINT.
    CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
    it_methods = t_meth
    it_component = t_comp
    it_component_up = t_comp_up
    return = t_ret.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.   <--- Hope u r using this too
    regards,
    Naveen
    Edited by: Naveen Deva on Apr 16, 2009 9:12 AM

  • How do I get rid of status bar for screen shots

    How do I get rid of the status bar at the top of my iPhone 3G while taking screen shots? I'd like to publish the shots on the web and in a You Tube video.

    It depends on what you are taking a screen shot of. For example, if you are watching a video and the controls (and status bar) are visible, you can tap the screen to remove them and take you screen shot.

  • How to display a message on status bar while an LOV is active?

    Hi,
    Can any suggest me that how can I display my custom message on the status bar of my form, while an LOV is displayed on the screen.
    I populate an LOV in an Item in the form. I need my status bar to display a message while my LOV is Displayed and also this message to be there on the screen when we moves between the records on the LOV.
    This can be partially achieved by 'message' built-in, but the text message so displayed disappears as soon as u move between the records displayed by the LOV.I want this to be retain there even when we move between records(the data displayed in the LOV) in LOV.
    Can anyone suggest the solution?
    Many thanks in advance.
    Cheers
    Naresh

    hi i am not sure about displaying the information on status bar , what i feel is u can do something like this.
    take one display item which shud be non database item and u can assign the message u want to display to this display item when ever u navigate thro' records.
    i hope this can solve ur problem
    thanks and regards
    chaitali

  • [Automator]How to pause Dropbox syncing from status bar?

    Sorry, i am a new guy.
    I don't have idea how to pause Dropbox syncing by using Automator.
    How should i do?

    Hi,
    The following script should do the trick. I've used cliclick because the “click at“ command doesn't seem to work any more under Mavericks (see this post for example).
    tell application "System Events" to tell process "Dropbox"
        set {x, y} to position of menu bar item 1 of menu bar 2
        set {x, y} to {x + 13, y + 11} -- center of menu icon
    end tell
    set cliclick to "/usr/local/bin/cliclick "
    do shell script cliclick & "c:" & x & "," & y & " w:250"
    set {x, y} to {x + 135, y + 251} -- center of wheel
    do shell script cliclick & "c:" & x & "," & y & " w:250"
    set {x, y} to {x + 85, y + 102} -- center of menu item
    do shell script cliclick & "c:" & x & "," & y
    If you prefer, you might also use this more concise version of the script:
    tell application "System Events" to tell process "Dropbox"
              set {x, y} to position of menu bar item 1 of menu bar 2
    end tell
    do shell script "/usr/local/bin/cliclick " & "c:" & (x + 13) & "," & (y + 11) & " w:250" & " c:" & (x + 148) & "," & (y + 262) & " w:250" & " c:" & (x + 233) & "," & (y + 364)
    Hope it can help.

  • How do i keep the foxclocks status bar at the bottom of the page ?

    I have just recently changed over to the latest version of firefox 4.01 .... I use the foxclocks add onn to which on this latest version of Firefox i have to keep on going into the settings - Tools - Options - Display In - to display the status bar as it keeps on disappearing everytime i log off and log back on ! Is there a way of keeping the status bar permanently on the bottom just like it used to be on the old version of Firefox ?

    You can use this extension to hide the pop-up that shows the URL of a link on hover and other data that previously appeared on the Status bar.
    *Status-4-Evar: https://addons.mozilla.org/en-US/firefox/addon/status-4-evar/

  • How to - take screenshots WITHOUT the "status bar"

    Hi iPhone lovers,
    For a new application release to the AppStore, we need to create snapshots without the 20 pixel "status bar".
    Cropping the image manually is not an option because of all the language localizations...
    Thanks in advance for shedding some light on this,
    Frog Studio's team

    Well you are only talking to users here, not Apple.
    As for your request. Due to limitation no app can run in the background thus no app can be made by anybody else to take screen shots (except one can be made to take screen shot of itself).
    A simple work around is:
    Take a screen shot.
    Go to Camera Roll.
    View Image.
    Zoom in just a little bit until status bar is not showing.
    Screen shot again (as the photo app when you wait will hide everything but the image).
    Yes you lose a little bit, but that is about the best you can do.

  • How to customize the applet's status bar in Oracle Forms 9i

    I extended the statusBar class to include our own message in the applet's status bar. Using JDeveloper I compiled the class and jared the class file. Eventhough I placed that jar file in the classpath, it is not shown in the "import java classes" dialog box.Could anyone help me. Thanks in advance.

    Hi,
    it needs to be in the path configured in the Forms_Builder_Classpath registry variable.
    Frank

  • How to remove fw update notification at the status bar?

    my xperia pro is already updated to .587 and rooted it. even it's already updated, i still keep on getting the notification. i tried to download and install it but always fail now.
    the arrow is bugging me. i want to remove it but don't know how. anyone know how remove it?

    Moved thread to better sub forum. Perhaps you can get some user tips on this here.
     - Community Manager Sony Xperia Support Forum
    If you're new to our forums make sure that you have read our Discussion guidelines.
    If you want to get in touch with the local support team for your country please visit our contact page.

  • How to update the Sent Idoc Status based on the Response From Webservice

    Hi All,
    I have to develop Idoc--SOAP Sync Process Scenario Using BPM .
    I have configured every thing using BPM and mapped
    MATMAS----SOAP Request
    SOAP Resp----STATUS.SYSTAT01
    In R/3  the Main Idoc Number(MATMAS) Status needs to be update , but it is creating the new Idoc with STATUS.SYSTAT01.
    I have used STATUS.SYSTAT01 Idoc to Update the status of the Original idoc based on the Response that is coming from webservice .
    I was posted the same thread a days ago and there Bhavesh suggested me some sugessions.
    How can we make the status of the Idoc based on some response Text
    iam unable to follow OR not able to clear my self on this.
    Please suggest me or give some over view kind of thing on this
    Regards

    Hi Suman,
    It is clearly mentioned in SAP help that "SAP Intermediate Documents (IDOCS) are EDI like documents that are asynchronous in nature."
    So Your Scenario is Asynch(receive) - Synch(WS call) -Transformation (Multimapping)- Asynch(Send to R/3).
    now go in this way:
    you can develop all the message Interfaces  of  Abstract catagory (not manditory )
    MI_AA_MATMAS   -> Abstract Asynchronous message    interface for your Matmas IDOC
    MI_AS_SOAP_ReqandResp  -> Abstarct Syncronous MI for SOAP request and response.
    MI_AA_STATUS ->Abstract Asyncronous MI for Status Idoc
    MI_AA_SOAP_Req ->  Abstarct Asyncronous MI for SOAP request .
    MI_AA_SOAP_Res ->  Abstarct Asyncronous MI for SOAP response .
    Thats all in Message interface.
    your first reciever :
    (This will receive the message asynchronously from R/3)
    create a conatainer varaiable (say preceive) and assign it message interface MI_AA_MATMAS
    Now in thw Propert TAB of this step: give this message name.
    Step2: Synchronous call :
    create container Variable psoaprequest and psoapresponse  give abstract message interface MI_AA_SOAP_Req and MI_AA_SOAP_Req  resp.
    Now in thw Propert TAB of this step:
    Synchronous Interface : MI_AS_SOAP_ReqandResp
    Request Message : psoaprequest
    Response Message: psoapresponse
    Transformation Step :
    Here you will specify Interface Mapping that will conatain Multimapping between Synch Response - MATMAs and STATUS
    Let's name it as IM_ResandMatmasToStatus
    create a container variable as pstatus and assign it abstract interface MI_AA_STATUS.
    In Property pan of this step :
    Interface mapping :IM_ResandMatmasToStatus
    Source Message :psoapresponse
                                preceive
    (IT will ask you for two source messages as IM selected in this transformation has 2 source messages)
    Target Message :pstatus
    Send step:
    Select a message as pstatus.
    thats all in IR.
    If have doubt in ID just let me know.
    Thanks
    Sunil Singh

  • Netflix app. How to make the battery/time status bar disappear?

    When I watch a streaming movie on my iPad the little bar at the top of the window which shows wi-fi strength, time and battery status is constantly there and annoying. During one movie it disappeared and watching the movie was more enjoyable. I don't know why it disappeared and wondered if anyone has found a preference to make that bar go away when the movie is running? It can be done, I just don't know how.
    Thanks

    Aah! So simple! One less annoyance in my meager existence. Thanks Bizzle555!

  • How to setup and position resizable Scroll Bars in Java ?

    I seem to be asking a trivial question -
    I having MFC code below, how to convert it to Java ?
    For a given bigger image_dims and smaller view_dims -
    MFC code below sets-up and positions the ScrollBars.
    What is the corresponding class and member functions in Java ?
    Thanks A LOT for any help !
    Roman Kazinnik
    ====
    sc_info.fMask = SIF_DISABLENOSCROLL | SIF_ALL;
    sc_info.nMin = 0;
    sc_info.nMax = image_dims.size.y-1;
    sc_info.nPage = view_dims.size.y;
    sc_info.nPos = view_dims.pos.y - image_dims.pos.y;
    child->SetScrollInfo(SB_VERT,&sc_info);
    kdu_coords step = view_dims.size;
    step.x = (step.x >> 4) + 1;
    step.y = (step.y >> 4) + 1;
    kdu_coords page = view_dims.size - step;
    child->set_scroll_metrics(step,page,image_dims.size-view_dims.size);
    ====

    hi lev,
    check this document for jco pools
    http://www.winfobase.de/lehre/lv_materialien.nsf/intern01/FB09D79A41930E34C125709F0046180C/$FILE/Tips&Tricks_JCo_Programming.pdf
    ravindra

  • How to prevent "AciveX Control" yellow status bar on top of the page.

    Hi All,
    While i am trying to download the plug-in(.dll) using <OBJECT> or <EMBED> TAG in jsp(Html) page, there is one yellow bar saying{color:#ff6600} "{color}+{color:#ff6600}This site requires the following add-on:.......Please Click here to install".+
    +{color}+1).Is there any code(javascript) to prevent this yellow bar.
    2).How to detect(with help of any code) whether Activex controls are enabled or disabled in the IE browser settings.
    Thanks in advance,
    Prasad.

    No can do, except maybe if you find some exploit in the IE security system. The very point of that bar is to prevent a site from installing add ons and active x controls without letting the user know - which could lead to all kinds of mischief.

  • ADF Faces Dialog position and status bar

    Hi,
    I would like to set the status ="no" for the popup and set the position before it is launched..
    Is there a way to do this with a selectInputText custom renderer or something else?? using the JSF navigation rules "dialog:"
    Thanks
    JO

    Yes you can. Try to lauch the dialog manually.
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getApplication().getViewHandler().createView(context, "/faces/test.jspx");
    HashMap properties = new HashMap();
    properties.put("width", new Integer(200));
    properties.put("height", new Integer(200));
    properties.put("status","no");
    properties.put("left", new Integer(80));
    properties.put("top",new Integer(80));
    AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
    Map dialogParameters = new HashMap();
    dialogParameters.put("message", "This is a test.");
    afContext.launchDialog(root, dialogParameters, null, true, properties);
    Regards,
    Luis R.

Maybe you are looking for

  • Cannot Complete Installation of Vista with Mac Pro and Boot Camp

    I only have one hard drive with my Mac Pro, and I partitioned the drive into two sections with boot camp and restarted with my Vista 64 bit Ultimate CD. I have tried formatting the partition with Vista and it still gives me the dreaded error message

  • How to create a properties file for DB connection (BPEL async processes)

    Hi, In BPEL asynchronouns Project, I am trying to create the Database connection. Instead of hardcoding the details, I want to put it in the properties file and then import the connection file in order to create a connection. I am very new to BPEL an

  • How to add electronic signatures to crystal report?

    All- I need to add a .bmp (electronic signature) to the bottom of my Crystal PO form.  I want to use .bmp files located in a specific folder.  I see a Format graphic option and an area to enter a location, but can't seem to get it to work.  How do I

  • Managing inventory without inventory management

    HI Guys, I have following questions How do we mange stock in inventory if we have just purchasing and no inventory  management..... when do we create new account assignment cateogry Please kindly help...

  • Erreur 0xc000007b.

    J'ai acheté adobe premiere element 12 en magazin (avec disque et numéro de série inclus dans la boîte) et je l'ai installé correctement sur mon ordinateur. Au moment de le lancer, une fenêtre s'affiche avec le message suivant : «L'application n'a pas