Event handling in seperate class

hello... i have a gui w/ a series of combo boxes, text fields, etc. (call this the GUI file)
upon pressing a button, i need to run a series of event handling that will use info from many of these components
i would like to create a separate java file for the button event handling, but need this file to have access to many componets in the GUI file - does anyone know a nice way to do this?

i'm not quite sure how to do that... in my GUI class,
I construct the actuall gui within the constructor..
then i have a simple driver that creates an instance
of class GUI and calls the constructor... how can I
pass a reference of the GUI to the handler in that
scenario??it would be better if you post your code. Some people like me can't just imagine.

Similar Messages

  • Event handling in global class (abap object)

    Hello friends
    I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
    Regards
    Reema jain.
    Message was edited by:
            Reema Jain

    Hello Reema
    The following sample report shows how to handle event in principle (see the § marks)..
    The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
    *& Report  ZUS_SDN_TWO_ALV_GRIDS
    REPORT  zus_sdn_two_alv_grids.
    DATA:
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1,
      gt_knvv          TYPE STANDARD TABLE OF knvv.
    "§1. Define and implement event handler method
    "     (Here: implemented as static methods of a local class)
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_knb1      TYPE knb1.
        CHECK ( sender = go_grid1 ).
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
    *        IS_ROW_ID    =
    *        IS_COLUMN_ID =
            is_row_no    = es_row_no.
    *   Triggers PAI of the dynpro with the specified ok-code
        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = '1000'.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 2
          columns           = 1
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_cell_top
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    "§2. Set event handler (after creating the ALV instance)
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.  " Or:
    " SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_cell_bottom
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Display data
      gs_layout-grid_title = 'Customers'.
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNB1'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_knb1
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      gs_layout-grid_title = 'Customers Details (Sales Areas)'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNVV'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_knvv  " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    *  SET TITLEBAR 'xxx'.
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
    *   User has pushed button "Display Details"
        WHEN 'DETAIL'.
          PERFORM entry_show_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  ENTRY_SHOW_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM entry_show_details .
    * define local data
      DATA:
        ld_row      TYPE i,
        ls_knb1     TYPE knb1.
      CALL METHOD go_grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  knvv INTO TABLE gt_knvv
             WHERE  kunnr  = ls_knb1-kunnr.
    ENDFORM.                    " ENTRY_SHOW_DETAILS
    Regards
    Uwe

  • Event handling and inner classes

    Hi everyone,
    When assigning an actionlistener object to a swing component, is making the encapsulating component implement actionlistener better performance-wise than using inner classes? I ask this because my application is pretty slow to start-up, and I'm using lots of inner classes.
    I don't want to go ahead and change the event-handling unless I'm sure it will do any good, because the time restriction is too tight for wasting. Does using addActionListener(this) just pass a reference to itself or is an object generated for each call?
    Thanks in advance,
    Richard

    Passing this only passes a reference. But you won't get a big improvement over inner classes. (If you use one listener object instance and pass that instance to the event sources. Do you?)
    Kurta

  • Event handling without new class

    I'm new to Java, so please bear with me.
    I'm working with a file management software called Intralink which allows automating tasks by recording keystrokes or writing instructions in Java. A typical recorded script would look like:
    // Start Macro Recording
    import com.ptc.intralink.client.script.*;*
    *import com.ptc.intralink.script.*;
    public class newpn2 extends ILIntralinkScript {
    ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface)getScriptInterface();
    private void run0 () throws Exception {
    IL.deselectAll( "WSPI" ); // recorded step: 1
    IL.select( "WSPI", "New_Generic/template_sm.prt" ); // recorded step: 2
    } // End of run0
    public void run () throws Exception {
    run0 (); // recorded
    } // End of function
    } // End Macro RecordingI don't know why but the run0() function has to be called from the run() function. (to clarify that, the run0() can be called from anywhere but all the statements beginning with "IL." are ignored unless it was called from the run() function) I'm trying to write something that uses a dialog box created with JFrame, contains a few combo boxes, and has a JButton to then start the run0() function. This fails because the run0() ends up being called from the actionPerformed class, similar to below.
    public void actionPerformed(ActionEvent e)
    try
    run0();
    catch (Exception ex)
    System.out.println("Error..." + ex);
    }I've tried doing it with an anonymous inner class but the result is the same. Is there any way to detect a button click and act on it within the same function that creates the button?

    Vmtr wrote:
    I understand what you're suggesting but this would still require me to call the run0() function from within the listener class and (for whatever reason) the "IL." commands are ignored if they are not in a run0() function called directly from a run() function. I'm assuming that this is a quirk built in by the makers of Intralink and I am just trying to find a way around it.Something is happening behind the scenes, something that I don't see evidenced by your current code. Since Intralink is not your class, I guess it is impossible to create a true SSCCE. When I created an SSCCE based on your code, there were no problems:
    //import com.ptc.intralink.client.script.*;
    //import com.ptc.intralink.script.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.border.*;
    //import java.util.*;
    //import java.text.*;
    //import java.io.*;
    //import java.sql.*;
    //import com.ptc.intralink.ila.*;
    public class forum extends ILIntralinkScript
      ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface) getScriptInterface();
      private void run0() throws Exception
        JOptionPane.showMessageDialog(null, "In the run0 function!");
        IL.openWindow("Workspace", null, null); // recorded step: 1
        IL.selectTree("FTLOCALDB", "Local Database"); // recorded step: 2
      } // End of run0
      public void run() //throws Exception
        JButton button1 = new JButton("Done");
        button1.setPreferredSize(new java.awt.Dimension(310, 18));
        JFrame f = new JFrame("New Part Number");
        // add this so it exits nice:
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(360, 300);
        f.setResizable(false);
        Container content = f.getContentPane();
        content.add(button1);
        button1.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent ee)
            try
              run0();
            catch (Exception ex)
              System.out.println("Error..." + ex);
              ex.printStackTrace();
        f.setVisible(true);
      // get this all to run
      public static void main(String[] args)
        SwingUtilities.invokeLater(new forum());
    // dummy classes to allow for compilation
    abstract class ILIntralinkScript implements Runnable
      public ILIntralinkScriptInterface getScriptInterface()
        return new ILIntralinkScriptInterface();
    class ILIntralinkScriptInterface
      public void openWindow(String string, Object object, Object object2)
        JOptionPane.showMessageDialog(null, "in method openWindow(" + string + ", " + object + ", "
            + object2 + ")");
      public void selectTree(String string, String string2)
        JOptionPane.showMessageDialog(null, "in method selectTree(" + string + " ," + string2 + ")");
    }

  • Event handling across unrelated classes

    I have a widget type of package that holds some classes that are basically JPanels with appropriate components on them. Specifically, JCheckBox, JComboBox, that kind of thing. These JPanels are used by multiple applications that describe some graphics, so one JPanel allows a user to set properties on Lines, one JPanel allows a user to set properties on Areas, that kind of thing. Several of these are put together in a JTabbedPane, which is another class in this package (this thing can be customized for what is needed).
    The applications themselves use what they need for their particular thing. Here's the question. I designed this thinking that I can have these pre-created panels of what I need, and add the listeners in the application. For example, something like this:
    tabbedPanePanel.getLinePanel().getColorCombo().addItemListener(new ItemListener......);
    When I do this as described in the application, when the colorCombo box is changed, it doesn't trip the event (I was in debug tracing through). Obviously my design is flawed, but I don't know how to change it to make it work. There are two things I need help with improvement.
    First, how can I use these re-usable widgets, when the actions are different depending on the application, and the items that the actions would affect are specific to the applications?
    Second, what would a better design paradigm be for better encapsulation, and performance for these actions (item listeners and such) and the widgets themselves?
    Thank you,
    Valeri

    Think in terms of gathering data instead of actions. That is, each panel gets some user input. Put all the user input in some sort of data object, and provide a method that returns the data object. E.g. Imagine a color panel that lets the user enter R, G, and B:
    public class ColorPanel extends JPanel {
             // TextFields....
            public Color getColor() {
                     // returns a color based on the values in the text fields
    }It is important not to put any OK or Cancel buttons in the panels. You save the OK and Cancel buttons for another main panel that is application specific. When the OK button is pressed, you collect the data and apply it.

  • Event-Handling  Between 2 Classes

    Trying to learn where did I make a mistake!
    Here is a very simple sample code:
    2 classes (each has 1 (awt-style)Panel & 1 (awt-style) Button. By clicking on one of the buttons how do I change the Background (color) of the Panel in the other class?
    //***********Sample Code **********************
    import java.awt.*;
    import java.awt.event.*;
    //=====================================================
    public class App extends Frame
    Panel_1 ap1; //ap1 --> additional panel #1
    Panel_2 ap2;
    public App()
    setLayout(null);
    setBounds(100,100,300,200);
    setBackground(Color.yellow);
    //re: Panel_1
    //=============
    ap1=new Panel_1();
    add(ap1);
    //re: Panel_2
    //===========
    ap2=new Panel_2();
    add(ap2);
    public static void main(String[] args)
    App app=new App();
    app.setVisible(true);
    //==============================================================
    class Panel_1 extends Panel implements ActionListener
    Panel_2 p2;
    Button ap1b=new Button();
    Panel_1()
    setBounds(50,120,100,50);
    setBackground(Color.green);
    ap1b.setBackground(Color.red);
    ap1b.addActionListener(p2);
    add(ap1b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p2.ap2b)
    System.out.println("Test Panel 1");
    //=================================
    class Panel_2 extends Panel implements ActionListener
    Panel_1 p1;
    Button ap2b=new Button();
    Panel_2()
    setBounds(50,30,200,50);
    setBackground(Color.orange);
    ap2b.setBackground(Color.red);
    ap2b.addActionListener(p1);
    add(ap2b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p1.ap1b)
    System.out.println("Test Panel 2");
    }

    There are several ways to do this. Without going into all of them, let's narrow them down by thinking in terms of design. Why should the panels know anything about each other? Each panel is its own deal. The component which has both of the panels should be the one listening to the buttons.
    Really there is no reason to have separate classes for the panels, but if you must, then write a listener as an inner class of the frame class, then pass that listener to the constructor of each panel as you instantiate it. Then you can have the listener work with both panels directly.
    Drake

  • Event handler method

    Hi all,
    I want to know the significance of creating event handler method in Class builder.
    and how it can be used at the time of event trigger.( Is it called automatically or programmer need to call it explicitly in the program.)
    Thanks,
    Sushant singh

    Hi Sushant,
    1. In ABAP Objects, triggering and handling an event means that certain methods act as triggers and trigger events, to which other methods - the handlers - react. This means that the handler methods are executed when the event occurs.
    2.To trigger an event, a class must
      Declare the event in its declaration part
      Trigger the event in one of its methods
    3.You declare events in the declaration part of a class or in an interface. To declare instance events, use the following statement:
    EVENTS evt EXPORTING... VALUE(e1 e2 ...) TYPE type [OPTIONAL]..
    4. An instance event in a class can be triggered by any instance method in the class. Static events can be triggered by any method. However, static methods can only trigger static events. To trigger an event in a method, use the following statement:
    RAISE EVENT evt EXPORTING e1 = f1  e2 = f2 ...
    5. Events are handled using special methods. To handle an event, a method must
          be defined as an event handler method for that event
          be registered at runtime for the event.
    Declaring Event Handler Methods
    Any class can contain event handler methods for events from other classes. You can, of course, also define event handler methods in the same class as the event itself. To declare an event handler method, use the following statement:
    METHODS meth FOR EVENT evt OF cif IMPORTING e1 e2 ...
    6. Registering Event Handler Methods
    To allow an event handler method to react to an event, you must determine at runtime the trigger to which it is to react. You can do this with the following statement:
    SET HANDLER h1 h2 ... [FOR]...
    It links a list of handler methods with corresponding trigger methods. There are four different types of event.
    7. Timing of Event Handling
    After the RAISE EVENTstatement, all registered handler methods are executed before the next statement is processed (synchronous event handling). If a handler method itself triggers events, its handler methods are executed before the original handler method continues. To avoid the possibility of endless recursion, events may currently only be nested 64 deep.
    Handler methods are executed in the order in which they were registered. Since event handlers are registered dynamically, you should not assume that they will be processed in a particular order. Instead, you should program as though all event handlers will be executed simultaneously.
    Reward if useful.

  • 2 Displayable objects, 1 event handler object

    Hi there,
    I'm working on an application using J2ME and the MIDP profile. I was wondering, is it possible to use 1 event handler object for 2 Displayable objects? Lets say I have a list on one screen and a form on another, can I use 1 event handler object to handle the events for these two elements? I am implementing my event handler in another class, and I am trying to use the same event handler for all my screens, but it does not seem to be functioning. Any hints?
    Also, is it advisable to implement the event handler in a separate class for a J2ME application? Does it really make any difference design-wise and efficiency-wise?
    I would appreciate the insight..
    Thanks

    ...I would start with adding debug messages in commandAction and in nextScreen:
    // debug messages are within System.out.println, do not forget to remove after fix
      public void commandAction(Command s, Displayable x) {
        System.out.println("command: [" + s.getLabel() + "] screen: [" + x.getTitle() + "]" );
        // ...here starts your code...
      public void nextScreen(int x) {
        System.out.println("index: [" + x + "]);
        System.out.println("screen[0] is not null: [" + (screen[0] != null) + "]" );
        System.out.println("screen[0] title: [" + (screen[0].getTitle()) + "]" );
        System.out.println("screen[1] is not null: [" + (screen[1] != null) + "]" );
        System.out.println("screen[1] title: [" + (screen[1].getTitle()) + "]" );
        // ...here starts your code...
    {code}
    then retry run and check messages shown in WTK console...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Why event handler runs after reconcilliation

    Hello,
    I had done flat-file full reconcilliation where users mentioned in file are inserted in OIM but before
    starting my reconcilliaiton task i had created an event handler as seperate task whose purpose was to write
    group name,userid,first name & last name to log file when some group is assigned to some user,but
    during my reconcilliation task i came to know that my above event handler is also executed ,so anybody
    can please clarify how event handler is executed during reconcilliation ?
    Thank-You
    Rahul Shah

    Thanks for information Sunny,but i am facing some issue i.e i want to update mail & userid using first & last name after reconcilliation is done ,so first i did with entity adapter & it works fine,but when i tried with event handler its not working & i also tried both ways i.e pre-insert & post-insert.

  • Problem in event handling using oo abap code

    Hi,
    My requirement is i need to disply 3 blocks in ALV format.I have done that.Now my problem is if i double click on aufnr of the first block, it should call the transaction code. I have written the code in oo abap but i have used function modules for ALV.Now my doubt is 'How to write an event  once the user double click on the particular field of the first block, it should call the tcode " using object oriented code.
    How to populate the heading for each block using oo abap code.
    Thanks & Regards
    Anus

    hi.....
    Use Double_click event handler method of class cl_gui_alv_grid of first block....
    if not solved .
    Send me Your program lines ...........
    Best Regards
    Prabhakar

  • An event handler for several subclasses.

    I've been trying to write an event handler that is parameterized by a window
    being passed to it. The event handler is intended to handle the exception event
    that occurs when the window completes. I have had problems trying to write this.
    The scenario is as follows.
    I have a task that listens to events that respresent requests for a window being
    opened. On receiving these, it starts the window, also as an asynchronous task.
    The windows that may be opened (say window classes B, C, and D) are all
    subclasses of window class A. The event handler that I register for (after
    instantiating the window) takes a window of class A as parameter. It responds to
    the exception events for the Display() method of window passed in.
    Now the problems I have encountered are as follows :
    To allow the event handler to respond to the exception event of a window of
    class A, class A has the exception event defined for it. To allow me to start a
    window of class B where completion = event, I also have to define the same
    exception event. This hides the return and exception for class A. The
    implications of this in the event handler is that the event cannot be trapped
    unless I cast the parameter passed in into class B on the ' when return_event '
    line. This makes the event handler specific to class B.
    (This situation is also presumable caused by the fact that each subclasses
    overrides the Display method of window class A, and the exception event is
    defined for the Display method.)
    An alternative approach I tried was using interfaces. I defined the exception
    event as an event on an interface. This was defined with the same parameters as
    the exception events of classes B, C, and D would have (ie. the exception
    event had two parameters - one of type GenericException, and one of ErrorMgr). I
    then made classes B, C, and D implement the interface. The event handler
    parameter would be the interface rather than class A. However class B would not
    compile as the GenericException parameter for the event in the interface uses
    the input mechanism, but the GenericException parameter for the exception event
    in the display event of classes B, C, and D uses copy input. I have ben unable
    to find a way to change the mechanism for event parameters.
    Has anybody got any ideas as to how I may be able to achieve the goals of an
    event handler that can respond the exception event of a number of subclasses.
    Thanks
    Steve Elvin
    Systems Developer
    Frontline Ltd.
    UK.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Steve,
    Try this. Have a method in your super class A , say StubDisplay
    which processes the event loop.
    Also make this method return Exception and/or completion events you
    desire.
    Instead of overriding Display() in your sublclasses, override this
    StubDisplay method.
    You need not have to redefine the exception/completion events in
    your sublclasses B,C ..because they naturally inherit from the super class
    A.
    Using interfaces may not be a good idea in this case because, you
    will be forced to implement them in your subclasses even if you dont
    need them in some specific cases.
    Good luck!
    Ajith Kallambella M.
    Forte Systems Engineer,
    Internationational Business Corporation.
    From: [email protected][SMTP:[email protected]]
    Reply To: [email protected]
    Sent: Wednesday, May 13, 1998 4:42 AM
    To: [email protected]
    Subject: An event handler for several subclasses.
    I've been trying to write an event handler that is parameterized by a
    window
    being passed to it. The event handler is intended to handle the exception
    event
    that occurs when the window completes. I have had problems trying to write
    this.
    The scenario is as follows.
    I have a task that listens to events that respresent requests for a window
    being
    opened. On receiving these, it starts the window, also as an asynchronous
    task.
    The windows that may be opened (say window classes B, C, and D) are all
    subclasses of window class A. The event handler that I register for (after
    instantiating the window) takes a window of class A as parameter. It
    responds to
    the exception events for the Display() method of window passed in.
    Now the problems I have encountered are as follows :
    To allow the event handler to respond to the exception event of a window
    of
    class A, class A has the exception event defined for it. To allow me to
    start a
    window of class B where completion = event, I also have to define the same
    exception event. This hides the return and exception for class A. The
    implications of this in the event handler is that the event cannot be
    trapped
    unless I cast the parameter passed in into class B on the ' when
    return_event '
    line. This makes the event handler specific to class B.
    (This situation is also presumable caused by the fact that each subclasses
    overrides the Display method of window class A, and the exception event is
    defined for the Display method.)
    An alternative approach I tried was using interfaces. I defined the
    exception
    event as an event on an interface. This was defined with the same
    parameters as
    the exception events of classes B, C, and D would have (ie. the
    exception
    event had two parameters - one of type GenericException, and one of
    ErrorMgr). I
    then made classes B, C, and D implement the interface. The event handler
    parameter would be the interface rather than class A. However class B
    would not
    compile as the GenericException parameter for the event in the interface
    uses
    the input mechanism, but the GenericException parameter for the exception
    event
    in the display event of classes B, C, and D uses copy input. I have ben
    unable
    to find a way to change the mechanism for event parameters.
    Has anybody got any ideas as to how I may be able to achieve the goals of
    an
    event handler that can respond the exception event of a number of
    subclasses.
    Thanks
    Steve Elvin
    Systems Developer
    Frontline Ltd.
    UK.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • What is an event handler..?

    I'm trying to learn how to make responsiveness UI. I've read that I can not use SwingUtilities.invokeLater() method if I am in a event handler. The question can seems stupid but I'm only a beginner: what is a event handler? From what I know it might be the actionPerformed method..is it right? Could somebody give me an example? thanks!

    Basically an event handler is a class that performs code.
    It can be any class (even the same that fires the event), but it has to implement the proper interface for the event you want to catch. If you want to perform special code when someone clicks on a button you want to catch an Action, therefor you need an ActionListener, a class that either implements the ActionListener interface (and therefor the method actionPerformed) or your class has to extend AbstractAction (and therefor has an actionPerformed, too).
    It you want to perform special code when someone chooses an element from a list, you want to be informed about a ListSelectionEvent and therefor need a class that implements the ListSelectionListener Interface (and provides the method selectionChanged).
    The class that should react on the event has to be declared as being a listener to the object that fires the events. So an actionListener on a Button would be added by
    button.addActionListener(listener);or
    button.setAction(action);(Note that all variables used are just for clarifiing the type you need and have to be exchanged by the names of your declared objects)
    There are many more events ... really, read the tutorial!

  • Event handlers execute code from a seperate class

    i am having difficulties linking my event handlers to another piece of code in a seperate class. basically i want my event handler to execute a code which is in another class. how do i do this?

    while adding listener to the component for which u want to handle event add listener with the name of class where u r going to write the event handling code and declare that class as implementing the type of listener and handle the event in that class by implementing the definitions for the methods in the interface

  • Enhance standard class with event handler method

    In trying to enhance a standard class with a new event handler class, I find that the ECC 6.0 EHP4 system does not appear to recognise the fact the method is an event handler method.  The specific example is a new method to handle the event CL_GUI_ALV_GRID->USER_COMMAND. 
    I notice that the flag called Active has not been ticked - see image below.  Perhaps this is the reason why the event handler is not being triggered.
    Note that there is an event handler for the same event in the standard class which obviously is executed as expected.  Any ideas on limitations in the system or I am missing a step?
    Thanks
    John

    Thank you for your replies.
    There is a bug in the ALV handler of a standard SAP class (when executed in ITS WebGUI) and I was hoping to create a custom event handler as an Enhancement to execute some custom code to sort of "handle the bug". 
    I agree - ideally it should be done in a Z class but that will not give me access to the object methods and attributes of the enhanced class.
    Cheers,
    John

  • WPF UI running in seperate runspace - able to set/get controls via synchronized hash table, but referencing the control via the hash table from within an event handler causes both runspaces to hang.

    I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
    to see if anyone had a suggestion.
    My goals are as follows:
    1.) Set control properties from the primary runspace (Completed)
    2.) Get control properties from the primary runspace (Completed)
    3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
    I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
    runspaces. As a result, I am unable to update the form based on an event being fired by a control.
    In the example below, the form is loaded and the following steps occur:
    1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
    2.) update-textbox is called and sets the Text property of the textbox.
    3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
    4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
    5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
    unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
    $UI_JobScript =
    try{
    Function New-Form ([XML]$XAML_Form){
    $XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
    [Windows.Markup.XamlReader]::Load($XML_Node_Reader)
    try{
    Add-Type –AssemblyName PresentationFramework
    Add-Type –AssemblyName PresentationCore
    Add-Type –AssemblyName WindowsBase
    catch{
    Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
    $Form = New-Form -XAML_Form $SyncHash.XAML_Form
    $SyncHash.Form = $Form
    $SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
    $SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
    $SyncHash.Form.ShowDialog() | Out-Null
    $SyncHash.Error = $Error
    catch{
    write-host $_.Exception.Message
    #End UI_JobScript
    #Begin Main
    add-type -AssemblyName WindowsBase
    [XML]$XAML_Form = @"
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <DataTemplate x:Key="DTMPL_Name">
    <TextBlock Text="{Binding Path=Name}" />
    </DataTemplate>
    </Window.Resources>
    <DockPanel LastChildFill="True">
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
    <Label Name="LBL_Services" Content="Services:" />
    <ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
    </StackPanel>
    <TextBox Name="TXT_Output"/>
    </DockPanel>
    </Window>
    $SyncHash = [hashtable]::Synchronized(@{})
    $SyncHash.Add("XAML_Form",$XAML_Form)
    $SyncHash.Add("InitialScript", $InitialScript)
    $Normal = [System.Windows.Threading.DispatcherPriority]::Normal
    $UI_Runspace =[RunspaceFactory]::CreateRunspace()
    $UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
    $UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
    $UI_Runspace.Open()
    $UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
    $UI_Pipeline = [PowerShell]::Create()
    $UI_Pipeline.Runspace=$UI_Runspace
    $UI_Pipeline.AddScript($UI_JobScript) | out-Null
    $Job = $UI_Pipeline.BeginInvoke()
    $SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
    Function Update-Combobox{
    write-host "`nBegin Update-Combobox [$(get-date)]"
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
    write-host "`End Update-Combobox [$(get-date)]"
    Function Update-Textbox([string]$Value){
    write-host "`nBegin Update-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
    write-host "End Update-Textbox [$(get-date)]"
    Function Read-Textbox(){
    write-host "`nBegin Read-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
    $Global:Return
    remove-variable -Name Return -scope Global
    write-host "End Read-Textbox [$(get-date)]"
    #Give the form some time to load in the other runspace
    $MaxWaitCycles = 5
    while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
    Start-Sleep -Milliseconds 200
    $MaxWaitCycles--
    Update-ComboBox
    Update-Textbox -Value $("Initial Load: $(get-date)")
    Write-Host "Value Read From Textbox: $(Read-TextBox)"
    Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}

    Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
    To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
    the main runspace update the form in the UI runspace.
    ex:
    1.) User changes selection on combo box generating form event
    2.) Event calls delegate (which I have gotten to work)
    3.) Delegate does some basic processing (works)
    4.) Delegate attempts to update form in UI runspace (hangs)
    As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?

Maybe you are looking for

  • You can't open the application "Adobe InDesign CS4" because it is not supported on this architecture"

    A day or two ago I went through installing Adobe InDesign CS4 on Leopard OS X.5.8.  After what appears to be a successful installati on, in launching InDesign CS4 the message " You can't open the application "Adobe InDesign CS4" because it is not sup

  • Pl/sql boolean expression short circuit behavior and the 10g optimizer

    Oracle documents that a PL/SQL IF condition such as IF p OR q will always short circuit if p is TRUE. The documents confirm that this is also true for CASE and for COALESCE and DECODE (although DECODE is not available in PL/SQL). Charles Wetherell, i

  • RH9-CHM file Set twisties open as default

    Dear all, I followed the instuction of Twisties 2 at site http://www.grainge.org/pages/authoring/twisty/twisty.htm. Twisties 2 work well in my .chm file. But now I have a concern that I want those twisties open as default. Anyone knows, please help m

  • IWeb default title

    Can some please tell me how to change the Blog page's default title because everytime I forget people ask me who Ivan is.... thanks

  • Setting up hotmail on iPhone????????????

    I cannot set up my hotmail account on my iPhone. I go to settings, add account, other, then fill in the blanks. What's the deal with IMAP, POP and Exchange? Can someone walk me through this???? Thanks!!!! -Chris