How to fire event to a textarea?

Hi all!
I am developing a small chat application where the data typed at the client on a textarea should be reflected in the textarea at the server. I can send data through the network and append it at the client. But if I want to handle the special keystrokes like backspace and all, I need to manually identify the code for that particular key and then do that operation on the server textarea. But what I am trying is I will send the TEXTEVENT object through the network and using information in it, I will construct a new TEXTEVENT object by changing the source object alone. Then I want to fire that on the textarea. We have a method processTextEvent in TextComponent(base of textarea). But it is protected and so even if I try to extend the textarea and do it, I don't have access to that method.
Can anyone help me out!
Thanks in advance.
Bye
Vijay

Here's some code that works in Window$, but fails badly in Solaris 9. In Solaris it doesn't display the characters and produces an "unexpected exception in code outside the JVM".
Here's the client
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.LinkedList;
public class TestEC extends Frame implements KeyListener
     TextField input;
     Socket sock=null;
     boolean connected = false;
     InputStream is = null;
     ObjectOutputStream oos = null;
     Thread recvThread = null;
     Thread sendThread = null;
     Queue sendQueue = null;
     TestEC()
          input = new TextField(30);
          addWindowListener(new WindowAdapter()
          {public void windowClosing(WindowEvent evt){System.exit(0);}});
          add(input);
          input.addKeyListener(this);
          pack();
     private boolean connect(String address, int port)
          try
               sock = new Socket(address, port);          // try to connect to port 9999 on my Solaris system
               is = sock.getInputStream();
               oos = new ObjectOutputStream(sock.getOutputStream());
               sendQueue = new Queue();
               recvThread = new Thread(new Runnable(){public void run(){doRecv();}});
               recvThread.start();
               sendThread = new Thread(new Runnable(){public void run(){doSend();}});
               sendThread.start();
               connected = true;
          catch(IOException e)
               System.out.println("failed to connect to: "+address+":"+port);
               sock = null;
               connected = false;
          return connected;
     public void keyPressed(KeyEvent e){sendKey(e);}
     public void keyReleased(KeyEvent e){sendKey(e);}
     public void keyTyped(KeyEvent e){sendKey(e);}
     private void sendKey(KeyEvent e)
          sendQueue.push(e);
     public static void main(String[] args)
          String address = "127.0.0.1";
          if(args.length > 0)address = args[0];
          TestEC tec = new TestEC();
          if (tec.connect(address,9999))tec.show();
          else System.exit(0);
     // read and discard until close seen, then shutdown
     private void doRecv()
          int last = 0;
          try{while(connected && -1 != last){last = is.read();}}
          catch(IOException e){e.printStackTrace();}
          connected = false;
          try
               sock.close();
               sendThread.interrupt();
          catch(Exception ce){ce.printStackTrace();}
     private void doSend()
          Object obj;
          while(connected)
               obj = sendQueue.pop();
               if(obj != null)
                    try{oos.writeObject(obj); oos.flush();}
                    catch(IOException e){e.printStackTrace();}
     // a simple queue class between two threads
     class Queue
          LinkedList q = new LinkedList();
          public synchronized void push(Object obj)
               q.add(obj);
               this.notify();     // tell pop to run with it
          public synchronized Object pop()
               if(q.isEmpty())
                    try{this.wait();}
                    catch (InterruptedException e){return null;}
               return q.remove(0);
} And here's the server
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class TestES extends Frame
     TextField output;
     Socket sock=null;
     boolean connected = false;
     ObjectInputStream ois = null;
     Thread recvThread = null;
     Thread listenThread = null;
     TestES()
          output = new TextField(30);
          addWindowListener(new WindowAdapter()
          {public void windowClosing(WindowEvent evt){System.exit(0);}});
          add(output);
          pack();
     private void start()
          listenThread = new Thread(new Runnable(){public void run(){doListen();}});
          listenThread.start();
     private void doListen()
          ServerSocket ssock = null;
          try
               ssock = new ServerSocket(9999);          // listen on port 9999 on this host
               sock = ssock.accept();
               ois = new ObjectInputStream(sock.getInputStream());
               recvThread = new Thread(new Runnable(){public void run(){doRecv();}});
               recvThread.start();
               connected = true;
          catch(IOException e)
               System.out.println("listen failed");
               sock = null;
               connected = false;
     public static void main(String[] args)
          TestES tes = new TestES();
          tes.start();
          tes.show();
     // read and process events from socket
     private void doRecv()
          Object obj;
          while(connected)
               try
                    obj = ois.readObject();
                    postEvent(obj);
               catch(Exception e){e.printStackTrace(); connected = false;}
          try
               sock.close();
          catch(Exception ce){ce.printStackTrace();}
     private void postEvent(Object obj)
          output.requestFocus();
          output.dispatchEvent((KeyEvent) obj);

Similar Messages

  • How to fire event to generate insert message for the child objects?

    We are in process to integrate CRM On Demand and existing Microsoft SQL DB.
    We have the following problem:
    For ex., we have CRM Object_1 that already synchronized with the SQL DB. CRM also has independent Object_2 and its child Object_2.1
    We dicided that we want to connect the Object_2 as child to the Object_1.
    The question is how to fire event to generate insert message for the Object_2 and Object_2.1?
    What is the best technique? Is it possible to do it by workflow configuration or it needs to be done programmatically?
    Thanks,
    Dmitry
    Edited by: 955827 on Aug 29, 2012 11:57 AM

    Hi,
    integration events can be generated only via worklow. You will need to create separate workflows for each record type (regardless if it is child or parent) because a workflow for the parent record type will not trigger when a child record is created/ associated. Also, the association workflows will trigger only when the specific event occurs.
    There is not way to generate the integrtaion events programatically. They are generated by workflows and are read/ interpreted by a code extension.

  • How to fire event on panel in coverflow?

    Hi,
    I have cover flow.Inside that 10 panels(created dynamically)  will be present.
    when u run application we will get coverflow.My requirement is when i click on first panel i have to
    fire event.similarly when i click on remaining panels(ie first click it will show to user(panel1) and second click on the same pane1(panel1) event
    will be fired.for suppose second click on panel2(not panel1),then i dont want fire event).How to do that?
    Regards
    D.Mahesh Babu

    Hi Sarah,
    Looks like you are talking of exactly what I want!
    I have attached a sample VI to try achieve what I want. But it still has some issues which are:
    1) I am unable to configure a Plot Attribute Change Event. I have used a mouse leave event instead. How does one configure a Plot Attribute Change Event?
    2) Is there no single property which will transfer all the settings of plot legend from one graph to plot legend of another graph? In my sample VI, I have to read each property of the master graph and feed it into the slave graph.
    Kindly note I am using LV FDS 7.1 on Win2000
    Thanks,
    Gurdas
    Message Edited by Gurdas on 03-27-2006 11:51 PM
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu
    Attachments:
    Graph_PlotLegend_Event.vi ‏45 KB

  • How to fire event with parameter?

    Hi folks,
    does anyone know how to use the event parameter functionality?
    My idea is to fire an event within the richisland and pass a parameter value. As I recognized the function
    var myParameter:Number = new Number();
    FlashIsland.fireEvent(this,"myEvent",myParameter);
    On WD side in ROOTUIELEMENTCONTAINER I created a child element of type GACEvent, named myEvent. This event has a GACEventParameter named myParameter.
    But running the app I am getting a dump:
    WebDynpro Exception: ERROR: GAC_EVENT_PARAMETER 'myParameter' missing (GAC_EVENT='myEvent')
    Any idea of how to fix this?

    Hi,
    I solved it now. The correct syntax is:
    FlashIsland.fireEvent(this, 'myEvent', {myParameter:myValue});
    Hope it helps you too.
    Greets

  • How to fire event in view controller from component controller.

    I have a component usage that fires an event wich i have subscribed in the component controller.
          iv_usage->subscribe_event( iv_event_name = 'TAKE_IT'
                                     iv_handler = me ).
    After the event the method IF_BSP_WD_EVENT_HANDLER~HANDLE_EVENT in the component controller is called.
    method if_bsp_wd_event_handler~handle_event.
    endmethod.
    The usage component is opened as a popup window. After pressing a button, the data is transfered via context node binding to the calling component. But now i want to close the popup.
    My intension is to fire a event for the view controller in the IF_BSP_WD_EVENT_HANDLER~HANDLE_EVENT method that closes the popup.
    Is this possible?
    Or let me explain it this way:
    I want to close a popup after a button in the popup is pressed.
    best regards
    Jürgen

    Hello Juergen
    I am assuming your target pop-up is of type ref to IF_BSP_WD_POPUP.
    1.Make this a view controller class attribute.
    2. After the code to create the pop-up, you can add the following block :
    gv_target_popup->set_on_close_event( iv_view = me iv_event_name = 'CLOSEPOPUP').
    3. Now define event handler EH_ONCLOSEPOPUP where you can write the logic for on_close.
    You can access the same reference gv_target_popup at the event handler level as well.
    Hope this helps.
    Regards
    Nisha

  • How to fire event in VS C# when QuickTime sees a marker.

    I am using Visual Studio 2005 C# to run QT with ActiveX.  I have set markers in the video file that show up in the window at the bottom of a QT movie.  I want to be able to capture that marker with an event handler and tell a microcontroller to do something when that marker is hit.  I've done a lot of research and can't find a way to extract the marker name or even find an event handler that will fire when the marker is hit.  Since QT shows the name in the window I'm thinking there has to be a way to get that information to a C# application.
    Any help would be appreciated,
    Steve

    hi,
    You can create a method from the methods tab in your view controller. Write the code for populating your combo box in this method. Now in the doInit you can call this method. In the action handler of the button also call this method.
    hope this helps you.
    regards,
    Rahul.

  • How to fire an event dynamically in JSF Page

    Hi All
    How to fire an event dynamically in JSF Page?
    Thanks
    Sudhakar

    Hi,
    Thanks for the response. I mean to say, if I create the components dynamically then how can I fire events for those components.
    In otherwords,
    If I create the Button dynamically with particular ID being set to that component, then how can I call button action event when the button is clicked??
    Hope you understand
    What is the role of MethodBinding mechanism here??
    Thanks
    Sudhakar Chavali

  • How to fire another event handler for postprocess stage

    Hi All,
    I have 3 custom event handlers for postprocess stage, for modify action on user object. The problem is tah only one event handler is executed - I use EntityManager API to modify user object. How to fire another event handlers? Do I have use UserManager API?
    best
    mp

    As Bikash stated, used a single event handler. You can put if statements in there to identity the operation, as well as if statements if the parameter is found i the list of attributes being modified. This way you will only perform the action when necessary.
    -Kevin

  • How to fire JComboBox itemStateChanged event manually?

    hello:
    I want to know how to fire JComboBox itemStateChanged event manually.
    thank you
    -Daniel

    Call setSelectedIndex or setSelectedItem.

  • How to Create Event polling table

    hi,
    1)How to Create Event polling table
    2) wahts RPD stands for.
    3) when we are prefer Dynamic variables.
    thanks.
    raj

    1) http://obiee101.blogspot.com/2008/07/obiee-managing-cache-emptyingpurging.html
    2) Repository Project Design ?
    - More than likely the extension RPD was not used by anything else when Siebel Analytics first started using it, no doubt the 'RP' is repository, so use 'Definition' or 'Design' as you like. Im pretty sure there is nothing in the documentation but i've not checked, maybe you could check and let us know?
    3) Dynamic variables would be something like 'CURRENT_MONTH' where the same query does not need to fire per user (ie SESSION variable) but needs to be periodically refreshed. Another use of you dynamic variable might be 'LAST_ETL_DATE' or somethng similar which might implement with your event polling table. By including the Variable within a Business Model, all cache for the Business Model is purged whenever the Variable's value changes.

  • Fire Event Through Interface

    I have been using this interface
    public class InputHandler implements VoteListener
    public void onVote(Response[] responses)
    }I get the call back with out registering the class. How can I implement my own interface without the user registering their class? I do not know how to fire the events through an interface without registering the class.
    Edited by: MrGreen2 on Feb 5, 2008 4:01 PM

    What do you mean "registering a class?"
    If you don't care about which thread the events are fired on, the observable item should maintain a list of Listeners then call the relevant method when needed:
       public static void addVoterListener(VoterListener l) {
            m_voterListenerList.add(l);
       public static void removeFeatureListener(VoterListener l) {
           m_voterListenerList.remove(l);
       someMethod() {
             for (VoterListener l : m_voterListenerList) {
                  l.onVote(responses);
    }If you want the events to fire on the EDT, you'll have to wrap up the Responses into a Runnable and use SwingUtilities.invokeLater to enqueue the trigger there. If the trigger may alter the listener list, you'll also want to make something like the AWTEventMulticaster for your listeners.
    If you consider the "addVoterListener" method as "registering" then you'll have to find some other way to devise the list of listeners. But somehow, the obervable needs to know which observers are interested in the events.

  • JTable: how to prevent events?

    Hello friends...
    Does somebody know how to prevent a JTable to fire events at certain times when selections are made?
    In this case, the selection can be made externally to the table, by a lot of objects at the same time. The goal is to fire an event ONLY when I really need it...
    ThanX in advance for any help...

    Hello again...
    ThanX for your answers, I used a mix of both.
    I used the method .setValueIsAdjusting() in ListSelectionModel that considers all coming events as one and I used a flag to enable changes.
    The problem now is, I get a big array of values the table has to handle. Since it handles it as one unique event, it should be OK. But I fear that if the array is really monstruous, the method .setValueIsAdjusting() enters in "wait" mode (multi threads and all the stuff) and the flag is set to true (changes possible) without changes being made to table... Perhaps, there would be no problem at all...
    Is it possible to force .setValueIsAdjusting() to do his job immediately?
    ThanX a lot for your time...

  • InputField fire event problem in webDynpro

    I have one validation or Fire Event problem with respect to Inputfield in web Dynpro.
    I have one Input filed and created the context varible for that, then i mapped the context varible to the InputField, and i changed the context varible type as date.So , when i run the view , it will show the calender near to the text box to select the perticular date. On select of the perticular date. It will populate selected  date in to the inputField.
    On selection of the perticular date. Based on the date i want to generate the next 12 months date at runtime in different text boxes. But the only event available for the InputField is only "onEnter". This is not useful in my case, bcz on selection of the Date , the user may not use the Enter key. so , how can use the other events like onSelection or onChange events in the InputFields to reach my needs.
    Any one  give me the idea to solve this problem.
    Vijay

    Hello Vishal,
    You may also refer the sample code in the below link
    <a href="http://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0c0dcacd-0401-0010-b4bd-a05a0b4d68c8">http://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0c0dcacd-0401-0010-b4bd-a05a0b4d68c8</a>
    Regards,
    Sudeep.

  • How to swt scroll in the textarea?

    Hi to all.
    I can't figure out how to set scrollbars at my textarea text1.
    Can anyone help me out?
    Thanks in advance
    I attach her bellow my application:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.lang.*;
    public class EDS_SIM
       JButton  button1 = new JButton(" EOTS SIMULATION");
       JButton  button2 = new JButton("METEO STATION SIMULATION");
       JButton  button3 = new JButton("Exit Simulation");
       JTextArea text1 = new JTextArea("SIMULATION PROGRAM STATUS.........",10,100);
       JTextArea text2 = new JTextArea();
       public EDS_SIM()
         super();
         //Create a panel as a container
         JPanel panel1 = new JPanel(null);
         Color mycolor=new Color(50,0,255,200);
         panel1.setBackground(mycolor);
         //Create a frame
         JFrame.setDefaultLookAndFeelDecorated(true);
         String title = "E . D . S .";
         JFrame frame = new JFrame(title);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setBounds(100,80,200,50);
         //setting an image to the frame
         Image icon = Toolkit.getDefaultToolkit().getImage("icona.gif");
         frame.setIconImage(icon);
         frame.add(panel1);
         text2.setBackground(mycolor);
         text2.setForeground(Color.WHITE);
         text2.setBounds(80,10,500,20);
         Font myfont=new Font("Verdana", 3,16);
         text2.setFont(myfont);
         text2.setText("PROGRAM FOR THE SIMULATION OF EXTERNAL DEVICES");
         text2.setEditable(false);
         panel1.add(text2);
         text1.setBackground(Color.BLACK);
         text1.setForeground(Color.WHITE);
         text1.setBounds(80,100,530,150);
         text1.setEditable(false);
         panel1.add(text1);
        button1.setForeground(Color.BLUE);
        button1.setBounds(80, 300, 200, 50);
        panel1.add(button1);
        button2.setForeground(Color.BLUE);
        button2.setBounds(350, 300, 260, 50);
        panel1.add(button2);
        button3.setForeground(Color.RED);
        button3.setBounds(460, 400, 150, 50);
        panel1.add(button3);
        Action_EOTS action1 =new Action_EOTS();
        Action_MS action2 =new Action_MS();
        ExitAction action3 =new ExitAction();
        button1.addActionListener(action1);
        button2.addActionListener(action2);
        button3.addActionListener(action3);
        // Create a horizontal progress bar
        int width = 650;
        int height = 500;
        frame.setSize(width, height);
        frame.setVisible(true);
        public class Action_EOTS implements ActionListener {
            public void actionPerformed(ActionEvent evt) {
                  button1.setEnabled(false);
                  EOTS eots_sim = new EOTS(text1);
                  text1.setText("EOTS Simulation is running\n");
         public class Action_MS implements ActionListener {
            public void actionPerformed(ActionEvent evt) {
                  button2.setEnabled(false);
                  MS eots_sim = new MS(text1);
                  text1.append("Meteo Sation Simulation is running\n");
      public class ExitAction implements ActionListener {
            public void actionPerformed(ActionEvent evt) {
                 System.exit(0);
       public static void main(String argv[])
          EDS_SIM window = new EDS_SIM();
    }import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class EOTS
    JButton button3 = new JButton("Close Simulation");
    //Create a frame
    String title = "EOTS SIMULATION";
    JFrame frame = new JFrame(title);
    JTextArea text12 = new JTextArea();
    public EOTS(JTextArea text1)
    //Create a panel as a container
    JPanel panel1 = new JPanel(null);
    Color mycolor=new Color(0,0,150,200);
    panel1.setBackground(mycolor);
    //Create a frame
    JFrame.setDefaultLookAndFeelDecorated(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(50,600,80,50);
    //setting an image to the frame
    Image icon = Toolkit.getDefaultToolkit().getImage("icona.gif");
    frame.setIconImage(icon);
    frame.add(panel1);
    button3.setForeground(Color.RED);
    button3.setBounds(200, 100, 200, 50);
    panel1.add(button3);
    text12=text1;
    text12.setAutoscrolls(true);
    ExitAction action3 =new ExitAction();
    button3.addActionListener(action3);
    // Create a horizontal progress bar
    int width = 500;
    int height = 200;
    frame.setSize(width, height);
    frame.setVisible(true);
    public class ExitAction implements ActionListener {
    public void actionPerformed(ActionEvent evt) {
    frame.setVisible(false);
    // If the frame is no longer needed, call dispose
    frame.dispose();
    text12.append("EOTS HAS FINISHED THE SIMULATION\n");
    text12.append("0123456789qwertyuiopasdfghjklzxcvbnm0123456789qwertyuiopasdfghjklzxcvbnm0123456789qwertyuiopasdfghjklzxcvbnm0123456789\n");
    text12.append("3\n");
    text12.append("4\n");
    text12.append("5\n");
    text12.append("6\n");
    text12.append("7\n");
    text12.append("8\n");
    text12.append("9\n");
    text12.append("10\n");
    text12.append("11\n");
    text12.append("12\n");
    text12.append("13\n");
    text12.append("14\n");
    text12.append("15\n");
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MS
       JButton  button3 = new JButton("Close Simulation");
       //Create a frame
         String title = "MS SIMULATION";
         JFrame frame = new JFrame(title);
         JTextArea text12 = new JTextArea();
       public MS(JTextArea text1)
         //Create a panel as a container
         JPanel panel1 = new JPanel(null);
         Color mycolor=new Color(0,0,150,200);
         panel1.setBackground(mycolor);
         //Create a frame
         JFrame.setDefaultLookAndFeelDecorated(true);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setBounds(600,600,400,50);
         //setting an image to the frame
         Image icon = Toolkit.getDefaultToolkit().getImage("icona.gif");
         frame.setIconImage(icon);
         frame.add(panel1);
        button3.setForeground(Color.RED);
        button3.setBounds(200, 100, 200, 50);
        panel1.add(button3);
        text12=text1;
         text12.setAutoscrolls(true);
        ExitAction action3 =new ExitAction();
        button3.addActionListener(action3);
        // Create a horizontal progress bar
        int width = 500;
        int height = 200;
        frame.setSize(width, height);
        frame.setVisible(true);
      public class ExitAction implements ActionListener {
            public void actionPerformed(ActionEvent evt) {
                frame.setVisible(false);
                // If the frame is no longer needed, call dispose
                frame.dispose();
                text12.append("METEO STATION HAS FINISHED THE SIMULATION\n");  
    }

    Put the JTextArea into a JScrollPane.

  • GlassPane: How to fire the ActionEvent of a JPanel

    Hello Everyone,
    I'm developing an application with a glasspane added to it. The idea is that some JPanels which act as an Button
    can be "clicked" through the glasspane.The other components may not be clicked when the glasspane is enabled
    When i click on the glasspane on a location where a JPanel is located, the correct Jpanel is found by getDeepestComponentAt (tested by using System.out).
    but when i dispatch the event(mouseclick) on this JPanel the actionEvent isn't fired.
    The JPanels are located in another class file then the glasspane is.
    My question is how to fire a ActionEvent from another class?
    Thanks in advance,

    If you post a SSCCE that demonstrates your problem, someone might be able to help.
    {color:#0000ff}http://www.physci.org/codes/sscce.html{color}
    db

Maybe you are looking for

  • Selection screen modifications

    Hi, I have a sales o order, quantity, unit and material on the selection screen. I have to provide the validations in the following way If  I enter the material number on the selection screen then I need to make quantity as mandatory field. If I ente

  • How to Generate a Custom Message for A Custom Code.

    Hello, Can anyone guide me on this - Application : 11.5.10.2 We have a cutom Trigger through which we want to display a custom message. We have re-generated the .msb, but it seems that something is missing. Following are the Steps We have followed to

  • Read access mdb file in labview via ADO/DAO problem

    Hi guys, I am now facing one problem that I want to import ACCESS database (ver2000) files into labview and turn it into tables. but if I use ADO(actually using LABSQL) I have to create the ODBC in control panel, if I use DAO, I don't know how to cal

  • WL6.0 LDAP Realm problems

    I'm trying out WL6.0 (eval version) LDAP realm support and having trouble getting it to work - basic auth just keeps popping the window up 3 times and then giving up. Only pertinent message in the log is: ####<Mar 16, 2001 12:03:21 PM EST> <Info> <Se

  • MDX query with a DMX query

    Hi All, Do I have a way to run a MDX query with a DMX query? (Avoiding the "link server" options- ) I need to get the cube last update date like this DMX query: SELECT 1 as CubeStatus FROM $System.MDSCHEMA_CUBES where  format(LAST_DATA_UPDATE, 'dd/MM