JFrame.setCursor (not setting cursor)

I'm creating an application where I need to run an expensive operation. I've set it up to use a SwingWorker type of deal.
What I do is listen for the button to be clicked. It then sets the cursor on the parent JFrame to the wait cursor and then starts the Worker Thread.
The worker Thread runs it's process and resets the cursor to the default.
However, when I set the cursor on the JFrame, I only notice the change when I mouseover the clicked button.
There are a lot of components in the application I really don't want to have to go through and set the cursor for each component manually.
Any help would be greatly appreciated.
Thanks,
Eric
My actionPerformedMethod.
   public void actionPerformed(ActionEvent e) {
      Object source = e.getSource();
      if(source instanceof Component) {
         Component root = SwingUtilities.getRoot((Component)source);
         if(root instanceof JFrame) {
            int winW = root.getWidth();
            int winH = root.getHeight();
            compilingLabel.setLocation((winW - labelSize.width) / 2, (winH - labelSize.height) / 2);
            ((JFrame)root).getLayeredPane().setLayer(compilingLabel, JLayeredPane.POPUP_LAYER.intValue());
            ((JFrame)root).getLayeredPane().add(compilingLabel, JLayeredPane.POPUP_LAYER);
            ((JFrame)root).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            root.repaint();
            root.setVisible(true);
            new CompileThread(e).start();
   }I've also tried using getWindowAncestor with the same results.

I always use the JFrame's glasspane to do this. You set the hourglass cursor on the glasspane, and you must also register a MouseListener on the glasspane (the MouseListener doesn't have to do anything, but you must still have it there. Don't ask me why.). When you want to show the hourglass cursor you call setVisible(true) on the glasspane, and to display the normal cursor you call setVisible(false) on it. To sum it up:
// Set the cursor on the glasspane and register an empty MouseListener:
frame.getGlassPane().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) );
frame.addMouseListener( new MouseAdapter() {} );
// To display the hourglass cursor:
frame.getGlassPane().setVisible(true);
// To restore the normal cursor:
frame.getGlassPane().setVisible(false);Hope this helps.

