Results 1 to 4 of 4
  1. #1
    maxim is offline Member
    Join Date
    Apr 2008
    Posts
    15
    Rep Power
    0

    Default programmaticly trigger an event

    i have a mouse event that runs some code that i need the computer to trigger automatically at times without the mouse actually being used as the event trigger.how would i go about this any ideas ?
    Last edited by maxim; 02-22-2009 at 11:21 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    In my mind it depends. What else then would trigger the code? another event? a time interval?

  3. #3
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default Two entities fight for one task

    I'm going to assume that the computer, and the
    mouse operator act independent of each other,
    That they don't care what the other is doing,
    but at least they must 'respect' each other.

    So, write an application or applet where only the
    mouse operator performs the operation you want.

    Then write an application or applet where the
    computer alone performs this operation.

    Now you know this much of the code can work.

    To create the final code, throw both of them
    together. (I state it this way because I have no
    idea what your goal is, and this statement is
    concise enough.)

    THIS IS THE IMPORTANT PART:

    To avoid contention between the mouse operator
    and the computer, set up two flags:

    Java Code:
    boolean mouseHasFunction = false;
    boolean computerHasFunction = false;
    Modify your mouseEvent with a test of
    the "computerHasFunction" flag:


    Java Code:
    if(!computerHasFunction){
      mouseHasFunction = true;
    
      whatever you or the
      computer want to do..
    
      mouseHasFunction = false;
    }
    And for the computer, modify its process with a
    test of the "mouseHasFunction" flag:


    Java Code:
    if(!mouseHasFunction){
      computerHasFunction = true;
    
      whatever you or the
      computer want to do..
    
      computerHasFunction = false;
    }

  4. #4
    maxim is offline Member
    Join Date
    Apr 2008
    Posts
    15
    Rep Power
    0

    Default

    yeah its a timer thing. dont worry guys ill just call it from a thread like you would an animation

Similar Threads

  1. Key event
    By ivvgangadhar in forum Threads and Synchronization
    Replies: 1
    Last Post: 12-11-2008, 09:27 AM
  2. JSlider (to NOT cont'd trigger statechanged )
    By hanifa in forum AWT / Swing
    Replies: 4
    Last Post: 09-19-2008, 07:58 AM
  3. sending the message from trigger to mailid
    By geeta_ravikanti in forum JDBC
    Replies: 0
    Last Post: 04-04-2008, 11:09 AM
  4. Event
    By nt5515 in forum New To Java
    Replies: 0
    Last Post: 02-15-2008, 04:44 PM
  5. Timer which should never end and should trigger daily
    By garinapavan in forum New To Java
    Replies: 0
    Last Post: 08-10-2007, 05:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •