Fire event manually!

Hi:
If I press Enter-Key, I want to do the same, as if I click on te Button called "calculate". The click on calculate-Button will be processed to methode actionPerformed. How cann I fire manually the click-Event on the calculate-Button without clicking on this button?
Thanks

Thanks:
I tried as follow:
public void keyPressed(KeyEvent e)
          if ((e.getSource() instanceof Button) &&
             (((Button)e.getSource()).getActionCommand().equals("Berechnung")))
               int kc = e.getKeyCode();
               if (kc == KeyEvent.VK_ENTER)
                    /* --- Do you think so --- */
                    ActionEvent ae = new ActionEvent(this, 10, "Berechnung");
                    actionPerformed(ae);
                    /* I tried it, but it doesn't work --- */     
          else
               int n = e.getKeyCode();
               if  ((n < 48 || n > 57) &&
                      n != KeyEvent.VK_MINUS &&
                      n != KeyEvent.VK_PERIOD &&
                      n != KeyEvent.VK_TAB)
                    Toolkit.getDefaultToolkit().beep();
                    e.consume();
                    return;     
     }

Similar Messages

  • 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.

  • Want to fire event receiver before workflow is execute while adding File in Document Library.

    Hi,
    I have Event receiver and workflow attached to same Document
    Library.
    Is it possible to fire event receiver before Workflow is
    executed ?
    Regards,
    Milind

    Hi,
    According to your description, my understanding is that you want fire event receiver before workflow is excuted.
    If the workflow for a list is set to auto-start, it will always execute before event receiver by default.
    Here is a similar thread for your reference:
    http://sharepoint.stackexchange.com/questions/3147/execution-order-of-event-receivers-and-workflow-on-a-list
    As a workaround, you can set the workflow start by manually. Then , after executing the event receiver, you can start workflow using code at the end of event receiver.
    Here is a demo for your reference:
    http://zimmergren.net/technical/starting-a-sharepoint-workflow-from-code-event-receiver
    More information about start workflow using C#:
    http://jainnitin2411.wordpress.com/2012/07/06/programmaticallystartsharepointworkflow/
    Best regards,
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

  • Fire event in web dynpro java

    Hi,
    I want to fire events in code e.g. sorting of table columns. I'm sure I cannt call event handler with null parameter here.
    Can anybody please help here?
    Thanks in advance.
    Rgds,
    Atul.

    Hi Kishan,
    I think I'm confusing you. i do not have any controller usage.
    below is my event handler method:
    public void onActionSortTableColumn(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        TableAccessories Accessories = wdContext.currentcontextElement().getTableSorter();
        Accessories.onTableEvent(wdEvent);
    I just want to anyhow call this method, without wdEvent being null.
    Is there any way I can fire the event and this method get called OR to create wdEvent to call this method directly?
    Rgds,
    Atul.

  • EVENTS : Arranging Photos in an Event Manually

    I have imported about 8000 photos and they are sorted in separate events. I would like to re-arrange the order of some of the photos in the events manually but when I try to do this via "sort photos", the manual option is greyed out and it won't let me do it anyway via drag and drop.
    1) Why is this?
    2) Can I actually change the order of photos within an event manually?
    3) Do you have to create an additional album for each event which duplicates the event in order to re-arrange photos within an event?
    Help!

    I have imported about 8000 photos and they are sorted in separate events. I would like to re-arrange the order of some of the photos in the events manually but when I try to do this via "sort photos", the manual option is greyed out and it won't let me do it anyway via drag and drop.
    1) Why is this?
    Because events can not be manually sorted
    2) Can I actually change the order of photos within an event manually?
    No
    3) Do you have to create an additional album for each event which duplicates the event in order to re-arrange photos within an event?
    No matter what you can not rearrange photos within events manually - you can rearrange photos in albums
    You can move photos between events, split events, and combine events
    Events are the most basic automatic organization - most people use faces, places and keywords with smart albums for their organization beyond the time based events
    LN

  • 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.

  • Organizing pictures in events manually

    Hello,
    I have about 500 plus pictures in an event say pictures.
    I want to organize the pics in the event manually according to my order, when I click View>sort photos> the manual button is grey.
    I am able to manually sort pics in Photos or the event it self but not the pics in the event
    Please help as the pics are all mixed up

    That is not a feature of iPhoto - events are the most basic default organization and have very limited sort options - manual is not available - use albums for that
    Events essentially are time based
    LN

  • 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 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

  • Useful Code of the Day:  Button fires events while held

    Have you ever been making a GUI application with Swing and used some JButtons? Fun, right? Have you ever wanted to have the button fire action events while the button was being held down? Well, if you just stick a plain JButton in your application and press and hold the mouse button on it, you'll see it doesn't do anything except sit there looking pressed in. Insolent button!
    RepeatButton (code below, couldn't think of a better name) is a JButton subclass which contains a timer that is set when the mouse button presses the button, and after a slight initial delay (configurable), fires action events to all registered action listeners repeatedly (with another configurable delay between events) until either the mouse is released or the mouse moves out of the button (it starts up again if the mouse moves back over without releasing the mouse button) or the button is disabled. The event modifiers are passed on as well, so you know if the shift or control buttons (or whatever) are being pressed at the same time.
    There is also a method to disable the repeated action firing while holding. This, in effect, turns the button into a normal JButton, if needed.
    There is a main method for testing which will show a button in a frame and print out the action command for each action event fired.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    * <code>RepeatButton</code> is a <code>JButton</code> which contains a timer
    * for firing events while the button is held down.  There is a default
    * initial delay of 300ms before the first event is fired and a 60ms delay
    * between subsequent events.  When the user holds the button down and moves
    * the mouse out from over the button, the timer stops, but if the user moves
    * the mouse back over the button without having released the mouse button,
    * the timer starts up again at the same delay rate.  If the enabled state is
    * changed while the timer is active, it will be stopped.
    * NOTE:  The normal button behavior is that the action event is fired after
    * the button is released.  It may be important to konw then that this is
    * still the case.  So in effect, listeners will get 1 more event then what
    * the internal timer fires.  It's not a "bug", per se, just something to be
    * aware of.  There seems to be no way to suppress the final event from
    * firing anyway, except to process all ActionListeners internally.  But
    * realistically, it probably doesn't matter. 
    public class RepeatButton extends JButton
              implements ActionListener, MouseListener {
          * The pressed state for this button.
         private boolean pressed = false;
          * Flag to indicate that the button should fire events when held. 
          * If false, the button is effectively a plain old JButton, but
          * there may be times when this feature might wish to be disabled. 
         private boolean repeatEnabled = true;
          * The hold-down timer for this button.
         private Timer timer = null;
          * The pressed state for this button.
         private int delay = 60;
          * The pressed state for this button.
         private int initialDelay = 300;
          * Holder of the modifiers used when the mouse pressed the button. 
          * This is used for subsequently fired action events.  This may change
          * after mouse pressed if the user moves the mouse out, releases a key
          * and then moves the mouse back in. 
         private int modifiers = 0;
          * Creates a button with no set text or icon.
         public RepeatButton() {
              super();
              init();
          * Creates a button where properties are taken from the Action supplied.
          * @param  a  the button action
         public RepeatButton(Action a) {
              super(a);
              init();
          * Creates a button with an icon.
          * @param  icon  the button icon
         public RepeatButton(Icon icon) {
              super(icon);
              init();
          * Creates a button with text.
          * @param  text  the button text
         public RepeatButton(String text) {
              super(text);
              init();
          * Creates a button with initial text and an icon.
          * @param  text  the button text
          * @param  icon  the button icon
         public RepeatButton(String text, Icon icon) {
              super(text, icon);
              init();
          * Initializes the button.
         private void init() {
              this.addMouseListener(this);
              // initialize timers for button holding...
              this.timer = new Timer(this.delay, this);
              this.timer.setRepeats(true);
          * Gets the delay for the timer of this button. 
          * @return  the delay
         public int getDelay() {
              return this.delay;
          * Set the delay for the timer of this button. 
          * @param  d  the delay
         public void setDelay(int d) {
              this.delay = d;
          * Gets the initial delay for the timer of this button. 
          * @return  the initial delay
         public int getInitialDelay() {
              return this.initialDelay;
          * Sets the initial delay for the timer of this button. 
          * @param  d  the initial delay
         public void setInitialDelay(int d) {
              this.initialDelay = d;
          * Checks if the button should fire events when held.  If false, the
          * button is effectively a plain old JButton, but there may be times
          * when this feature might wish to be disabled. 
          * @return  if true, the button should fire events when held
         public boolean isRepeatEnabled() {
              return this.repeatEnabled;
          * Sets if the button should fire events when held.  If false, the
          * button is effectively a plain old JButton, but there may be times
          * when this feature might wish to be disabled.  If false, it will
          * also stop the timer if it's running.
          * @param  en  if true, the button should fire events when held
         public void setRepeatEnabled(boolean en) {
              if(!en) {
                   this.pressed = false;
                   if(timer.isRunning()) {
                        timer.stop();
              this.repeatEnabled = en;
          * Sets the enabled state of this button.  Overridden to stop the timer
          * if it's running.
          * @param  en  if true, enables the button
         public void setEnabled(boolean en) {
              if(en != super.isEnabled()) {
                   this.pressed = false;
                   if(timer.isRunning()) {
                        timer.stop();
              super.setEnabled(en);
          * Handle action events.
          * @param  ae  the action event
         public void actionPerformed(ActionEvent ae) {
              // process events only from this components
              if(ae.getSource() == this.timer) {
                   ActionEvent event = new ActionEvent(
                        this, ActionEvent.ACTION_PERFORMED,
                        super.getActionCommand(), this.modifiers);
                   super.fireActionPerformed(event);
              // testing code...
              else if(testing && ae.getSource() == this) {
                   System.out.println(ae.getActionCommand());
          * Handle mouse clicked events.
          * @param  me  the mouse event
         public void mouseClicked(MouseEvent me) {
              // process events only from this components
              if(me.getSource() == this) {
                   this.pressed = false;
                   if(this.timer.isRunning()) {
                        this.timer.stop();
          * Handle mouse pressed events.
          * @param  me  the mouse event
         public void mousePressed(MouseEvent me) {
              // process events only from this components
              if(me.getSource() == this && this.isEnabled() && this.isRepeatEnabled()) {
                   this.pressed = true;
                   if(!this.timer.isRunning()) {
                        this.modifiers = me.getModifiers();
                        this.timer.setInitialDelay(this.initialDelay);
                        this.timer.start();
          * Handle mouse released events.
          * @param  me  the mouse event
         public void mouseReleased(MouseEvent me) {
              // process events only from this components
              if(me.getSource() == this) {
                   this.pressed = false;
                   if(this.timer.isRunning()) {
                        this.timer.stop();
          * Handle mouse entered events.
          * @param  me  the mouse event
         public void mouseEntered(MouseEvent me) {
              // process events only from this components
              if(me.getSource() == this && this.isEnabled() && this.isRepeatEnabled()) {
                   if(this.pressed && !this.timer.isRunning()) {
                        this.modifiers = me.getModifiers();
                        this.timer.setInitialDelay(this.delay);
                        this.timer.start();
          * Handle mouse exited events.
          * @param  me  the mouse event
         public void mouseExited(MouseEvent me) {
              // process events only from this components
              if(me.getSource() == this) {
                   if(this.timer.isRunning()) {
                        this.timer.stop();
          * Testing flag.  Set in main method.
         private static boolean testing = false;
          * Main method, for testing.  Creates a frame with both styles of menu.
          * @param  args  the command-line arguments
         public static void main(String[] args) {
              testing = true;
              JFrame f = new JFrame("RepeatButton Test");
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel p = new JPanel();
              RepeatButton b = new RepeatButton("hold me");
              b.setActionCommand("test");
              b.addActionListener(b);
              p.add(b);
              f.getContentPane().add(p);
              f.pack();
              f.show();
    "Useful Code of the Day" is supplied by the person who posted this message. This code is not guaranteed by any warranty whatsoever. The code is free to use and modify as you see fit. The code was tested and worked for the author. If anyone else has some useful code, feel free to post it under this heading.

    This makes word completion possible for JTextArea:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.util.*;
    * This class provides word completion for JTextArea.
    public class WordCompleteArea extends JTextArea {
        private boolean isTextComplete = true;
        public WordCompleteArea (Document doc, String text,
                                      int rows, int columns, KeyStroke expandKey) {
            super (doc, text, rows, columns);
            String s = "word-complete";
            Action wordComplete = new AbstractAction () {
                public void actionPerformed (ActionEvent e) {
                    wordComplete ();
            getInputMap ().put (expandKey, s);
            getActionMap ().put (s, wordComplete);
        public WordCompleteArea (Document doc, String text, int rows, int columns) {
            this (doc, text, rows, columns,
                            KeyStroke.getKeyStroke ("ctrl pressed SPACE"));
        public WordCompleteArea (Document doc) {
            this (doc, null, 0, 0);
        public WordCompleteArea (String text, int rows, int columns) {
            this (new PlainDocument (), text, rows, columns);
        public WordCompleteArea (int rows, int columns) {
            this (null, rows, columns);
        public WordCompleteArea (String text) {
            this (text, 0, 0);
        public WordCompleteArea () {
            this (0, 0);
         * Define if text already written in the JTextArea will be used
         * for expansion.
        public void setTextComplete (boolean b) {
            isTextComplete = b;
         * Find out if text already written in the JTextArea will be used
         * for expansion.
        public boolean isTextComplete () {
            return isTextComplete;
        private String tokenDelimiters = "\t\r\n ,;()[]{}%+/-*<>=&|!\"\'.@#";
         * Get delimiters that form a word.
        public String getTokenDelimiters () {
            return tokenDelimiters;
         * Set delimiters that form a word.
        public void setTokenDelimiters (String s) {
            tokenDelimiters = s;
        // Additional words used for expansion.
        private LinkedList wordCompleteList = new LinkedList ();
         * Add words that will be used as expansion.
        public void addCompleteWords (java.util.List words) {
            wordCompleteList.add (words);
         * Add a word that will be used as expansion.
        public void addCompleteWord (String word) {
            wordCompleteList.add (word);
        private String lastExpanded = null;
        private String lastExpansion = null;
        private Set dontAccept = new HashSet ();
        protected void wordComplete () {
            int caret = getCaretPosition ();
            if (caret == 0)
                return;
            String text = getText ();
            if (caret != text.length () && isCompletionLetter (text.charAt (caret)))
                return;
            StringBuffer sb = new StringBuffer ();
            int index = caret - 1;
            char ch;
            while (index >= 0 && isCompletionLetter ((ch = text.charAt (index)))) {
                sb.append (ch);
                index--;
            if (sb.length () == 0)
                return;
            sb.reverse ();
            String word = sb.toString ();
            String toExpand = word;
            if (toExpand.equals (lastExpansion)) {
                dontAccept.add (lastExpansion);
                toExpand = lastExpanded;
            } else {
                dontAccept.clear ();
            String s = findExpansion (toExpand, caret);
            if (s != null) {
                lastExpanded = toExpand;
                lastExpansion = s;
                replaceRange (s, caret - word.length (), caret);
            } else {
                dontAccept.clear ();
                lastExpanded = null;
                lastExpansion = null;
                int diff = word.length () - toExpand.length ();
                replaceRange ("", caret - diff, caret);
        private boolean isCompletionLetter (char ch) {
            return tokenDelimiters.indexOf (ch) < 0;
        protected String findExpansion (String word, int caret) {
            StringTokenizer st;
            if (isTextComplete) {
                st = new StringTokenizer (getText (), getTokenDelimiters ());
                while (st.hasMoreTokens ()) {
                    String s = st.nextToken ();
                    if (    s.startsWith (word)
                            && s.length () != word.length ()
                            && !dontAccept.contains (s)      ) {
                        return s;
            for (Iterator it = wordCompleteList.iterator (); it.hasNext (); ) {
                st = new StringTokenizer
                                ((String) it.next (), getTokenDelimiters ());
                while (st.hasMoreTokens ()) {
                    String s = st.nextToken ();
                    if (    s.startsWith (word)
                            && s.length () != word.length ()
                            && !dontAccept.contains (s)      ) {
                        return s;
            return null;
        // TEST
        public static void main (String[] args) {
            WordCompleteArea a = new WordCompleteArea ();
            JFrame window = new JFrame ();
            window.getContentPane ().add (a, BorderLayout.CENTER);
            window.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
            window.setSize (300, 300);
            window.setVisible (true);
    }

  • 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);

  • Fire Event problem

    I would like to manually fire a SizeChangedEvent, but having problems to get it fired.
    I get Invalid arguments error, when trying to call it.
    Here is my code:
    private delegate void ChangedDelegate(object sender, SizeChangedEventArgs e);
    private event ChangedDelegate ChangedEvent;
    public void MyMethod(string str)
            //do stuff ....
            //Manually Raise event here
            ChangedEvent(this, SizeChangedEventArgs.Empty);        //get error: some Invalid arguments  
    //standard method sizechanged
    private void Control_SizeChanged(object sender, SizeChangedEventArgs e)
            //do stuff ....  
    Any help and explanation appriciated.
    Thanks

    The SizeChangedEventArgs.Empty property returns an EventArgs (though the EventArgs base class) and and EventArgs cannot be casted to a SizeChangedEventArgs.
    In fact the SizeChangedEventArgs class doesn't have any public constructor so you cannot create an instance of it nor manually invoke the event.
    If you want to run some code inside the SizeChanged event handler, you should move this code to a method and then call this method directly from the event handler and your MyMethod:
    public void MyMethod(string str) {
    //do stuff ....
    DoStuff();
    private void Control_SizeChanged(object sender, SizeChangedEventArgs e) {
    DoStuff();
    private void DoStuff() {
    Please remember to mark helpful posts as answer and/or helpful.

  • 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

  • Sort photos in an event manually

    Why would the sort manually option be grayed out, not able to choose?
    I went into event click view, click sort photos but the manually option is not available.
    Is there a way to change this?
    Thanks

    Because manual sorting of events or photos within an event is not a feature of iPhoto '09 - and no there is now way to turn it on
    albums can be manually sorted - events are (by default) in time/date order
    LM

  • 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.

Maybe you are looking for