ScheduleAtFixedRate - not catching interupt from FutureTask.cancel()

I'm not quite understanding how to correctly cancel a thread that is spawned with scheduleAtFixedRate.
main() schedules the MyTask runnable to run every second (which works fine). The runnable (MyTask) prints that its running every second. main() waits 5 seconds then calls cancel (implemented by FutureTask). This is where I get confused. cancel() (if called with a true flag) is supposed to interrupt the thread, but I never get a print in my catch for an InterruptException, and I never fall into my Thread.interupted() condition.
So I have 3 questions:
1. When I run this code from eclipse, the runnable does stop running (I stop getting the prints). So it does seem to be getting canceled. However, I don't understand why I'm not catching the thread interrupt.
2. I'm forced to use the application terminate button in Eclipse to stop execution (not sure why it doesn't terminate normally).
3. Whats the advantage of scheduleAtFixedRate over just spawning the thread with a while(shutdownFlag==true) loop (with a sleep at the end of the loop) and using a volatile atomic boolean to set the flag to false and have the thread terminate?
Thanks for any help!
     public static void main(String[] args) {
          final int THREAD_POOL_SIZE = 1;
          final int PERIODIC_TIME = 1;
          final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(THREAD_POOL_SIZE);
          MyTaskSingleton myTask = MyTaskSingleton.getInstance();          
          try {
                  final ScheduledFuture<?> myTaskHandle =
                              scheduler.scheduleAtFixedRate(myTask, 0, PERIODIC_TIME, TimeUnit.SECONDS);
               Thread.sleep(5000);
               System.out.println("TaskExecutor: MyTask cancel: " + myTaskHandle.cancel(true));
               Thread.sleep(1000);
               System.out.println("TaskExecutor: MyTask is done: " + myTaskHandle.isDone());
          } catch (InterruptedException e) {
               System.out.println("TaskExecutor: caught exception");
               e.printStackTrace();
     }Here is the run method of my runnable class.
public void run() {
          try {
               if (Thread.interrupted()){
                    System.out.println("MyTask: detected thread interrupt");                    
                    throw new InterruptedException();
               System.out.println("MyTask: running...");
          catch(InterruptedException e){
               System.out.println("MyTask: caught Interrupt Exception");
               e.printStackTrace();
     }

1. the only way your runnable will see an interrupted exception, is if it happens to be running when the cancel method is called. however, seeing as your run method is so trivial, the chances of the cancellation happening at the exact right time are very low. add a call to Thread.sleep() in your run method and you have a way better chance of seeing the interruption in the run method.
2. you need to shutdown the executor at the end of the main method. the thread it is using is keeping the application from exiting.
3. because you don't have to write all the code your self. not to mention that you can use 1 thread for multiple scheduled tasks (if you need more than 1).

Similar Messages

  • ThreadPool and FutureTask.cancel

    Hi,
    I have a fixed size thread pool executing a queue of tasks. The queue is larger than the number of threads in the pool. I try to cancel several running tasks using FutureTask.cancel(). At this point, I would expect to see the thread pool start executing the queued tasks in all of the thread pools threads. What I actually see is that the thread pool cancels all the tasks, creates a single new thread, and then sequentially executes all queued tasks in that one thread. It never recreates threads up to maxPoolSize for the queued tasks. Is this the correct behavior? Here is some code that reproduces the behavior I have described:
    import java.util.Map;
    import java.util.HashMap;
    import java.util.concurrent.*;
    public class ThreadPoolTest {
        public static void main(String... argv) throws Exception {
            ThreadPoolTest t = new ThreadPoolTest();
            t.runTest();
        public ThreadPoolTest() throws Exception {
        Map<Integer, Future<?>> futures = new HashMap<Integer, Future<?>>();
        public void runTest() throws Exception {
            ExecutorService executorService = Executors.newFixedThreadPool(10);
            synchronized(futures) {
                for(int i=0; i<30; i++) {
                    futures.put(i, executorService.submit(new MyThread(i)));
            Thread.sleep(1*1000);
            System.out.println("Cancelling threads");
            for(int i=0; i<10; i++) {
                Future<?> f = futures.get(i);
            if(f!=null)
                f.cancel(true);
            while(((ThreadPoolExecutor)executorService).getActiveCount() > 0) {
                System.out.println("Active count = " + ((ThreadPoolExecutor)executorService).getActiveCount());
                Thread.sleep(1000);
            executorService.shutdown();
        private class MyThread implements Runnable {
            private int threadnum = -1;
            public MyThread(int num) {
                this.threadnum = num;
            public void run() {
                System.out.println("Hello " + threadnum + " " + Thread.currentThread());
                try {
                    long i = 0;
                    while(i<1000000000) i++;
                } finally {
                    System.out.println("Removing " + threadnum);
                    synchronized(futures) {
                        futures.remove(threadnum);
                System.out.println("Goodbye " + threadnum);
    }Thanks,
    Anthony

    I replaced the tasks' loop with a sleep(20000); and lo and behold, the threads are interrupted (as expected) and, interestingly, the ActiveCount stays at 10.
    Apparently, threads/slots are not eliminated if the task catches the InterrupedException and exits. If the InterruptedException is not caught by the task/runnable, is it then propagated to the executor which then decides the thread must be destroyed because it suffered an uncaught exception?
    So if your task catches the InterruptedException from cancel, things work as expected. However, there is no guarantee that the task will be able to catch the exception. To mitigate this factor, you may issue a sleep(0, 1), i.e. wait for 1 nanosecond, just before your runnable exits to catch any pending InterruptedExceptions. There still is a small window where the cancel may result in a lost thread, but the window is much smaller.
    Your run method looks like this now:
            public void run() {
                System.out.println("Hello " + threadnum + " " + Thread.currentThread());
                try {
                    long i = 0;
                    while(i<1000000000) i++;
                    Thread.sleep(0, 1);
                } catch (InterruptedException ie) {
                    System.out.println("Interrupted " + threadnum);
                } finally {
                    System.out.println("Removing " + threadnum);
                    synchronized(futures) {
                        futures.remove(threadnum);
                System.out.println("Goodbye " + threadnum);
            }

  • Why can not catch the standard BACK event in ALV's USER_COMMAND event,

    Hi expert, why i can not catch the standard BACK event in ALV's USER_COMMAND event,
    Code:
    DATA G_CON_UC_FORM   TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = SY-REPID
          I_CALLBACK_TOP_OF_PAGE  = G_CON_FORM
          I_CALLBACK_USER_COMMAND = G_CON_UC_FORM
          IT_FIELDCAT             = G_TAB_FIELDCAT
          IT_SORT                 = G_TAB_SORT_INF
          I_SAVE                  = G_CON_U
    *<<<Liang
        IT_EVENTS               = G_TAB_ALV_EVENTS
    *<<<Liang
        TABLES
          T_OUTTAB                = G_TAB_OUTPUT_DATA
        EXCEPTIONS
          PROGRAM_ERROR           = 1
          OTHERS                  = 2.
    *&      Form  F_USER_COMMAND
          ALV USER COMMAND processing
    FORM F_USER_COMMAND .
      IF SY-UCOMM = '&FO3'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDFORM.                    " F_USER_COMMAND
    When I set breakpoint on this subrouting ,and try to click stardard  BACK or CANCEL button, the callback form do not run, but if double click one of line of alv report, the callback form works well,
    so why??

    hi
    good
    check this report and change your code accordingly.
    THESE LINES ARE FOR THE MAIN PROGRAM ***
    SAP V40B ***
    REPORT Z_PICK_LIST .
    TABLES: RESB.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant
                    S_AUFNR FOR RESB-AUFNR," Order number
                    S_BDTER FOR RESB-BDTER." Req. date
    SELECTION-SCREEN END OF BLOCK BL1.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
    DATA: BEGIN OF OUT OCCURS 10,
            AUFNR LIKE RESB-AUFNR,         " Order number
            MATNR LIKE RESB-MATNR,         " Material
            BDMNG LIKE RESB-BDMNG,         " Requirements in UM
            MEINS LIKE RESB-MEINS,         " Unit of Measure (UM)
            ERFMG LIKE RESB-ERFMG,         " Requirements in UE
            ERFME LIKE RESB-ERFME,         " Unit of Entry (UE)
            MAKTX LIKE MAKT-MAKTX,         " Mat. description
          END OF OUT.
    INCLUDE Z_ALV_VARIABLES.
    INITIALIZATION.
      REPNAME = SY-REPID.
      PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
      PERFORM BUILD_EVENTTAB USING EVENTS[].
      PERFORM BUILD_COMMENT USING HEADING[].
      PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
      PERFORM GET_ORDERS.
      PERFORM GET_MATERIAL_DESCRIPTION.
    END-OF-SELECTION.
      PERFORM BUILD_LAYOUT USING LAYOUT.
      PERFORM BUILD_PRINT  USING PRINTS.
      PERFORM WRITE_USING_ALV.
          FORM INITIALIZE_FIELDCAT                               *
    -->  P_TAB                                                         *
    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  GET_ORDERS
          text
    FORM GET_ORDERS.
      SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME
             FROM RESB
             APPENDING TABLE OUT
             WHERE XLOEK EQ SPACE          " deletion indicator
             AND   XWAOK EQ 'X'            " goods movement indicator
             AND   WERKS IN S_WERKS        " plant
             AND   BDTER IN S_BDTER        " req. date
             AND   AUFNR IN S_AUFNR.       " pr. order
    ENDFORM.                               " GET_ORDERS
    *&      Form  GET_MATERIAL_DESCRIPTION
          text
    FORM GET_MATERIAL_DESCRIPTION.
      SORT OUT BY MATNR.
      LOOP AT OUT.
        SELECT SINGLE MAKTX
               INTO OUT-MAKTX
               FROM MAKT
               WHERE MATNR EQ OUT-MATNR
               AND   SPRAS EQ 'EN'.
        MODIFY OUT.
      ENDLOOP.
      SORT OUT BY AUFNR MATNR.
    ENDFORM.                               " GET_MATERIAL_DESCRIPTION
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: L_POS TYPE P.
    first line
      WRITE:/ TEXT-001.                    " Plant:
      IF S_WERKS-HIGH NE SPACE.
        WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.
      ELSEIF S_WERKS-LOW NE SPACE.
        LOOP AT S_WERKS.
          WRITE: S_WERKS-LOW.
        ENDLOOP.
      ELSEIF S_WERKS-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).
      POSITION L_POS. WRITE: TEXT-TIT.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED.  " User:
    second line
      WRITE:/ TEXT-002.                    " Order:
      IF S_AUFNR-HIGH NE SPACE.
        WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.
      ELSEIF S_AUFNR-LOW NE SPACE.
        LOOP AT S_AUFNR.
          WRITE: S_AUFNR-LOW.
        ENDLOOP.
      ELSEIF S_AUFNR-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-012,SY-DATUM.      " Date:
    third line
      WRITE:/ TEXT-003.                    " Req. Date:
      IF S_BDTER-HIGH(1) NE '0'.
        WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.
      ELSEIF S_BDTER-LOW(1) NE '0'.
        LOOP AT S_BDTER.
          WRITE: S_BDTER-LOW.
        ENDLOOP.
      ELSEIF S_BDTER-LOW(1) EQ '0'.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-013, SY-PAGNO.   " Page:
    ENDFORM.                               " TOP_OF_PAGE
          FORM END_OF_LIST                                              *
    FORM END_OF_LIST.
      DATA: L_POS TYPE P.
      ULINE.
      WRITE:/ '|', TEXT-021.      " Delivered by:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-031.            " Received by:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
      WRITE:/ '|', TEXT-012.      " Date:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-012.            " Date:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
    ENDFORM.                               " END_OF_LIST
    *&      Form  WRITE_USING_ALV
          text
    FORM WRITE_USING_ALV.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME     = REPNAME
                I_INTERNAL_TABNAME = 'OUT'
                I_INCLNAME         = REPNAME
           CHANGING
                CT_FIELDCAT        = FIELDTAB.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM       = REPNAME
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
                I_STRUCTURE_NAME         = 'OUT'
                IS_LAYOUT                = LAYOUT
                IT_FIELDCAT              = FIELDTAB
                I_DEFAULT                = 'A'
                I_SAVE                   = G_SAVE
                IS_VARIANT               = G_VARIANT
                IT_EVENTS                = EVENTS[]
                IS_PRINT                 = PRINTS
           TABLES
                T_OUTTAB                 = OUT.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
      ENDIF.
    ENDFORM.                               " WRITE_USING_ALV
    THESE LINES ARE FOR THE INCLUDE ***
    ***INCLUDE Z_ALV_VARIABLES .
    TYPE-POOLS: SLIS.
    DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
          HEADING  TYPE SLIS_T_LISTHEADER,
          LAYOUT   TYPE SLIS_LAYOUT_ALV,
          EVENTS   TYPE SLIS_T_EVENT,
          REPNAME  LIKE SY-REPID,
          F2CODE   LIKE SY-UCOMM VALUE  '&ETA',
          PRINTS   TYPE SLIS_PRINT_ALV,
          TITLE(40) TYPE C,
          G_SAVE(1) TYPE C,
          G_EXIT(1) TYPE C,
          G_VARIANT LIKE DISVARIANT,
          GX_VARIANT LIKE DISVARIANT.
    CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
               FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
               FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
               FORMNAME_BEFORE_LINE TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE',
               FORMNAME_AFTER_LINE TYPE SLIS_FORMNAME VALUE 'AFTER_LINE'.
          FORM MAIN_STATEMENTS                                          *
    THIS IS THE CODE THAT MUST BE INSERTED IN THE MAIN PROGRAM
    FORM MAIN_STATEMENTS.
    Declare the parameter P_VARI wherever you want it. If you don't
    want it, hide it with NO-DISPLAY, but it must exist.
    parameters: p_vari like disvariant-variant. " ALV Variant
    You have to add the following line after the data and parameter
    declaration:
    include z_alv_variables.
    Then, after the data/parameter declaration, add these lines:
    *initialization.
    repname = sy-repid.
    perform initialize_fieldcat using fieldtab[].
    perform build_eventtab using events[].
    perform build_comment using heading[].
    perform initialize_variant.
    If you are using the variable P_VARI (ALV Variant), also add this:
    *at selection-screen on value-request for p_vari.
    perform f4_for_variant.
    *at selection-screen.
    perform pai_of_selection_screen.
    After the "END-OF-SELECTION" statement, add these lines:
    perform build_layout using layout.
    perform build_print  using prints.
    perform write_using_alv.
    You also have to create the following forms: (you can find samples
    in this program)
    INITIALIZE_FIELDCAT
    USER_COMMAND     (only if you are creating a STATUS)
    WRITE_USING_ALV
    ENDFORM.
    *&      Form  INITIALIZE_FIELDCAT_SAMPLE
          THIS IS A SAMPLE, DO NOT USE THIS FORM IN YOUR PROGRAM
         -->P_FIELDTAB[]  text                                           *
    FORM INITIALIZE_FIELDCAT_SAMPLE USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.                           " Always clear before use
      CAT-TABNAME = 'I'.                   " Your internal table
      CAT-REF_TABNAME = 'ZCUSTMAS'.  " The data dictionary reference table
      CAT-FIELDNAME = 'KUNNR'.       " Name of your field in the itable.
      CAT-COL_POS   = 1.                   " Output position
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'NAME1'.             " Next field
      CAT-COL_POS   = 2.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'STRAS'.             " and the next
      CAT-COL_POS   = 3.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'LOEVM'.
      CAT-SELTEXT_S = 'Del'.         " You can always override the descrip-
      CAT-SELTEXT_M = 'Delivery'.          " tion (short, medium, large)
      CAT-SELTEXT_L = 'Delivery Num'.
      CAT-COL_POS   = 4.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'FKIMG'.
      CAT-DO_SUM    = 'X'.                 " You want totals calculated.
      CAT-NO_OUT    = 'X'.                 " and hidden.
      APPEND CAT TO P_TAB.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  BUILD_EVENTTAB
          THIS IS THE SAME FOR ALL THE PROGRAMS
         -->P_EVENTS[]  text                                             *
    FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = P_EVENTS.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_LIST TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_BEFORE_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_BEFORE_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_AFTER_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_AFTER_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
    ENDFORM.                               " BUILD_EVENTTAB
    *&      Form  BUILD_COMMENT
    NOT REALLY NEEDED, BUT I'LL LEAVE IT THERE, JUST IN CASE...
         -->P_HEADING[]  text                                            *
    FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: HLINE TYPE SLIS_LISTHEADER,
            TEXT(60) TYPE C,
            SEP(20) TYPE C.
      CLEAR: HLINE, TEXT.
      HLINE-TYP  = 'H'.
    write: text-101 to text+23.
      HLINE-INFO = TEXT.
      APPEND HLINE TO P_HEADING.
    ENDFORM.                               " BUILD_COMMENT
    *&      Form  INITIALIZE_VARIANT
    VERY IMPORTANT WHEN YOU USE VARIANTS!!!
    FORM INITIALIZE_VARIANT.
      G_SAVE = 'A'.
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = REPNAME.
      GX_VARIANT = G_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                I_SAVE     = G_SAVE
           CHANGING
                CS_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    ENDFORM.                               " INITIALIZE_VARIANT
    *&      Form  PAI_OF_SELECTION_SCREEN
    ALSO FOR VARIANTS
    FORM PAI_OF_SELECTION_SCREEN.
      IF NOT P_VARI IS INITIAL.
        MOVE G_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = G_SAVE
             CHANGING
                  CS_VARIANT = GX_VARIANT
             EXCEPTIONS
                  WRONG_INPUT   = 1
                  NOT_FOUND     = 2
                  PROGRAM_ERROR = 3.
        IF SY-SUBRC EQ 0.
          G_VARIANT = GX_VARIANT.
        ELSE.
          PERFORM INITIALIZE_VARIANT.
        ENDIF.
      ELSE.
        PERFORM INITIALIZE_VARIANT.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  F4_FOR_VARIANT
          text
    FORM F4_FOR_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT = G_VARIANT
                I_SAVE     = G_SAVE
           IMPORTING
                E_EXIT     = G_EXIT
                ES_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 2.
        MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    ENDFORM.                               " F4_FOR_VARIANT
    *&      Form  BUILD_LAYOUT
    STANDARD LAYOUT
         -->P_LAYOUT  text                                               *
    FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
      P_LAYOUT-F2CODE       = F2CODE.
      P_LAYOUT-ZEBRA        = 'X'.
    p_layout-detail_popup = 'X'.
      P_LAYOUT-TOTALS_TEXT  = SPACE.
      P_LAYOUT-SUBTOTALS_TEXT = SPACE.
    ENDFORM.                               " BUILD_LAYOUT
          FORM BUILD_PRINT                                              *
    STANDARD PRINT OPTIONS                                             *
    -->  P_PRINT                                                       *
    FORM BUILD_PRINT USING P_PRINT TYPE SLIS_PRINT_ALV.
      P_PRINT-NO_PRINT_LISTINFOS = 'X'.
      P_PRINT-NO_PRINT_SELINFOS  = ' '.
    ENDFORM.                               " BUILD_PRINT
          FORM PF_STATUS_SET                                            *
    NAME YOUR STATUS ALV. IF YOU NEED IT..                             *
    FORM PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ALV' EXCLUDING EXTAB.
    ENDFORM.                               " PF_STATUS_SET
          FORM USER_COMMAND_SAMPLE                                      *
    -->  UCOMM                                                         *
    -->  SELFIELD                                                      *
    FORM USER_COMMAND_SAMPLE USING UCOMM    LIKE SY-UCOMM
                               SELFIELD TYPE SLIS_SELFIELD.
      CASE UCOMM.
        WHEN 'MSXL'.                       " Export to Excel
         perform set_excel_export.
          CLEAR UCOMM.
        WHEN 'MM03'.
         set parameter id 'MAT' field selfield-value.
         call transaction 'MM03' and skip first screen.
          CLEAR UCOMM.
        WHEN 'BGR1'.
         perform fill_available.
         perform graph_available.
          CLEAR UCOMM.
        WHEN 'DOCU'.
         call function 'Z_HELP' exporting repname = repname.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
    *&      Form  WRITE_USING_ALV_SAMPLE
    *THIS IS A SAMPLE AND MUST BE WRITTEN DIRECTLY IN THE MAIN PROGRAM
    FORM WRITE_USING_ALV_SAMPLE.
    YOU CAN MERGE WITH A DATA DICTIONARY TABLE USING THIS:
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
          exporting
               i_program_name     = repname
               i_internal_tabname = 'I'
               i_inclname         = repname
          changing
               ct_fieldcat        = fieldtab.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_FIELDCATALOG_MERGE'.
    endif.
    OR JUST DISPLAY IT USING THIS:
    call function 'REUSE_ALV_LIST_DISPLAY'
          exporting
               i_callback_program       = repname
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
               i_structure_name         = 'I'
               is_layout                = layout
               it_fieldcat              = fieldtab
               i_default                = 'A'
               i_save                   = g_save
               is_variant               = g_variant
               it_events                = events[]
               is_print                 = prints
          tables
               t_outtab                 = i.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_LIST_DISPLAY'.
    endif.
    ENDFORM.                               " WRITE_USING_ALV
    thanks
    mrutyun^

  • Can't install printer driver: HP Color LaserJet 2605dn drivers "not currently available from the Software Update server"

    I was having trouble printing to my HP Color LaserJet 2605dn from a Mac Pro running Mountain Lion, so I went to System Prefernces -> Print & Scan deleted it and atempted to re-add it.  When I try add the printer I get this message:
    Software for this printer is available from Apple. Would you like to download and install it?
    After clicking Download & Install (the only option other than Cancel), I get this:
    Can't install the software for the Hewlett-Packard HP Color LaserJet 2605dn because it is not currently available from the Software Update server.
    What's the workaround when Mountain Lion can't find the driver?
    Thanks!

    Sean L. wrote:
    I was having trouble printing to my HP Color LaserJet 2605dn from a Mac Pro running Mountain Lion, so I went to System Prefernces -> Print & Scan deleted it and atempted to re-add it.  When I try add the printer I get this message:
    Software for this printer is available from Apple. Would you like to download and install it?
    After clicking Download & Install (the only option other than Cancel), I get this:
    Can't install the software for the Hewlett-Packard HP Color LaserJet 2605dn because it is not currently available from the Software Update server.
    What's the workaround when Mountain Lion can't find the driver?
    Thanks!
    The 2605dn has dual Network and USB connectivity. Which are you attempting to configure: Network or attached USB?
    Printer on, and if networked, use a static IP address
    Print & Scan
    IP
    Provide printer static IP address
    Select Printer Software ... HP Color LaserJet 2605dn driver (not sure about that 2600 driver)
    Add
    Configure Driver under Options and Supplies
    I have a 1994 HP Laserjet 4m Plus set up using these steps and the appropriate driver. I just added another network printer, using the same IP address, but using the above 2605dn driver without any issue other than complaint about a redundant IP address.
    Hopefully, you have already sorted this out.

  • I tunes: when trying to burn a playlist I keep getting the message: the attempt to burn a disc failed. The disc could not be read from or written to. I am using version 12

    I tunes: I am using version 12 of I tunes. Ever since downloading it I get the message when trying to burn a playlist it says, The attempt to burn a disc failed. The disc could not be read from or written to.
    I uninstalled V-12 and then reinstalled it. This enabled me to burn a disc again but after a couple of tries I received the same error message again. Has Apple put out a fix to this problem that anyone is aware of?
    Thanks.

    Hi rossfrombluffton,
    Welcome to the Support Communities!  The resource below provides some general things to consider when burning a disc with iTunes.  I would also try burning a music CD and a data disc from a different application in the Windows OS and trying a different brand CD just to confirm the issue is not with the optical drive.
    Can't burn a CD in iTunes for Windows - Apple Support
    http://support.apple.com/en-ae/HT203173
    Find out what to do if you can't burn an audio CD using iTunes for Windows. Sometimes an audio disc may not burn as expected. Here are some things to check.
    Update iTunes
    Download and install the latest version of iTunes for Windows.Check for unauthorized songs
    iTunes will stop burning a disc if you purchased one or more of the songs in a playlist from the iTunes Store and the songs aren't authorized to play on your computer. This message should appear: "Some of the files can not be burned to an audio CD. Do you still want to burn the remainder of this playlist? For more information on why some files can not be burned, click below."
    To find out which songs aren't authorized, play each song in the playlist. Songs that play are authorized. Songs that don't play aren't authorized. You'll be asked to authorize any unauthorized songs.Make sure your playlist will fit on a single CD
    If there are too many songs in a playlist to fit on a single CD, iTunes should ask if you want to burn multiple discs or cancel the burn. This message should appear: "The songs in this playlist will not fit on one Audio CD. Do you want to create multiple Audio CDs with this playlist split across them? This will require more than one blank CD to complete."
    If you click the Audio CDs button, the burn will continue and you'll be asked to insert blank CDs until the playlist is completely burned. If you click cancel, the burn will be canceled.
    To make the playlist shorter so that it will fit on a single CD, select a song to remove from the playlist and choose Edit > Clear. Repeat this step until the duration of the playlist is between 60 and 80 minutes. The duration appears at the top of the playlist window. Most CD-R discs can hold 60 to 80 minutes of music.
    Check how many times you've burned the playlist
    An unchanged playlist that contains songs purchased from the iTunes Store can be burned no more than seven times.Additional steps and submitting feedback
    Go to iTunes Support to get additional troubleshooting suggestions specific to your optical drive configuration or to submit feedback to Apple.Learn more
    For additional troubleshooting, please see these steps:
    Additional troubleshooting tips for burning issues
    iTunes for Windows doesn't recognize my audio CDs
    Last Modified: Feb 3, 2015
    Have a good day ...
    - Judy

  • Can't install the software for the Canon MX870 series because it is not currently available from the Software Update server.

    I'm trying to setup my Canon MX870 USB ink jet printer plugged into my Airport Extreme's USB port.  However, I keep getting a message of; "Can't install the software for the Canon MX870 series because it is not currently available from the Software Update server."  And then I have to click cancel.
    The "Print & Scan" from System Preferences, can see the printer as it has the NAME: Canon MX870 series,  and the LOCATION: 'the name of my network',  and USE: MX870 series.  But after clicking "Add", it tries to install the software (I've already installed the latest drivers however on my Mac Pro) and that's when I get this message;
    "Can't install the software for the Canon MX870 series because it is not currently available from the Software Update server."
    Any ideas, help would be greatly appreciated!
    Marty

    Hello Marty,
    It sounds like you are not able to add your Canon printer in System Preferences.  I found an article with steps you can take to resolve this:
    Resolution
    USB printers and Bonjour-enabled network printers
    Follow these steps until the issue is addressed:
    Make sure that the printer is powered on, has ink / toner, and that there are no alerts on the printer’s control panel. Note: If you cannot clear an alert on the printer's control panel, stop here and check the printer's documentation or contact the manufacturer for support.
    Ensure the printer is properly connected to a USB port on the Mac or AirPort base station / Time Capsule. If the printer is a network-capable printer, make sure that it is properly connected to your home network.
    Use Software Update to find and install the latest available updates. If an update is installed, see if the issue persists.
    Open the Print & Scan pane or Print & Fax (Snow Leopard) pane in System Preferences.
    Delete the affected printer, then add the printer again.
    If the issue persists, try these additional steps:
    Reset the printing system, then add the printer again.
    If the issue still persists, reset the printing system again.  Download and install your printer's drivers. Then, add the printer again.
    Contact the printer vendor or visit their website for further assistance.
    You can find the full article here:
    Troubleshooting printer issues in OS X
    http://support.apple.com/kb/ts3147
    Thank you for posting in the Apple Support Communities. 
    Best,
    Sheila M.

  • How to catch ClassCastException from JSP page?

    I get a ClassCastException within my JSP page and I know where my bug is. However, this classcastexception message is displayed in the browser and I want to catch this exception to also log it into my log file. But I can't find the place where to catch it: in my servlet's doPost() method I can't catch it - i tried it by enclosing the method body with try/catch but it isn't catched. I wonder if I can catch it at all or if this error is handled internally in the servlet engine?

    It should only be displayed in the browser if you're not catching the exception in the jsp itself. If the exception is happening in the jsp, then there's no point in trying to catch it in the servlet.
    What happens if you put a try-catch just around the actual code in the jsp? You could put it around the entire jsp, but that's not necessary.
    One problem I've encountered in catching exceptions is if there are escape sequences within the try block, for example:
    try{
       //java code
    %>
       <!--html -->
    <%
    //java
    catch (Exception e)I'm not sure if that works or not, but to be safe, make sure you're not escaping from jsp within the try block.

  • Invite Email not being sent from iCal from a Google Apps calendar

    Hello,
    I am running Mac OS X 10.6.5, iCal 4.0.4, and am attempting to do the following from a Google Apps calendar I have setup in iCal. Please note that it's not gmail, it's Google Apps. If that makes a difference. That being said...
    I am trying to create a meeting invite from iCal. I am able to create the invite and add attendees with no problem. When I hit send (from iCal), the invitees do not receive an email notification of the event, but it does appear their calendar (both in iCal and via Google Calendar on the web). I need an email to be sent to the invitees that they have been invited to a meeting, not just to have it appear on their calendars.
    When I create the meeting invite via Google Calendar on the Web the invitees do receive an email notification (as specified in their calendar preferences). The issue only happens when the meeting invite is created in iCal.
    When an invitee accepts or declines a meeting via iCal I receive an acceptance or declining email. Just not when the meeting invite is sent.
    Also, I am able to create a meeting on one of the "On My Computer" calendars in iCal, invite people, and a meeting invitation is sent as expected.
    And again, the invitees have notification of meeting invites turned on in their calendar settings (as is shown by the fact that when the invite is sent out via Google Calendar on the Web they receive an email with the invite).
    Thanks! Any assistance would be awesome.
    Aaron

    That was actually my post on the Google forums
    Here is what I have found so far (and hopefully some of my assumptions are correct, because we're making the full switch to Google Apps this weekend and I am assuming it will work after this). This is long, but I'm trying to be thorough. Also note that I have updated to 10.6.6 since the time I first posted my last message.
    We are currently piloting Google Apps, so our primary domain (which I will refer to from now on as domain.com) still points to our old exchange servers. Mail is currently being delivered to our Google Apps pilot accounts the following way:
    1. User sends an email to [email protected]. This email is delivered to our old Exchange servers.
    2. Once the email is received on our old Exchange servers it gets forwarded to our Google Apps test domain (gtest.domain.com).
    This seems to be an important piece of the puzzle as our primary domain (domain.com) shows up on the Google Apps for Admin dashboard as improperly setup (which is correct, because we're currently piloting)
    So, in iCal I have my Google Apps account setup (I'm one of the pilot users) the following way. I added the Account as Google calendar in iCal, but once the account shows up it shows up as a CalDAV account.
    Under the account information tab:
    CalDAV
    Description: [email protected]
    User name: [email protected]
    Password: my password
    Under the server settings tab (*NOTE: these were entered in automatically when I setup the calendar as a Google calendar)
    Server address: www.google.com
    Server path: the path to my calendar.
    Use SSL is checked
    Use Kerberos v5 is NOT checked
    So, during my testing I was sending meeting invites from people who were in the Google Apps pilot to other people who were in the Google Apps pilot. When I was doing that, no invitations were getting sent.
    I created a new email account on our exchange server ([email protected]) but did NOT set it up to be a part of the Google Apps pilot (this means that emails were not being forwarded from [email protected] to [email protected]). Doing this successfully delivered all invites, cancellations, and meeting updates from iCal!
    From what I can tell there must be something going on (probably my own fault) when a calendar invite is sent from my Google Apps account, through our old Exchange system, and then back to our Google Account. My assumption is it has something to do with the fact that our MX records for domain.com currently point to our old exchange servers, and the MX records for gtest.domain.com point to the Google Apps servers. It may also have something to do with the SPF record which only allows emails from domain.com to be sent from our Exchange servers.
    Those are just guesses though as I am not very knowledgeable in that area.
    I hope this helps and I would love to hear about anyone else working on this issue.

  • Application error not catched

    Hi,
    we are calling an RFC synchronously from BPM. This is a standard BAPI, that does not have any RFC exception message (BAPI_IPAK_START and BAPI_ISREQUEST_GETSTATUS). We are only able to catch system errors, since no RFC exception message is avaiable for which we could define a different exception branch.
    If an error happens in the RFC, an application error is thrown, which is not catched in the exception branch defined to handle the system error. After the application error, the process simply terminates- that's it.
    Why is an application error not catched as system error? Is there any way to catch an application error and let the business process continue?
    Your help will be rewarded,
    Volker

    Hi Volker,
    a BAPI does not throw any exception, therefore you cannot catch any.
    - You could write a wrapper RFC around the BAPI which interprets the RETURN structure and throws exception in case of an error.
    - You could have a fork in the BPM depending of the entries in RETURN.
    Regards
    Stefan

  • DMA transfer on Interupt from Counter on NI6602

    I try to use DMA transfer on Interupt from Counters on the NI6602
    In addition to the programm there are some external input/outputs on the NI 6602 Card connected:
    Most important are:
    Counter 0 is working as an A,B,Z X4 Encoder, so the value represents the position of a antenna, and is reseted after every turn around.
    Well this whole thing is in hardware counting, so it should be ok.
    I need to get the value of the encoder on specific places of the antenna. Allways when, i trigger the transmitter of the radarsystem with a (gated) PRF-Signal generated by counter 2 on the NI 6602.
    So i give this signal as gate into counter 1.
    On counter 1 i activate the DMA and DMA_INT, and also the global interrupt r
    egister.
    I also create an array, to store encoder data in it with the ISR, just to avoid some direct printf.
    However i print the results later.
    So this results are looking like once the interupt has been detected, it will not detect any new one, because just the same data is there till the encoder changes.
    So one question is, how to reset the interupt, so a new one will be recognized?
    I will have about 3000 Interupts per second.
    source is attached
    Thanks a lot
    Mario Behn
    Attachments:
    main.cpp ‏15 KB

    dear Steven_T:
            the registers are In my enclosure ,if you have some ideas,please reply me  first time.thank you !
    Attachments:
    PCI6602.pdf ‏818 KB

  • Solved "Attempting to copy to disk "ipod" failed. Could not be read from or

    Finally found a solution that worked for me when getting this error message on an 2nd Gen. iPod Nano.
    There is a lot of discussion on this topic with no real answers coming back other than to read this article/topic. So, I wanted to share a solution that worked on mine.
    The background: Computer running Windows XP Pro. Up-to-date iTunes and iPod software. I downloaded several CDs into iTunes and synced with no problem. I made a few purchases from iTunes Store and would get to one song that when I tried to sync, the following error message appeared; "Attempting to copy to the disk "ipod" failed. The disk could not be read from or written to." When I deleted the song, then I could sync without receiving the error message, but the purchased song would not be included. I restored my iPod, my iTunes was up-to-date, ran chk dsk, emailed support, searched the forums, followed instructions, re-downloaded the problem song from iTunes Store, BUT as long as that problem song was included, I could not sync without getting the error message.
    The solution (this worked in my situation): After doing all of the above and not getting rid of this problem, I set the iPod to manually manage my music and synced the iPod (without the problem song, which was already deleted from iTunes). When I deleted the song from the iTunes library, I would always click the button to keep the song in the files instead of sending it to trash. I then went into the iTunes music folder where my songs were kept and opened the file for the problem song. I dragged the song back into my purchases folder in iTunes. From the purchases folder, I dragged the song over to my iPod in iTunes. Then synced. The problem song synced without any problems and the error message did not appear. Thinking that something was still not right, I went back and clicked on the button to NOT manually manage my music and then re-synced. Same good result. No error message. The problem song sings along just fine now with no more error message.
    I haven't tried to download another song just yet, so this may not hold, but at least this worked and resolved this problem song. There may be some other factors through all of the work that I did above in trying to resolve this problem that contributed, but it wasn't until I set the iPod to manually manage the music and brought back in the problem song that the error message disappeared. Hopefully this might help. It worked for me so I'm happy now.
      Windows XP Pro  

    I see you've stumbled upon the catch-all article for this incredibly generic error message. Note the phrasing of it: "DISK cannot be READ FROM or written to." Notice that the error doesn't specifically state that it's the iPod disk that cannot be read or written. I used to get this error all the time when I had my library stored on a remote server. The issue being that my machine couldn't access my songs fast enough to copy them to the iPod w/o timing out, and so the disk, in this case my file server, could not be read from. Since you mentioned previously that you're having some anomalies with your library, I would say concentrate on correcting that, rather than worrying that your iPod is kaput.
    regards,
    -c.

  • ItemFocusOut not catching  "TAB" key in Datagrid edited cell?

    In DataGrid, "keyUp" can catch "TAB" key when it is pressed,
    but the Keyboard event has less information needed. I tried
    itemFocusOut, but it seems DataGridEvent would not catch it. Any
    tips on how to make "TAB" key generate DataGridEvent or similar
    event?
    Platforms with this issue: WIN-XP/JDK-1.6/Air-1.5/FLEX
    SDK-3.2
    Thanks!
    -Herbert

    Let me rephrase like this:
    In our application, a DataGrid’s edited cell has
    “itemEditEnd” and “itemEditBeginning”
    handlers defined. However when a “TAB” key is pressed
    to navigate from one editable cell to another editable cell, none
    of the above handlers can catch this special key stroke event.
    Our intention is to make “TAB” key to emit an
    event that can be caught by above handlers. Or, in other words, we
    would like make “TAB” key to be similar(in the sense of
    generating events) to that of “Enter” key when pressed.

  • Airdrop: Messages "The Apple ID Certificate of the McBook is not valid. File transfert canceled."

    Airdrop:
    As I trued to transfert a file from my Imac to my McBook Pro both on Mavericks latest version I got the following message on the Imac : "The Apple ID Certificate of the McBook is not valid. File transfert canceled."
    How do I get around this? 
    Thank you for your help
    Kind regards,

    i had airdrop issues...
    when sending to another machine from my own, the other machine instantly denied the request
    when the other machine tried sending to me, it failed with a warning "apple id certificate is invalid"
    after calling apple:
    go to the apple>preferences>iCloud
    log out
    log in
    do this on BOTH machines
    fixed

  • CatchAll does not catch exception in ora:translateFromNative

    Hello,
    In a BPEL process, I have an Assign step where I use the ora:translateFromNative function. There is a CatchAll around the Sequence. When I provide wrong data in the inputvariable for the native translation (for instance a typo in the root element name), the XPATH function fails but the CatchAll does not catch this. Furthermore, the process state is not dehydrated so in the BPEL console you don't see anything about this. The log file however shows the following information:
    <2007-06-25 13:31:01,723> <ERROR> <default.collaxa.cube.engine.dispatch> <BaseScheduledWorker::process> Failed to handle dispatch message ... exception ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.instance.PerformMessage"; the exception is: XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:translateFromNative(bpws:getVariableData('ReceiveBodConfirmation_confirm_InputVariable','payload','/client:PlasPOImportConfirmRequest/client:request'),'mro_confirm_bod.xsd','CONFIRM_BOD_002')", the reason is FOTY0001: type error.
    Please verify the xpath query.
    My gut feeling after reading this is that an exception occurs while BPEL is creating the fault that should be thrown.
    In any case, this behaviour prevents me from creating a robust BPEL process. Any ideas on how I could deal with this would be much appreciated.
    Kind regards,
    Peter

    Hoi Peter,
    Is the message still in the recovery area? So BPEL is thinking that it is a runtime error and could be revoverd?
    Did you log a TAR?
    Marc

  • MouseEvents not catching in JSplitpane

    Hi
    I had problem with JSplitpane, I used in my application for differentiation for two wave graphs, if i drag the splitpane (up/down)then my top and bottom graphs are updated accordingly, i want to write mouse listener and when moveRelesed update the two graphs.
    If i use property change listener for Splitpane it will work ok but the repainting is very slow(because every time), So i want to replace with mouse listener, but pressed on divider and dragged on it the event is not catching.
    please help

    You will ahve to add a mouse listener on the divider but not on the splitpane itself.
    The problem is the divider is implemented by the UI, so you will have to get it from the UI to add the mouse listener to it.
    Here is the principle :
              final JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT ,leftPanel, rightPanel);
              (((BasicSplitPaneUI)sp.getUI()).getDivider()).addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent e) {
                        System.out.println("Mouse released");
                        sp.getRightComponent().repaint();
                        sp.getLeftComponent().repaint();
              });(nb: I declare sp final to use it in the inner class)
    I hope this will help you,
    Denis

Maybe you are looking for