Similar Messages

  • Set cursor alv grid (not using objects)

    I got a question on ALV GRID (not using objects), please let me know if you have pointers. Thanks.
    Output has 2 screens both has different contents. The output is generated using internal table1 and 2 and using FM  'REUSE_ALV_GRID_DISPLAY_LVC'  (both screen use same FM).
    First screen has multiple pages of output (say 10 pages). User scrolled page 5 and line 10 of first screen and then double clicked it takes to screen #2. After completion of screen #2, the back arrow should get back to page 5 and line 10 of screen #1. Currently the back arrow gets to screen#1 page 1 and line 1. How to remember the cursor position in alv grid and instruct the cursor to go there?
    Appreciate the input.
    Note: I tried "set cursor line n" with "Scroll" command but no luck. http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm

    Thanks for the inputs.
    FYI, I got it implemented using method  CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
    The method is called by 'REUSE_ALV_GRID_DISPLAY_LVC' form 'PF_STATUS_SET' when the ALV grid output is presented each time.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_bypassing_buffer       = 'X'
          i_callback_program       = gc_repid
          i_callback_pf_status_set = 'PF_STATUS_SET'
          i_callback_user_command  = 'USER_COMMAND'
          is_layout_lvc            = lwa_layout
          it_fieldcat_lvc          = git_fc_lvc
          i_default                = ' '
        TABLES
          t_outtab                 = git_data
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      FORM alv_event_pf_status_set USING rt_extab                
                                 TYPE slis_t_extab.
      DATA lo_ref1 TYPE REF TO cl_gui_alv_grid.
    *Get the reference to class "lo_ref1" for the ALV report
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = lo_ref1.
    *set the focus of cursor in ALV
      CALL METHOD lo_ref1->set_current_cell_via_id
        EXPORTING
          is_row_no = gv_row. "row number where you want to focus the cursor
      ENDFORM.

  • Wait cursors not set till end of AbstractAction.actionPerformed()

    Hi.
    Is there a problem setting the wait cursor in the actionPerformed method of Actions? I?m running Java 1.4.1_02.
    I am finding that if I try and set a wait cursor in AbstractAction.actionPerformed() it never gets displayed until the very end of the method, which is a bit useless because this is usually when I want to set it back to the default cursor. The result is that I never see the wait cursor when I execute the action.
    I don?t have the same problem with setting cursors in JComponent.actionPerformed().
    Does anyone have a solution?
    The following code fragment demonstrates the problem. It is from a class that extends the abstractAction class. It calls a method of my own to set the wait cursor ( on the root container and its child components ), then sleeps for a bit. The wait cursor is only shown after the sleep.
    public void actionPerformed( java.awt.event.ActionEvent oActionEvent )
    ESTrace.printMsg( ESTrace.LEVEL_3, "Start of ESAction_NEW.actionPerformed.");
    ESValues.m_oUtils.setGlobalCursor( new Cursor( Cursor.WAIT_CURSOR ) );
    ESTrace.printMsg( ESTrace.LEVEL_3, "ESAction_NEW.actionPerformed. Start Wait");
    try
    Thread oThread = Thread.currentThread();
    oThread.sleep(15000);
    catch(Exception e)
    System.out.println("Wait exception");
    e.printStackTrace();
    ESTrace.printMsg( ESTrace.LEVEL_3, "End of ESAction_NEW.actionPerformed");

    If you set the Field 'Comb' value to show a specific number of characters, then you can use this in the Custom Format script:
    if (event.target.comb) {
    var l = event.value.length
    var m = event.target.charLimit
    var x = m - l
    var s = ""
    if (event.value != "") {
    for (var i = 1; i < x; i++) { s = s + "." }
    event.value = event.value + s
    Note that this will space the characters out to fit the width of the field, and may not line up with other fields properly. Otherwise, without using a monospaced font, I don't know if there is a way for you to know how many periods are needed to fill out the field.

  • Set cursor on table control not working

    Hi,
      I have a screen with delivery number field on top with Get Data Button next to it. Once I click on Get Data, I want to get all the handling units and show them in a table control below and show the first line of that table control selected by default.
      I m able to get the data but the cursor always goes back to the delivery number field.
    I have the following code in PBO
    Status & title for the screen
      MODULE status_0100.
    And in the module, the last lines are as follows
      if sy-ucomm = 'GET'.
        s_vepo-sel = c_x.
        set cursor field 'TABLE1' line 1. "TABLE1 is name of the table control in screen
                                                      "painter
      endif.
    I debugged and saw that the line " set cursor field 'TABLE1' line 1." is indeed the last line which gets executed but still the cursor goes back to delivery number field and table row doesnt get selected.
    Thanks for reading.

    Try maintaining the "Cursor position" in the screen layout in Attributes tab with the field name that you want the default cursor position to be present.
    Regards,
    Shri Hari.

  • Set cursor in Control String component

    Hello:
    I would like to set cursor in "Control String" automatically when I open my VI. If I open my VI, cursor should be seen automatically in the text field of "Control String". The user hasn`t set cursor by mouse into this field. Has anybody an idea how can I do?
    Thanks!

    Create a property node for the control on your block diagram and set the Key Focus property value to TRUE.
    http://zone.ni.com/reference/en-XX/help/371361H-01​/lvprop/ctrl_key_focus/
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to set cursor in table control?

    I have a table control (Screen 300) to display invoice number and amount. For some checks we have around 200 invoices to be displayed.  When user enters the invoice number in invoice text box and click on OK, it should highlight the invoice number and amount row or set the cursor position.
    I have another problem.
    Screen 300 is being called from Screen 200. When the user clicks on OK in 300, 300 is getting closed. Acutally it should be displayed with Cusor position or highlighted row.
    I appreaciate your help ... Thanks

    I believe that you can use the SET CURSOR statement to do the first part of your requirement.  Something like this should work:
    SET CURSOR FIELD w_field LINE w_line.
    Here's the info from SAP help:
    Effect
    : The cursor is positioned on the screen element whose name is contained in upper case in field. The data object field must be character-type and flat. The screen layout or a table control is scrolled in the display so that the screen element on which the cursor is positioned is visible. If the specified screen element is not found, the statement is ignored.
    If the specified screen element is part of a table control or a step loop, the line of the table control or group of the step loop in which the cursor is positioned on the specified screen element must be specified using the addition LINE. For the data object line, the type i is expected. If there is no line or group for the value of line, or the addition LINE is not specified, the statement is ignored. The statement is also ignored if the addition LINE is specified and the screen element is not part of a table control or step loop.
    I hope this helps.
    - April King

  • How to set cursor in perticular field Table Maintence generator?

    Hi
    All
    I have created a table with 2 fields  Start_date and End_date. Now my requirement is i have to validate the both date field as Start_Date must be LESS than or EQUAL to End_Date. In table maintenance maintenance generator i have created a event VALIDATE_DATE in event 21. Its validating perfectly. The issue is after the ERROR message the Cursor is going to the key field. I want to set the cursor at End_Date field.
    I used
    data:ly_pos type i.
    IF NOT start_date LE end_date.
        SET CURSOR FIELD 'TABLE_NAME-END_DATE' LINE sy-linno OFFSET lv_pos.
        MESSAGE exxx(MsgClass).
    ENDIF.
    Its working for the FIRST time i am entering the new data. Next time the cursor going to the KEY field.  I have been asked not to write code in SE80. Anyhow i have to set the cursor in table maintenance maintenance generator event.
    Can anybody help?

    Hi Sourav,
    Please follow the below method:
    Go to Maintainance Screen (where you want the cursor setting). Goto Status - > Remember the screen name -> Double click on Program name.. Open Object list and expant Screen Tree -> double click on the same screen Number -> Go to its first tab attributs -> Change Mode -> Do F4 on Cursor Position field -> Choose the field where you want the cursor.
    But this way will always set the cursor at the HardCoded Field Name.
    Thanks,
    Preyansh

  • Set cursor on error field in selection screen

    Hi ALL,
    How to place the cursor on a particular selection screen field?I am doing validation if validation fails for a particular field the program should give error mesg and the cursor should place on the error field only but it's going to the Ist field on the selection can somebody tell me how do this? I tried with set cursor field <fieldname) but not working I am doing validations on at-selection screen.
    Thanks&Regard
    mahesh

    Hi chandrasekhar find my code below
    this code i am writing under  at selection-screen.
    *&      Form  Z_VALIDATE_TVKOV
    FORM z_validate_tvkov .
      DATA: i_vtweg LIKE vbak-vtweg.
      IF NOT s_vtweg-low IS INITIAL.
        SELECT SINGLE vtweg FROM tvkov INTO i_vtweg
                     WHERE vtweg = s_vtweg-low.
        IF sy-subrc <> 0.
        set cursor FIELD 'S_VTWEG-LOW'.
        MESSAGE e000(z_sd) WITH text-052.
        ENDIF.
       ENDIF.
      IF NOT s_vtweg-high IS INITIAL.
        SELECT SINGLE vtweg FROM tvkov INTO i_vtweg
                            WHERE vtweg = s_vtweg-high.
        IF sy-subrc <> 0.
          MESSAGE e000(z_sd) WITH text-052.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Z_VALIDATE_TVKOV

  • Set cursor Field

    hey guys,
    MODULE PAI_CHECK.
    MODIFY MYTAB FROM LTAB INDEX ZTABDISP-CURRENTLINE transporting KUNRR STATUS.
    SET CURSOR FIELD 'LTAB-KUNNR'
    MESSAGE E005.
    END MODULE.
    does not allow me to put cursor at KUNNR field, instead
    it stands in first column itself..
    what could be the reason here..
    ambichan

    Try setting the cursor field in the PBO.
    If this is to point the user at the error which is occuring, then it should happend automatically if you are coding it correctly.
    This statement should actually be in its own module.
    MODIFY MYTAB FROM LTAB INDEX ZTABDISP-CURRENTLINE transporting KUNRR STATUS.
    The checks should be in their own modules.
    MODULE CHECK_KUNNR.
    IF ltab-kunnr is initial.
    message E005.
    endif.
    ENDMODULE.
    In your flow logic, in the PAI,  you should be coding your checks like this.
      LOOP AT LTAB.
          MODULE YOUR_MODIFY_STATEMENT.
          FIELD LTAB-KUNNR MODULE CHECK_KUNNR.
      ENDLOOP.
    Regards,
    Rich Heilman

  • Set cursor command

    Hi experts,
    I want to position the cursor in a screen field.
    I gave SET CURSOR FIELD GS_ASSEMBLY-SERNR  in PAI.
    But still the cursor is not in required position.
    Pls help me to do this.
    Thanks.

    Hi  Murugan ....
    in the  screen example  100- > in  <b>Attribute's  tab</b>  ( first tab )   there is  Other Attriubutes  block which is   3rd   selection screen in the  screen..
    <b>Exactly  below the  <b>Next Screen</b>  field  that is the <b>Cursor  position</b> .
    <b>for  setting the cursor on the screen</b>
    <b>there  do the F4</b>   it will show the  <b>list of the fields  which are all declared in the screen by you  ..</b>
    <b>just select the  field</b>   .....   inwhich field  you want to set the cursor  .</b>then <b>activate</b> it  ... execute  and see ...
    the  cursor will be there  on the cursor selected  field .
    reward points if it is usefull   ...
    Girish

  • Set cursor on screen

    hi,
    i want to set cursor on screen field. i used SET CURSOR FIELD field_name command on PBO ,but it is not working. if any body has solution then please reply me....
    Thanks
    Regards
    Rakesh

    Hi
    Check Rich Heilman's reply for code sample in the thread:-
    Re: Cursor setting in Screen fields
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir

  • Error message and set cursor field in subscreen

    hey ,
    i have a program with main screen 500 and many subscreens 501,502 and so own .
    when i  want to validate wrong input in a field and set message type 'E' in the PAI of the subscreen the program
    raise the message and exit from the program .
    if i try to put the message in the PBO of the subscreen it dosn't exit but after the message the program dosn't flow to
    command SET CURSOR FIELD that i wrote after the message .
    how can i solve this ?
    is there somthing that i'm missing in the basic code flow of the program ?
    ( screen 500 PBO - PAI ->  SUBSCREEN 50x PBO - PAI )
    best regards
    ASA

    hello and thanks for the answer
    let me  clarify my problem :
    i want to issue a message ( type e or i ) only if some fields are null and the user pressed on SAVE .
    when i'm in the tab-strip and writing error message in :
    PAI :
    chain.
    field XXX
    field YYY
    module issue_warning_message on chain-request.
    endchain.
    in  module issue_warning_message :  if XXX is initial --> message type E --> set cursor field XXX.
    here i get the message and cursor is set.
    when i try to post the message in without chain or any events :
    module user_command_tab502 .
    the message is issued and it exit the program if the type is e and if type message is I the cursor is not set .
    please advice
    ASA

  • SET CURSOR in to commando field

    Hi!
    I wont set cursor in to commando field (the truncation field eg: /nSE80).
    Is it possible?
    I have tried it with SET CURSER FIELD u2018DUMMYu2019 but I donu2019t now the technical name of this field.
    Thanks
    Hermann

    hi
    even i did one table control.
    like i create the new data.
    i type some value in the table control line which in turn is the work area.
    say after one record i press enter.
    then the ok_code will have the previous value. i.e. if ok_code for the create new is say &CRE1. then after typing the data in the record the value ok_code will be &CRE1 only.
    so for that either you have to read the record st in some other internal table and flag is set when user presses the enter.
    say if the user presses the enter many times then modify the other internal tables.
    i suggest if you work with flag and internal table concept then your Table control will not change in GRAY.
    if you have any doubt then i could share with you my code as well because my problem solved like this only.
    thanks
    ekta

  • How to SET CURSOR FIELD my_field in my_REPORT_PROG.?

    Hi Experts,
    If the user do not enter a value in one field( NOT mandatory field) on the selection screen of my_report_prog. I wanna,
    1- To throw message - am getting by throwing as STATUS message
    2 - wanna keep CURSOR on that particlar field in order to input the value by the user - am using SET CURSOR FILED my_filed----
    > but NOT working????????
    So, pls. let me know that How to get it done?
    thanq

    hi,
    try the following code.you will get the cursor in the same field if you use status message or information message.
    selection-screen:begin of block b with frame title text-001.
    parameters:a type i.
    selection-screen:end of block b.
    at selection-screen.
    if a <> 3.
    message s000(0) with 'hi this is chaitu'.
    endif.
    after showing the message the cursor is at a.
    please rewards points if useful.

  • Set cursor in a textinput

    In this example, the focus is set to the phoneInput object
    but the cursor in this textinput is not set. How can I do this?
    Thank you!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="
    http://www.adobe.com/2006/mxml"
    viewSourceURL="src/FormatterSimple/index.html"
    width="310" height="210"
    initialize="focusManager.setFocus(phoneInput);"
    >
    <mx:PhoneFormatter id="phoneDisplay"
    formatString="(###) ###-####"
    />
    <!-- User interface -->
    <mx:Panel
    title="Using a formatter in an item renderer"
    paddingLeft="10" paddingRight="10" paddingBottom="10"
    paddingTop="10"
    >
    <mx:Text text="Enter a phone number,
    including{&apos;\r&apos;}the area
    code{&apos;\r&apos;}e.g., 2025558721:"/>
    <mx:TextInput id="phoneInput" width="100%"/>
    <!-- Display the formatted phone number -->
    <mx:Text text="{&apos;Formatted:
    &apos;+phoneDisplay.format(phoneInput.text)}"/>
    </mx:Panel>
    </mx:Application>

    I tried this and it doesn't work!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="
    http://www.adobe.com/2006/mxml"
    viewSourceURL="src/FormatterSimple/index.html"
    width="310" height="210"
    creationComplete="focusManager.setFocus(phoneInput);"
    >
    <mx:PhoneFormatter id="phoneDisplay"
    formatString="(###) ###-####"
    />
    <!-- User interface -->
    <mx:Panel
    title="Using a formatter in an item renderer"
    paddingLeft="10" paddingRight="10" paddingBottom="10"
    paddingTop="10"
    >
    <mx:Text text="Enter a phone number,
    including{&apos;\r&apos;}the area
    code{&apos;\r&apos;}e.g., 2025558721:"/>
    <mx:TextInput id="phoneInput" width="100%"/>
    <!-- Display the formatted phone number -->
    <mx:Text text="{&apos;Formatted:
    &apos;+phoneDisplay.format(phoneInput.text)}"/>
    </mx:Panel>
    </mx:Application>

Maybe you are looking for

  • Must not use Java 1.7 when using E-Business Suite

    This notification is being posted at the request of Oracle Corporation All E-Business Suite desktop administrators must disable the JRE Auto-Update for their end users immediately to stop it updating to Java 1.7. URGENT BULLETIN: Disable JRE Auto-Upd

  • TS1398 imessage waiting for activation

    I am not able to receive or send an imessage from my phone.

  • Adobe Books

    I am utterly new to all design programs.  I've found books (Adobe Illustrator CC Classroom in a Book (2014 release) and same for InDesign and Photoshop) on Amazon.   Are these the best book for learning resources available?   Also how do I make sure

  • Selection screen descriptions

    Hi all help me in the issue .                    I am having Selection screen with the field sales order type when the user enter particular sales order type the description of the sales order type should come correspondig to the order type how to ac

  • Action Engine indicators do not update?

    This action engine is part of a larger test. I call it every 15 minutes to test for temperature stabilization (four consecutive readings at 15 minute intervals within three degrees) It seems to work as far as detecting stabilization but I don't under