Problem in event listening

hi,
Sub:
i have a container(like VBox) & in which there are few
UIComponents, i want to raise a timeout event when there is
no mouse
activity's or any keyboard activities in the UIComponents
which are in
the container component.
How can i listen the user activities in the container's child
UIComponents?

Hi Jambo,
I would suggest to register for the user inputs (mouse/key)
events with the addeventlistener for every child uicomponent.
The listenfunction restarts everytime a timer and if the
timerfunction (timeout) is called you can do whatever you like to
do on a timeout.
kcell

Similar Messages

  • URGENT : EVENT Listener Problem

    Hi All,
    Thanks for your time. I am facing a Small issue with Event
    dispatcher and Add Event listener. Well i will explain the problem.
    I am having one MovieClip named BUTTON_SET and i gave
    "ButtonSet.as" as linkage Class.
    Inside that BUTTON_SET i am having some Buttons and they are
    also having "UIButton.as" as linkage class
    UIButton Dispatching press and release events, But unable to
    capture it using ButtonSet Class. Here with i have attached the
    Code and i gave the Source URL Too.
    upto my Knowledge : UIButton class is not initiated When the
    ButtonSet is ready to addListener.
    Please Help me to fix this.
    if i don't find a solution i need to change all my class
    structures.
    CLICK HERE FOR SOURCE
    CODE

    According to your Code, When you are calling the InitHandler
    Functionction the Buttons may/may not be Initiated. So use the
    Enterframe to check whether its loaded or not.
    Write down this in the ButtonSet to replace the init Handler
    Call.
    this.onEnterFrame = Delegate.create(this, initHandler);
    inside the initHandler remove the function This will help you
    if you are not using any Enterframe for any other manipulation)
    delete this.onEnterFrame;

  • JList event listener problem

    I'm trying to define an event listener for a JList component. The code is shown below. The problem i'm having is that when elements are added to the JList none of the functions (callFunctionHere()) are being called. Can anyone tell me what i'm doing wrong? (elements are being added to the list using DefaultListModel.addElement())
            pnlWhere.lstCond.getModel().addListDataListener(new javax.swing.event.ListDataListener() {
                public void contentsChanged(ListDataEvent e) {
                    callFunctionHere();
                public void intervalRemoved(ListDataEvent e) {
                    callFunctionHere();
                public void intervalAdded(ListDataEvent e) {
                    callFunctionHere();
            });Thanks,
    Danny.

    Check out the KeyListener interface. You can create an implementation that searches for a string starting with the character of the key that was pressed.

  • Adding an event listener to combo box

    I am working on a mortgage calculator and I cannot figure out how to add an event listener to a combo box.
    I want to get the mortgage term and interest rate to calucate the mortgage using the combo cox. Here is my program.
    Modify the mortgage program to allow the user to input the amount of a mortgage
    and then select from a menu of mortgage loans: 7 year at 5.35%, 15 year at 5.50%, and
    30 year at 5.75%. Use an array for the different loans. Display the mortgage payment
    amount. Then, list the loan balance and interest paid for each payment over the term
    of the loan. Allow the user to loop back and enter a new amount and make a new
    selection, with resulting new values. Allow user to exit if running as an application
    (can't do that for an applet though).
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.NumberFormat;
    import java.util.Locale;
    //creates class MortgageCalculator
    public class MortgageCalculator extends JFrame implements ActionListener {
    //creates title for calculator
         JPanel row = new JPanel();
         JLabel mortgageCalculator = new JLabel("MORTGAGE CALCULATOR", JLabel.CENTER);
    //creates labels and text fields for amount entered          
         JPanel firstRow = new JPanel(new GridLayout(3,1,1,1));
         JLabel mortgageLabel = new JLabel("Mortgage Payment $", JLabel.LEFT);
         JTextField mortgageAmount = new JTextField(10);
         JPanel secondRow = new JPanel();
         JLabel termLabel = new JLabel("Mortgage Term/Interest Rate", JLabel.LEFT);
         String[] term = {"7", "15", "30"};
         JComboBox mortgageTerm = new JComboBox(term);
         JPanel thirdRow = new JPanel();
         JLabel interestLabel = new JLabel("Interest Rate (%)", JLabel.LEFT);
         String[] interest = {"5.35", "5.50", "5.75"};
         JComboBox interestRate = new JComboBox(interest);
         JPanel fourthRow = new JPanel(new GridLayout(3, 2, 10, 10));
         JLabel paymentLabel = new JLabel("Monthly Payment $", JLabel.LEFT);
         JTextField monthlyPayment = new JTextField(10);
    //create buttons to calculate payment and clear fields
         JPanel fifthRow = new JPanel(new GridLayout(3, 2, 1, 1));
         JButton calculateButton = new JButton("CALCULATE PAYMENT");
         JButton clearButton = new JButton("CLEAR");
         JButton exitButton = new JButton("EXIT");
    //Display area
         JPanel sixthRow = new JPanel(new GridLayout(2, 2, 10, 10));
         JLabel displayArea = new JLabel(" ", JLabel.LEFT);
         JTextArea textarea = new JTextArea(" ", 8, 50);
    public MortgageCalculator() {
         super("Mortgage Calculator");                     //title of frame
         setSize(550, 350);                                             //size of frame
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container pane = getContentPane();
         GridLayout grid = new GridLayout(7, 3, 10, 10);
         pane.setLayout(grid);
         pane.add(row);
         pane.add(mortgageCalculator);
         pane.add(firstRow);
         pane.add(mortgageLabel);
         pane.add(mortgageAmount);
         pane.add(secondRow);
         pane.add(termLabel);
         pane.add(mortgageTerm);
         pane.add(thirdRow);
         pane.add(interestLabel);
         pane.add(interestRate);
         pane.add(fourthRow);
         pane.add(paymentLabel);
         pane.add(monthlyPayment);
         monthlyPayment.setEnabled(false);
         pane.add(fifthRow);
         pane.add(calculateButton);
         pane.add(clearButton);
         pane.add(exitButton);
         pane.add(sixthRow);
         pane.add(textarea); //adds texaarea to frame
         pane.add(displayArea);
         setContentPane(pane);
         setVisible(true);
         //Adds Listener to buttons
         calculateButton.addActionListener(this);
         clearButton.addActionListener(this);
         exitButton.addActionListener(this);
         mortgageTerm.addActionListener(this);
         interestRate.addActionListener(this);
    public void actionPerformed(ActionEvent event) { 
         Object command = event.getSource();
         JComboBox mortgageTerm = (JComboBox)event.getSource();
         String termYear = (String)mortgageTerm.getSelectedItem();
    if (command == calculateButton) //calculates mortgage payment
         int year = Integer.parseInt(mortgageTerm.getText());
         double rate = new Double(interestRate.getText()).doubleValue();
         double mortgage = new Double(mortgageAmount.getText()).doubleValue();
         double interest = rate /100.0 / 12.0;
         double monthly = mortgage *(interest/(1-Math.pow(interest+1,-12.0 * year)));
                   NumberFormat myCurrencyFormatter;
                   myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US);
                   monthlyPayment.setText(myCurrencyFormatter.format(monthly));
         if(command == clearButton) //clears all text fields
                   mortgageAmount.setText(null);
                   //mortgageTerm.setText(null);
                   //interestRate.setText(null);
                   monthlyPayment.setText(null);
              if(command == exitButton) //sets exit button
                        System.exit(0);
         public static void main(String[] arguments) {
              MortgageCalculator mor = new MortgageCalculator();

    The OP already did this to both JComboBoxes.
    mochatay, here is a new actionPerformed method for you to use.
    I've improved a few things here and there...
    1) You can't just cast the ActionEvent's source into a JComboBox!
    What if it was a JButton that fired the event? Then you would get ClassCastExceptions (I'm sure you did)
    So check for all options, what the source of the ActionEvent actually was...
    2) You can't assume the user will always type in valid data.
    So enclose the Integer and Double parse methods in try-catch brakcets.
    Then you can do something when you know that the user has entered invalid input
    (like tell him/her what a clumsy idiot they are !)
    3) As soon as user presses an item in any JComboBox, just re-calculate.
    I did this here by programmatically clicking the 'Calculate' button.
    Alternatively, you could have a 'calculate' method, which does everything inside the
    if(command==calculateButton) if-block.
    This will be called when:
    a)calculateButton is pressed
    b)when either of the JComboBoxes are pressed.
    public void actionPerformed (ActionEvent event)
            Object command = event.getSource ();
            if (command == calculateButton) //calculates mortgage payment
                int year = 0;
                double rate = 0;
                double mortgage = 0;
                double interest = 0;
                /* If user has input invalid data, tell him so
                and return (Exit from this method back to where we were before */
                try
                    year = Integer.parseInt (mortgageTerm.getSelectedItem ().toString ());
                    rate = new Double (interestRate.getSelectedItem ().toString ()).doubleValue ();
                    mortgage = new Double (mortgageAmount.getText ()).doubleValue ();
                    interest = rate / 100.0 / 12.0;
                catch (NumberFormatException nfe)
                    /* Display a message Dialogue box with a message */
                    JOptionPane.showMessageDialog (this, "Error! Invalid input!");
                    return;
                double monthly = mortgage * (interest / (1 - Math.pow (interest + 1, -12.0 * year)));
                NumberFormat myCurrencyFormatter;
                myCurrencyFormatter = NumberFormat.getCurrencyInstance (Locale.US);
                monthlyPayment.setText (myCurrencyFormatter.format (monthly));
            else if (command == clearButton) //clears all text fields
                /* Better than setting it to null (I think) */
                mortgageAmount.setText ("");
                //mortgageTerm.setText(null);
                //interestRate.setText(null);
                monthlyPayment.setText ("");
            else if (command == exitButton) //sets exit button
                System.exit (0);
            else if (command == mortgageTerm)
                /* Programmatically 'clicks' the button,
                As is user had clicked it */
                calculateButton.doClick ();
            else if (command == interestRate)
                calculateButton.doClick ();
            //JComboBox mortgageTerm = (JComboBox) event.getSource ();
            //String termYear = (String) mortgageTerm.getSelectedItem ();
        }Hope this solves your problems.
    I also hope you'll be able to learn from what I've indicated, so you can use similar things yourself
    in future!
    Regards,
    lutha

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

  • How can I check if a function is or is not called from the event listener? in Flash CS4 (AS3)

    Hi,
    I came across a little problem.
    I put an event listener inside a for loop and the for loop inside a function.
    I want the for loop to end as soon as the event listener inside the for loop calls its function.
    Here is the general code for a better picture.
    Code:
    this.addEventListener(Event.ENTER_FRAME, function#1);
    function function#1(event:Event):void{
              if(something is true){
                        for(var i = 0; i < numOfmy_mcs; i++){
                                  this["my_mc_"+String(i)].addEventListener(MouseEvent.CLICK, function#2);
    function function#2(e:Event):void{
    //do something cool here
    Thank you for any help!

    kglad wrote:
    that for-loop (if it executes), defines listeners for interactive objects.  that will complete long before any object is clicked.
    Well yes but it does it again and again (frames per second times seconds = number of times it goes through the code if i'm not mistaken), because it is inside a function, and through testing i found out that it works like this:
    Example:
    there are 5 my_mc's in my project: (my_mc_0, my_mc_1, my_mc_2, my_mc_3, my_mc_4)
    if i click my_mc_0 function#2 is called and executed. BUT only after the loop finishes (i know this from tons of testing)...which is unnecessary since you cannot click two places at once. This might not be a problem in this example because i am only using 5 my_mc's buy if i use 500000000 my_mc's it would make a lot of difference.
    is there a way to stop the loop if the function is called?
    ...maybe there is a better way to write it, the only alternative i know that works is if i manually write every single listener and this also is logical in this example but as i said next to impossible if the numbers get bigger.
    -Note
    I didn't specify this earlier but function#2 makes the if statement false so it wont jump back into it.
    Thank you for the help I really appreciate it!
    3rd edit...don't know what's wrong with me

  • Remove event listener from loaded external swf

    I have a main movie timeline that loads an external swf. When I unload the swf from the main timeline I get an error from this:  my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, vidEnd);
    is there any way to remove the event listener from the loaded swf from the main timeline?
    THANKS!

    if you're publishing for fp 10+, use unloadAndStop() applied to your swf's loader.  that has a fair chance of solving the problem.
    if that fails, you should explicitly stop my_FLVPlybk.

  • Problem in event handling of combo box in JTable cell

    Hi,
    I have a combo box as an editor for a column cells in JTable. I have a event listener for this combo box. When ever I click on the JTable cell whose editor is combo box,
    I get the following exception,
    Exception occurred during event dispatching:
    java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.setDispatchComponent(Unknown Source)
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(Unknown Source)
         at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Can any one tell me how to over come this problem.
    Thanks,
    Raghu

    Here's an example of the model I used in my JTable. I've placed 2 comboBoxes with no problems.
    Hope this helps.
    public class FileModel5 extends AbstractTableModel
    public boolean isEditable = false;
    protected static int NUM_COLUMNS = 3;
    // initialize number of rows to start out with ...
    protected static int START_NUM_ROWS = 0;
    protected int nextEmptyRow = 0;
    protected int numRows = 0;
    static final public String file = "File";
    static final public String mailName = "Mail Id";
    static final public String postName = "Post Office Id";
    static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
    // List of data
    protected Vector data = null;
    public FileModel5()
    data = new Vector();
    public boolean isCellEditable(int rowIndex, int columnIndex)
    // The 2nd & 3rd column or Value field is editable
    if(isEditable)
    if(columnIndex > 0)
    return true;
    return false;
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();
    * Retrieves number of columns
    public synchronized int getColumnCount()
    return NUM_COLUMNS;
    * Get a column name
    public String getColumnName(int col)
    return columnNames[col];
    * Retrieves number of records
    public synchronized int getRowCount()
    if (numRows < START_NUM_ROWS)
    return START_NUM_ROWS;
    else
    return numRows;
    * Returns cell information of a record at location row,column
    public synchronized Object getValueAt(int row, int column)
    try
    FileRecord5 p = (FileRecord5)data.elementAt(row);
    switch (column)
    case 0:
    return (String)p.file;
    case 1:
    return (String)p.mailName;
    case 2:
    return (String)p.postName;
    catch (Exception e)
    return "";
    public void setValueAt(Object aValue, int row, int column)
    FileRecord5 arow = (FileRecord5)data.elementAt(row);
    arow.setElementAt((String)aValue, column);
    fireTableCellUpdated(row, column);
    * Returns information of an entire record at location row
    public synchronized FileRecord5 getRecordAt(int row) throws Exception
    try
    return (FileRecord5)data.elementAt(row);
    catch (Exception e)
    throw new Exception("Record not found");
    * Used to add or update a record
    * @param tableRecord
    public synchronized void updateRecord(FileRecord5 tableRecord)
    String file = tableRecord.file;
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    boolean addedRow = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    { //update
    data.setElementAt(tableRecord, index);
    else
    if (numRows <= nextEmptyRow)
    //add a row
    numRows++;
    addedRow = true;
    index = nextEmptyRow;
    data.addElement(tableRecord);
    //Notify listeners that the data changed.
    if (addedRow)
    nextEmptyRow++;
    fireTableRowsInserted(index, index);
    else
    fireTableRowsUpdated(index, index);
    * Used to delete a record
    public synchronized void deleteRecord(String file)
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    data.removeElementAt(i);
    nextEmptyRow--;
    numRows--;
    fireTableRowsDeleted(START_NUM_ROWS, numRows);
    * Clears all records
    public synchronized void clear()
    int oldNumRows = numRows;
    numRows = START_NUM_ROWS;
    data.removeAllElements();
    nextEmptyRow = 0;
    if (oldNumRows > START_NUM_ROWS)
    fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
    fireTableRowsUpdated(0, START_NUM_ROWS - 1);
    * Loads the values into the combo box within the table for mail id
    public void setUpMailColumn(JTable mapTable, ArrayList mailList)
    TableColumn col = mapTable.getColumnModel().getColumn(1);
    javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
    int s = mailList.size();
    for(int i=0; i<s; i++)
    comboMail.addItem(mailList.get(i));
    col.setCellEditor(new DefaultCellEditor(comboMail));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for mail Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Mail Id to see a list of choices");
    * Loads the values into the combo box within the table for post office id
    public void setUpPostColumn(JTable mapTable, ArrayList postList)
    TableColumn col = mapTable.getColumnModel().getColumn(2);
    javax.swing.JComboBox combo = new javax.swing.JComboBox();
    int s = postList.size();
    for(int i=0; i<s; i++)
    combo.addItem(postList.get(i));
    col.setCellEditor(new DefaultCellEditor(combo));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for post office Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Post Office Id to see a list of choices");
    }

  • Is there any event listener for changing the selection of layer?

    Hi all,
    I am looking into an event listener which fires on changing the selection of layer. I found 'Select' event listener which fires on selecting the different object.
    Actually the problem with Select event listener is that when we select an object and move it and deselect it by clicking on the document, event fires on the selection of that object. But if we again select the same object and move it, no event is fired at that time.
    Is there any workaround of this? So that the event is fired every time when we select the same object.
    Please help me on this..
    Regards,
    VG.

    Thanks for the reply..
    Actually I want the same behaviour as in illustrator i.e
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier calls the listener again)
    - Move it.
    But in photoshop,
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier doesnot calls the listener again as the layer is already selected in panel as you explained.)
    - Move it.
    Is there any way to get the same behaviour of illustrator in photoshop?

  • Event Listening With Correlation

    Hi.
    I am seeking the better solution for listening to an event based in information that each BPEL process instance stores internally.
    To each BPEL instance is passed a correlation ID, that is not unique among several BPEL instances. I want to cancel the corresponding BPEL instances if a termination event is published in EDN referring the same correlation ID. The BPEL instances waits for the termination events in a pick activity.
    I have tried 2 solutions:
    1- Filter expression on the event listening on the onMessage branch- The problem is that i cannot acess internal instance data (id that was passed to the instance on the initiate message) to place on the expression. I can build the expression only based on the event data. Makes sense since this test is maybe taking place on the EDN.
    2- Correlation Set on the event listening. The problem is that i get a "receive conflict" since the correlation set is not unique among the instances.
    The workaround was to receive the event in all instances and test the correlation ID subsequently in an "if activity". If the correlation ID is not "mine" i have to listen again. I have to put pick activity inside a while.
    Anybody has faced this requirement?
    Can someone help me with a more elegant solution?
    Thank you very much.
    Bruno Silva

    I think you should use a midware, like CORBA. If your applications are simulations, use pRTI and study some High Level Architecture before. Then your applications can communicate through the midware. This is for programs written on different platforms. Will take you some time..

  • Creating custom event listener ?

    Hello,
    Is there anyone that have a link to a tutorial or have some information on what is needed to be able to create a custom event listener on a component ?
    I am creating an interactive JSF chart library (JSFlot) and I would like to have events such as ChartDraggedEvent and ChartClickedEvent. I can create the events fine (and I can even queue them fine throught the standard action and actionListener interfaces), but I would like for the component to have attributes like chartDraggedListener and chartClickedListener, so that I can fire off the appropriate event to the appropriate listener.
    Any help would be very much appreciated!

    Well, that is what I am doing. The Renderer:
    if (event != null && event.equalsIgnoreCase("drag")) {
                        String componentValue = request.getParameter("componentValue");
                        //Cut out logic irrelevant for this example
                        FlotChartDraggedEvent dragEvent = new FlotChartDraggedEvent(component, dragValue);
                        dragEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                        dragEvent.queue();
                   } else if (event != null && event.equalsIgnoreCase("click")) {
                        //Cut out logic irrelevant for this example                    
                        FlotChartClickedEvent clickEvent = new FlotChartClickedEvent(component, clickedPoint, clickIndexInt, clickSeriesIndexInt, clickSeriesLabel);
                        clickEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                        clickEvent.queue();
                   }The problem though, is that both of these events gets delivered to the actionListener attribute of my component. What I assume is missing is functionality to register a custom listener for each event, and some code in the Tag-class and TLD to supply these listeners, and its these issues that I am unsure how is done. I may be missing something very basic here though :)

  • BeforeSave event listener reverting doc to unsaved [AS, CS5]

    Hi,
    I've got an AppleScript, which is triggered by a beforeSave event listener.  This script makes some modifications to the active document, and then the save proceeds.  The problem I'm encountering is that, after the save, the document appears as saved momentarily, but then immediately reverts back to unsaved.  This is evident by an asterisk disappearing and reappearing next to the document name in the document window's title bar.  If I comment out the document modification code, the save works as expected. 
    It seems like maybe the save is continuing while the script is still in progress, and this is why the document reverts to unsaved.  However, shouldn't the beforeSave event take place before the save occurs, and not proceed until the script has finished executing?
    Things I've checked and/or tried…
    * I've checked to see if somehow my script is being triggered a second time after the save is complete.  It is not.
    * I've tried having my script save the document on completion, but this fails because the database is busy.
    * I've tested with beforeSaveAs, and it encounters the same problem.
    * I've tested on multiple machines.  What's weird is that it occurs on some, and not on others.  So, it's not consistent.
    * I have seen the problem in Mac OS X 10.5.x and 10.6.x.  I have not tested it in 10.7.x yet.
    * I have seen the problem with CS5, but have not yet encountered it with 5.5.
    Anyone have any thoughts or suggestions?
    Thanks,
    -Ben

    Thanks for the ideas regarding beforeInvoke, Ben.  I will try to check that out.  In my situation, here's essentially how my script is working...
    BeforeSave is invoked.
    Script makes a change to the document, which should be captured in the saved file.
    Document saves.
    Document appears saved for a moment, and then appears unsaved (asterisk in the document title).
    My biggest problem is that this behavior isn't consistent.  I have dozens of users, all running the same script, and the problem only occurs with certain users and at random times. I can move a problematic document from a user's machine to a different machine, and the problem doesn't occur there.  It's very difficult to troubleshoot because I can't reproduce it consistently.

  • Event Listener dispatcher giving an ClassCast Exception in C++ 3.6.1

    Hi,
    I have attached a Event listener to underlying NamedCache and when I update the cache entry I didn't get any alerts. But When I checked the
    coherence log I found following Exception available. But I'm not doing any sort of Casting as mentioned below.
    2012-01-17 11:12:55.793/0.320 Oracle Coherence for C++ RTC 3.6.1.0 <Info> (thread=main): Connected Socket to 169.52.37.237/169.52.37.237:9099
    2012-01-17 11:13:04.859/9.386 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): An exception occurred while dispatching the following event:
    coherence::component::util::RunnableCacheEvent: coherence::util::MapListenerSupport::FilterEvent{coherence::component::net::extend::RemoteNamedCache::BinaryCache[source=coherence::component::net::extend::RemoteNamedCache::BinaryCache@0x69f090c4] updated: key=Binary(length=19), old value=Binary(length=713), new value=Binary(length=713), filters=[NULL]}
    2012-01-17 11:13:04.860/9.387 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): The following exception was caught by the event dispatcher:
    2012-01-17 11:13:04.860/9.387 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): NULL
    coherence::lang::ClassCastException: attempt to cast from a "gce::coherence::CoherenceEventHandler" to a "coherence::util::MapListener" at void coherence::lang::coh_throw_class_cast(const std::type_info&, const std::type_info&)(ClassCastException.cpp:27)
    at coherence::lang::coh_throw_class_cast(std::type_info const&, std::type_info const&)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::TypedHandle<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::TypedHolder<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::MemberHolder<coherence::lang::Object> const&, bool)
    When I wrote a sample application It works without any problem. Only difference of above exception coming program is this c++ library is loaded true JNI and relevant event listener is added during a JNI method call. Please explain me why this exception is coming. I have attached the relevant code as well.
    CoherenceEventListener.hpp
    * File: CoherenceEventHandler.hpp
    * Author: srathna1
    * Created on 05 January 2012, 10:15
    #ifndef COHERENCEEVENTHANDLER_HPP
    #define     COHERENCEEVENTHANDLER_HPP
    #include "coherence/util/MapEvent.hpp"
    #include "coherence/util/MapListener.hpp"
    #include <iostream>
    //#include <map>
    #include "coherence/lang.ns"
    #include "mihelper.hpp"
    #include "MiCoherence.hpp"
    #include <string>
    #include "MICoherenceDataObject.hpp"
    using coherence::util::MapEvent;
    using coherence::util::MapListener;
    using namespace coherence::lang;
    * A MapListener implementation that prints each event as it receives
    * them.
    namespace gce {
    namespace coherence {
    class CoherenceEventHandler
    : public class_spec<CoherenceEventHandler,
    extends<Object>,
    implements<MapListener> > {
    friend class factory<CoherenceEventHandler>;
    public:
    CoherenceEventHandler(CMiCoherence * miCoh) : mi(miCoh), msgSeqNo(1) {
    virtual void entryInserted(MapEvent::View vEvent) {
    Object::View vKey = vEvent->getKey();
    String::View key = cast<String::View > (vKey);
    Object::View vValue = vEvent->getNewValue();
    char topic[100];
    strcpy(topic, key->getCString());
    Managed<gce::coherence::MICoherenceDataObject>::View pos = cast<Managed<gce::coherence::MICoherenceDataObject>::View > (vValue);
    std::cout << key << " = " << pos << std::endl;
    virtual void entryUpdated(MapEvent::View vEvent) {
    Object::View vKey = vEvent->getKey();
    String::View key = cast<String::View > (vKey);
    Object::View vValue = vEvent->getNewValue();
    char topic[100];
    strcpy(topic, key->getCString());
    Managed<gce::coherence::MICoherenceDataObject>::View pos = cast<Managed<gce::coherence::MICoherenceDataObject>::View > (vValue);
    std::cout << key << " = " << pos << std::endl;
    gce::coherence::MICoherenceDataObject msg = *pos;
    virtual void entryDeleted(MapEvent::View vEvent) {
    private:
    CMiCoherence * mi;
    int msgSeqNo;
    #endif     /* COHERENCEEVENTHANDLER_HPP */
    Event Registration code
    NamedCache::Handle miCoherenceCache = NULL;
    try {
    String::View cacheName = szConnect;
    miCoherenceCache = CacheFactory::getCache(cacheName);
    } catch (const std::exception& e) {
    LOGERR("initializing coherence middleware cache error: %s", e.what());
    return MI_ERR_BADSTATE;
    nConnectState = miCoherenceCache->getCacheService()->isRunning() == true ? 1 : 0;
    miCoherenceCache->addFilterListener(gce::coherence::CoherenceEventHandler::create(this));
    Please give me a clue why Cohrence Internal Event Dispatcher giving exception.....
    Thanks and regards,
    Sura

    Hi,
    Even when I try to to test the MemberListener while closing the Coherene Java Cache Cluster I can see following Exception. Something similar to EventListener.
    2012-01-18 20:06:18.868/44.346 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): The following exception was caught by the event dispatcher:
    2012-01-18 20:06:18.868/44.346 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): NULL
    coherence::lang::ClassCastException: attempt to cast from a "gce::coherence::CoherenceMemberListener" to a "coherence::net::MemberListener"
    at void coherence::lang::coh_throw_class_cast(const std::type_info&, const std::type_info&)(ClassCastException.cpp:27)
    at coherence::lang::coh_throw_class_cast(std::type_info const&, std::type_info const&)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::TypedHandle<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::TypedHolder<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::MemberHolder<coherence::lang::Object> const&, bool)
    at coherence::net::MemberEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::util::ListenerCallback::translateMemberEvent(coherence::lang::TypedHandle<coherence::net::MemberEvent const>)
    at coherence::component::util::ListenerCallback::memberLeaving(coherence::lang::TypedHandle<coherence::net::MemberEvent const>)
    at coherence::net::MemberEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::net::extend::RemoteService::dispatchMemberEvent(coherence::net::MemberEvent::Id)
    at coherence::component::net::extend::RemoteService::connectionError(coherence::lang::TypedHandle<coherence::net::messaging::ConnectionEvent const>)
    at coherence::component::net::extend::RemoteCacheService::connectionError(coherence::lang::TypedHandle<coherence::net::messaging::ConnectionEvent const>)
    at coherence::net::messaging::ConnectionEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::util::Peer::DispatchEvent::run()
    at coherence::component::util::Service::EventDispatcher::onNotify()
    at coherence::component::util::Daemon::run()
    at coherence::lang::Thread::run()
    on thread "ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher"
    Seems to be like loading with JNI will giving some exceptions.
    Please help me on this...
    Thanks and regards,
    Sura

  • Add event listener to HTTPService call

    Hi – I am using a HTTP service within my flex
    application.
    My HTTPServeice is connecting to an XML file:
    <mx:HTTPService
    id="myResults"
    url="
    http://localhost/myResults.xml"
    resultFormat="e4x"
    result="resultHandler(event)" />
    the data within the XML file is constantly changing (the
    structure remains the same, but the actual data within the
    structure of the XML changes), therefore I am refreshing my
    HTTPService results every 5 seconds:
    [Bindable]
    public var myDataFeed:XML;
    private function initApp():void
    var timedProcess:uint = setInterval(refreshResults, 5000);
    private function refreshResults():void
    myResults.send();
    private function resultHandler(event:ResultEvent):void
    myDataFeed = event.result as XML;
    My problem is that sometimes the XML file needs longer than 5
    seconds to load / refresh the data (as it is quite heavy)
    etc… therefore I want to implement some sort of event
    listener on the HTTPService to let the application know when the
    results have been refreshed so I can restrict / the 5 second
    refresh taking place until the previos refresh is complete
    etc…
    is this possible – to set an event listener to a
    HTTPService to know when it has completed refreshing results from
    an XML file???
    Thanks,
    Jon.

    result="resultHandler(event)" <--- is already an event
    listener.
    btw if you have a live XML you might want to consider xml
    socket connection so that server will push data to client .(lot
    more efficient)

  • AWT Event Listener not listening...

    Hi,
    I'm having problems with an AWT Event Listener on a JFrame.
    Basically, im making a tank game, so the first screen to appear is an inventory screen. The when you click start on this screen, you create a GameScreen which extends JFrame. i have an AWT Event Listener added to this frame using this code:
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){
    public void eventDispatched(AWTEvent e) {
    if(((KeyEvent)e).getKeyCode() == KeyEvent.VK_DOWN && e.getID() == KeyEvent.KEY_PRESSED)
    It's checking events on the arrow keys and the tab and enter keys.
    So when the this round of the game has finished, i setVisible to false, and make the inventory visible again.
    The problem is, when i set make the GameScreen visible again, the listeners aren't working.
    It seems to be working fine for 'enter', that is VK_ENTER, but not for the arrow keys...
    Any1 have any ideas??
    Any help would be great!
    Thanks,
    D.

    I am willing to bet that your problem lies in that once you return the main game screen from the inventory screen that you need to set the focus back to the main game screen. I believe, as events go, the component that has the focus is the one that will receive the events and process them according to their listener code. As I am not sure where your focus goes once you close the inventory screen and open the main screen, it could be that the wrong component has the focus.
    As far as getting the focus to the correct component is concerned, I remember myself and Malohkan having a discussion as to how to get this to work, and he came up with a work-around. That thread is somewhere in this forum. I'm not sure if it will solve your problem, but it might be something worth looking into.
    -N.

Maybe you are looking for