Waiting for a mouse click in a single thread

Here's my problem:
I'm working on a program I didn't initially create, and I picked it up from the rough midpoint of its evolution. It is a single thread AWT program, with a mouseListener interface already implemented.
Here's my problem. In a game setting, we have two players. It is no problem when both are computer controlled. When player one is controlled by a human, I need to wait for a mouse event before returning, because upon returning player two moves (regardless of its player configuration).
I can't do any kind of busy waiting because it is a single thread. I'm looking for some kind of option besides making the program multithreaded. This also makes it difficult to use some sort of boolean variable, though I don't think it's impossible.
Thanks in advance for any help.
Eric

#9 - You are correct in your assumptions. I agree it's
not the best model, but it worked for the original
purpose, which was to have one player always
controlled by the computer, and the option of
selecting a second player as being either human or
computer. Since each move is made manually - that is,
for a move to be made, it requires user input - there
was no harm in returning from a function, because it
had no immediate computation. The requirements have
just changed, and now I must allow both players to be
selectable. This presents a problem in that I have to
wait for the move actions to finish before
proceeding.Understood.
>
My only question is, how can I access the AWT thread?You mentioned in an earlier post that you have action listeners. As triggered by user events, these are always called on the AWT thread. For example:
import javax.swing.*;
import javax.awt.event.*;
JButton button = new JButton( new AbstractAction {
        public void actionPerformed(ActionEvent e) {
            synchronized (myMonitor) {
                myMonitor.notifyAll();
    });This button can be added to some swing UI. If clicked on, then actionPerformed will be called on the AWT thread, and any threads waiting on myMonitor will be notified.
I see what you are saying - it's almost exactly what
my coworkers told me - but I don't have the knowledge
to implement it, which is why I'm here. Creating a
monitor object isn't a problem (makeMove() would need
to be synchronized, otherwise you wouldn't be able to
call wait()),I recommend using a separate object for the monitor, especially if you are already using synchronized, so that you know exactly how each object's lock is being used. If you're sure it is safe, then there is nothing wrong with using the object itself as the monitor, as you suggest, however.
but I'm not sure what you mean by the
action handling method should be called on the AWT
thread.Just that any action listener method is always called on the AWT thread in response to user action.
Dave

Similar Messages

  • Wait for a mouse click

    Really need help with this one. I'm writing a program to simulate a Risk game and I need to write a method to make two countries neighbors, which would be done by adding each the neighbor country to each country's neighbor's array. To do this, I will need to click on the country, click on the map and then click on the other country. My method gets the country's name but how do I tell it to wait for a mouse click before trying to get the second country's name???? I've tried everything but to no avail. Any help would be appreciated.

    Some object has to be made a mouse listener for the components that are representing countries (I guess there are multiple of these) and the map.
    It should have a variable to represent first country clicked on - a variable that is initially null. It will need another variable to store the information it obtains from the click on the map (location, or whatever). It responds more or less as follows:
    Cick on country:
    Is firstCountry null?
        If so make firstCountry the country that was clicked on and finish
        If not, do we have mapInfo?
            If so use firstCountry, the country that was clicked on and mapInfo to update the neightbour list. Then make mapInfo and firstCountry null. Then finish.
            If not, just finish (because we are waiting for a click on the map).
    Click on map:
    Is firstCountry null?
        If so, just finish (because we are waiting to start the process with a click on a country).
        If not, extract the information from the map and place in mapInfo. Then finish.
    As you can see "waiting" in a GUI is quite a complex business - nothing really pauses, rather it continues as usual until an event of the right "type" occurs. The listener maintains enough "state" (information) to know what it is listening for and to remember necessary information that it has heard and will use later.
    This is somewhat general. It is difficult to be more specific unless you post some code. It should not be pages of GUI code - just enough to illustrate the task of three clicks and an action.

  • How to select a row in JTable for right mouse click ?

    Hi All,
    I need to select a row on JTable for right mouse click ?
    Can any one help me ?
    Thanks a lot.
    Seelam.

    Got solution...
    tabel.addRowSelectionInterval(..) works.
    thanks.

  • Wait for a button click

    Hi,
    Here's the problem :
    my main class calls :
    LoginContext loginContext = new LoginContext("Main",
    new DialogCallbackHandler());
    I've made a DialogCallbackHandler class which opens a JFrame with 2 fields (TextField & PasswordField) and a button "ok".
    But the LoginContext wants immediately an answer (the login & the password). How can I make the loginContext waiting for the button click.
    I tried with a
    while(!buttonClicked);
    but it's not a good solution.
    I also tried with a Thread inside this loop while and sleeps (during a 500 ms). But I think there's a better solution...
    Can I make a wait, and a notify for this or not.
    Thank you for your help.
    Yann
    -- http://www.objectweb.org/jonas

    Why don't you use the JOptionPane class.
    I think it provides all that you need.
    For example use the method :
         String pass = "azedvge";
         JPasswordField passwordField = new JPasswordField(20);
         int result = JOptionPane.showConfirmDialog(parentComponent, password, "Password check", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
         if (result == JOptionPane.OK_OPTION) {
              String p = new String(passwordField.getPassword());
              if (p.equals(pass)) {
                   // OK !
              else {
                   System.exit(0);
         else {
              System.exit(0);
    I hope this helps,
    Denis

  • Why does Lightroom 4.3 use very high cpu when waiting for user to click OK?

    I saved metadata for 52 photos. 
    Lightroom 4.3 couldn't save metadata for 2 of the photos and opened a window to tell me so. (It had no problem saving metadata on second attempt.)
    While it waited for my response and wasn't doing any work, it was using over 50% of my CPU.
    Why?
    Windows 7 is 32-bit Professional.
    Processor: Intel Core i5 750 Processor 2.66 GHz
    Here's my system info as reported by Lightroom. 
    Lightroom version: 4.3 [865747]
    Operating system: Windows 7 Business Edition
    Version: 6.1 [7601]
    Application architecture: x86
    System architecture: x86
    Logical processor count: 4
    Processor speed: 2.7 GHz
    Built-in memory: 3579.4 MB
    Real memory available to Lightroom: 716.8 MB
    Real memory used by Lightroom: 710.9 MB (99.1%)
    Virtual memory used by Lightroom: 847.9 MB
    Memory cache size: 2.0 MB
    Maximum thread count used by Camera Raw: 4
    System DPI setting: 96 DPI
    Desktop composition enabled: Yes
    Displays: 1) 1920x1080
    Application folder: C:\Program Files\Adobe\Adobe Photoshop Lightroom 4.3
    Library Path: D:\Users\Calvin\Pictures\My Lightroom\lightroom\lightroom4\lightroom4.lrcat
    Settings Folder: C:\Users\Calvin\AppData\Roaming\Adobe\Lightroom
    Adapter #1: Vendor : 10de
        Device : 640
        Subsystem : c9593842
        Revision : a1
        Video Memory : 1007
    AudioDeviceIOBlockSize: 1024
    AudioDeviceName: Speakers (Realtek High Definition Audio)
    AudioDeviceNumberOfChannels: 2
    AudioDeviceSampleRate: 44100
    Build: Uninitialized
    Direct2DEnabled: false
    GL_ALPHA_BITS: 0
    GL_BLUE_BITS: 8
    GL_GREEN_BITS: 8
    GL_MAX_3D_TEXTURE_SIZE: 2048
    GL_MAX_TEXTURE_SIZE: 8192
    GL_MAX_TEXTURE_UNITS: 4
    GL_MAX_VIEWPORT_DIMS: 8192,8192
    GL_RED_BITS: 8
    GL_RENDERER: GeForce 9500 GT/PCIe/SSE2
    GL_SHADING_LANGUAGE_VERSION: 3.30 NVIDIA via Cg compiler
    GL_VENDOR: NVIDIA Corporation
    GL_VERSION: 3.3.0
    OGLEnabled: true
    OGLPresent: true
    GL_EXTENSIONS: GL_ARB_arrays_of_arrays GL_ARB_base_instance GL_ARB_blend_func_extended GL_ARB_clear_buffer_object GL_ARB_color_buffer_float GL_ARB_compatibility GL_ARB_compressed_texture_pixel_storage GL_ARB_conservative_depth GL_ARB_copy_buffer GL_ARB_copy_image GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_layer_viewport GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_no_attachments GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL_ARB_get_program_binary GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_program_interface_query GL_ARB_provoking_vertex GL_ARB_robust_buffer_access_behavior GL_ARB_robustness GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shading_language_420pack GL_ARB_shading_language_include GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_range GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a2ui GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_swizzle GL_ARB_texture_view GL_ARB_timer_query GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXTX_framebuffer_mixed_formats GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_shader_objects GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_texture_storage GL_EXT_texture_swizzle GL_EXT_timer_query GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_EXT_import_sync_object GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KHR_debug GL_KTX_buffer_region GL_NV_blend_square GL_NV_conditional_render GL_NV_copy_depth_to_color GL_NV_copy_image GL_NV_depth_buffer_float GL_NV_depth_clamp GL_NV_ES1_1_compatibility GL_NV_explicit_multisample GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_gpu_program4 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_parameter_buffer_object2 GL_NV_path_rendering GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_shader_buffer_load GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_multisample GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_buffer_unified_memory GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_NVX_gpu_memory_info GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control

    I don't think so. 
    I have enough experience with LR to know what to expect for various activities. 
    Previews for all photos had been rendered long before I initiated the Save Metadata.
    Metadata for 50 of the 52 files had already been written. 
    The high cpu had gone on for at least 5 minutes.   I switched to another app imediately after initiating the Save Metadata for the 52 files and only went back to LR when I heard my CPU fan running for a long time.
    When I got back to LR, I saw the "Could not save metadata" window.  I clicked "Show in Library" and OK.  As soon as I did that, CPU usage went back to normal. 
    I've experienced the exact same scenario, where LR can't save metadata for all photos and I've never had LR get stuck consuming a very large amount of CPU.
    As a test, I selected 118 other photos, changed metadata for all of them and then selected all and saved metadata.  LR took about 20 seconds to save metadata for all 118 and LR CPU usage never went above 17%.  The difference is that LR did not show the "Could not save metadata" window.

  • How can I add a popup for right mouse click for anywhere on application?

    I have never used popup menus before but need to add on to my application.
    This is a swing application with several pages that are basically panels that are added and removed as needed.
    I need to have a popup menu that appears anywhere on the application when the right mouse button is clicked,
    no matter which component the cursor is over.
    I have been able to add one for a specific panel, but that is not what needs to be done, since there are dozens
    of separate panels in the application.
    Could someone point me to an example of how to make the popup active for anywhere on the application?
    Thanks.

    You are correct, I have not yet read the tutorial you suggested. I will do so tomorrow and try to move farther up the learning curve.
    My response was intended to acknowledge your reply and let you know where I am in trying to resolve this issue.
    You are also correct in that creating a popup may be a simple task, but, like I stated in my original post, I have never used popups in the past.
    And, like I said, things that are second nature for someone who uses certain components are not always intuitive for people who have not.
    I did do some research before posting my question, but all the examples I found were related to popups tied to a specific panel.
    I am able to create that, but the problem I ran into was that I needed to have a popup menu that was application general, not panel specific.
    It was not obvious to me how to do that and none of the examples I found explained how to do that.
    Hence, my question to the forum, hoping that someone who has gone through this exercise would impart knowledge to help me resolve this issue.
    It is not uncommon for persons to post examples or direct one to web sites that specifically address the issues in question.
    That is what I was hoping for, but I am not adverse to doing follow-up research on leads that are provided.
    My main issue is trying to figure out how to find a parent component (or panel) for the popup.
    You stated that I should be able to get that from the event listener.
    I'm not sure how to do that, but hopefully one of the event listener get methods will provide that information
    Hopefully, I will be able to resolve this with the feedback you provided, but if necessary, I will post code for a simple example to illustrate my problem.
    Thanks again for the feedback.

  • Please help with script for right-mouse click on 3D objects

    Hi!
    I have PDF file with two simple 3d objects (for example with two cube).
    I need to make script that when user right-click to first cube, a PDF file (c:\a.pdf) opening (or c:\b.pdf for second one) in new windows. How to make it? Thank you so much!

    Hi,
    please check SDK sample 22 Right-Click, there is everything you need.
    First catch RightClickEvent, then create the menu entry when beforeAction = true, and when beforeAction = false you have to remove it again (otherwise you will receive an error when rightclicking again).
    Regards
    Sebastian

  • Captivate 8 - I want my slides to stop at the end and wait for a button click to advance

    It works when published as HTML5, but NOT as swf.
    (I have those specific slides set to pause at the end.  They contain stuff the user might want to write down.)
    Instead, the swf project advances to the next slide and THEN stops.  Instead of using the forward button, the user has to use the play button on the skin.
    Any help would be greatly appreciated!

    I suppose you used the On Exit event to pause? In that case the SWF-behavior is normal behavior: the action occurs only after exiting the slide, so Pause will be on first frame of next slide.
    Why not add a click box, time it for the rest of the slide and it will pause at the last frame. And you talk about a Forward button? Why not use the pausing of that button to pause at the last frame (or almost at the last frame)?

  • Custom UIView not receiving touch events for fast mouse clicks in simulator

    I'm having a problem in the simulator where if I click fast in a UIView inside a table cell that is setup to receive touch events, it doesn't receive them. But if I click slow (holding down the button for a little bit) the view gets the touch events. I can't test it on the device. Is this a known problem in the simulator?
    Thanks.

    Hi George,
    Thanks a lot for your quick response and jumping to help.
    I am so frustrated that I did not get touch event for the custom cell.
    I also tried your solution for a custom UIImageView, I put the codes of PhotoView.h, PhotoView.m and TestTouchAppDelegate.m here: Please help to look into it for me.
    // PhotoView.h
    // Molinker
    // Created by Victor on 6/18/08.
    // Copyright 2008 _MyCompanyName_. All rights reserved.
    #import <UIKit/UIKit.h>
    @interface PhotoView : UIImageView {
    CGPoint touchPoint1;
    CGPoint touchPoint2;
    @property (nonatomic) CGPoint touchPoint1;
    @property (nonatomic) CGPoint touchPoint2;
    @end
    // PhotoView.m
    // Molinker
    // Created by Victor on 6/18/08.
    // Copyright 2008 _MyCompanyName_. All rights reserved.
    #import "PhotoView.h"
    @implementation PhotoView
    @synthesize touchPoint1;
    @synthesize touchPoint2;
    - (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    // Initialization code
    self.userInteractionEnabled = YES;
    return self;
    - (void)drawRect:(CGRect)rect {
    // Drawing code
    // Handles the start of a touch
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    UITouch *touch = [touches anyObject];
    touchPoint1 = [touch locationInView:self];
    // Handles the end of a touch event.
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    UITouch *touch = [touches anyObject];
    touchPoint2 = [touch locationInView:self];
    if(touchPoint1.x>touchPoint2.x)
    //move Left
    NSLog(@"Move Left");
    if(touchPoint1.x<touchPoint2.x)
    //move Right
    NSLog(@"Move Right");
    - (void)dealloc {
    [super dealloc];
    @end
    // TestTouchAppDelegate.m
    // TestTouch
    // Created by Victor on 6/17/08.
    // Copyright _MyCompanyName_ 2008. All rights reserved.
    #import "TestTouchAppDelegate.h"
    #import "RootViewController.h"
    #import "PhotoView.h"
    @implementation TestTouchAppDelegate
    @synthesize window;
    @synthesize navigationController;
    - (id)init {
    if (self = [super init]) {
    return self;
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Configure and show the window
    //[window addSubview:[navigationController view]];
    UIImage *myImage= [UIImage imageNamed: @"scene1.jpg"];
    CGRect frame = CGRectMake (0, 20, 300, 400);
    PhotoView *myImageView1 = [[UIImageView alloc ] initWithFrame:frame];
    myImageView1.userInteractionEnabled = YES;
    myImageView1.image = myImage;
    [window addSubview:myImageView1];
    [window makeKeyAndVisible];
    - (void)applicationWillTerminate:(UIApplication *)application {
    // Save data if appropriate
    - (void)dealloc {
    [navigationController release];
    [window release];
    [super dealloc];
    @end
    Message was edited by: Victor Zhang

  • Event Handlers of a mouse click

    In the simplest way possible please tell me how to do an event handler for a mouse click.
    private int clickCounter = 0;
    private void MyCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (Device1RB.IsChecked == true)
    clickCounter++;
    return;
    else if (RemoveRB.IsChecked == true)
    clickCounter--;
    return;
    else
    return;
    private void Switch_class()
    switch (clickCounter)
    case 1:
    //code here
    break;
    case 2:
    //code here
    break;
    case 3:
    //code here
    break;
    case 4:
    //code here
    break;
    case 5:
    //code here
    break;
    default:
    //code here??
    break;
    This is what I have and I apparently need an event handler for the mouse click. Also if there is an easier way to do what I want then please point me in the right direction.

    I still can't figure out why its not working.
    private int clickCounter = 0;
    private void MyCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (Device1RB.IsChecked == true)
    clickCounter++;
    return;
    else if (RemoveRB.IsChecked == true)
    clickCounter--;
    return;
    else
    return;
    private void Switch_class()
    switch (clickCounter)
    case 1:
    pic_1.Visibility = System.Windows.Visibility.Visible;
    break;
    case 2:
    pic_2.Visibility = System.Windows.Visibility.Visible;
    break;
    case 3:
    pic_3.Visibility = System.Windows.Visibility.Visible;
    break;
    case 4:
    pic_4.Visibility = System.Windows.Visibility.Visible;
    break;
    case 5:
    pic_5.Visibility = System.Windows.Visibility.Visible;
    break;
    default:
    //code here??
    break;
    That's what I've got.
    <Canvas x:Name="MyCanvas" HorizontalAlignment="Left" Height="391" Margin="130,20,0,0" VerticalAlignment="Top" Width="520" MouseLeftButtonDown="MyCanvas_MouseLeftButtonDown" Background="Transparent">
    <Rectangle Fill="White" HorizontalAlignment="Left" Height="391" Stroke="Black" VerticalAlignment="Top" Width="520"/>
    <Image HorizontalAlignment="Left" Height="34" VerticalAlignment="Top" Width="100" Source="Power.png" Visibility="Visible"/>
    <Image x:Name="pic_1" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_2" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_3" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_4" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    <Image x:Name="pic_5" Height="42" Canvas.Left="152" Canvas.Top="70" Width="44" Source="2box.png" Visibility="Hidden"/>
    </Canvas>
    This is the canvas...Is there something blatantly obvious that I'm missing?

  • Mouse clicks on windows without focus

    Is there a way to recognize when a user is clicking on a defocused JFrame, to bring it to the front, as opposed to clicking to set a text cursor position within the JFrame? For example, if I click on a terminal emulator I've developed, the text cursor within the emulation window goes to the click, even if the emulator is only being clicked to give it focus. (I've also noticed a similar phenomenon with JBuilder, by the way.)
    By comparison, look at any native Windoze or Macintosh application; very few (if any) behave that way.

    This must be very hard for LabView to do.  I just need to use LabView to run another application. Then have labview emulate a mouse click on that application. I have found out the windows message using Spy++ for the mouse click.  Now in LabView I need to move the mouse to a certain position on that application.  How could LabView know where to move the mouse cursor.  I found some move cursor vi on this forum, then the coordinate of the position on the application (the active window) is not known.  Do I need to map out the position in advance using Spy++?  That seems not reasonable as later on the position may change. 
    LabView is indeed good for Hardware automation and data acquisition, but when it comes to performing some software automation tasks (i.e., runing a couple of other applications automatically), it doesn't seem to be powerful at all, unless the other applications are ActiveX capable, or you have their code to build Dlls.  Most of time, one only need to automate the process of running a couple of other programs, then have data presented.

  • Want CP4 project to play like a "movie" - i.e. no mouse click by user to advance.  How?

    I recorded a simple 2 minute, 7 slide project.  I want the project to play more like a "movie", meaning I don't need the user to "click" to advance to the next slide.  So, no breaks, just play the project from slide 1 to slide 7.  How can I make this happen.  Was looking into slide properties (on slide enter and on slide exit), but nothing seems to make it work the way I want.
    Any thought?

    Hello,
    When you turned the PPT to a CP-file, which settings did you choose? You can have 'Automatic' or 'waiting for user clicks' (I'm not sure about the phrasing but you should recognize this). I presume that you choose the second option. Then the 'movie' will indeed wait for a user click.
    Lilybiri

  • I am writting a test  using a sequencer to test for multiple button click

    I'm using flex sdk 4.1 and have a situation where a  button click is sometimes called twice. I am writting a test for this using a sequencer and it will run for at least one button click, what I am not sure is how to test for multiple click events(which shouldn't happen, but occours randomly in my project)
    package tests.view
        import flash.events.MouseEvent;
        import flexunit.framework.Assert;
        import mx.events.FlexEvent;
        import org.flexunit.async.Async;
        import org.fluint.sequence.SequenceEventDispatcher;
        import org.fluint.sequence.SequenceRunner;
        import org.fluint.sequence.SequenceWaiter;
        import org.fluint.uiImpersonation.UIImpersonator;
        import views.AddComments;
        public class TestAddComments
            private var view:AddComments;
            [Before(async,ui)]
            public function setUp() : void
                view = new AddComments;
                Async.proceedOnEvent( this, view, FlexEvent.CREATION_COMPLETE, 600 );
                UIImpersonator.addChild( view );
            [Test]
            public function testButtonClick():void
                view.addCommentBtn
                var sequence:SequenceRunner = new SequenceRunner( this );
                sequence.addStep( new SequenceEventDispatcher( view.addCommentBtn, new MouseEvent( 'click', true, false ) ) );
                sequence.addStep( new SequenceWaiter( view.addCommentBtn, MouseEvent.CLICK, 100 ) );
                sequence.run();

    The only way you could test for that type of circumstance... one where something may happen... is to do so with a timeout. In other words, you cannot let the test pass simply because the first event occurred.
    Two ways to handle this... with sequences:
    Instead, you write a test that expects 2 clicks. In the assertion handler (which would only be reached if both clicks occur) you would fail the test:
    fail('i shouldnt be here');
    In the Waiter for the 2nd click, you would specify a timeout handler. That timeout handler will get called in the 2nd click does not occur in the specified time... (finding that time is the hard part). The default timeout handler fails the test, however, in your case, your timeout handler would just happily do any assertions needed and move on. A timeout does not necessarily mean failure... in your case, it is correct
    Second choice:
    You could create a timer. Create an event handler for the button click which increments a counter. Start the timer, do your test. However, have your test pending on the timer's completion rather than something like the click.. In that case, you would then be able to just check the count:
    private var clickCount:int = 0;
    [Test]
    public function testButtonClick():void {
         var timer:Timer = new Timer( 100, 1 );
        Async.handleEvent( this, timer, TimerEvent.COMPLETE, checkClickCount );
         view.addCommentBtn.addEventListener( 'click', function( e:Event ):void { clickCount++ } );
         view.addCommentBtn.dispatchEvent( new MouseEvent( 'click;, true, false ) );
    private function checkClickCount( e:Event ):void {
    assertEquals( 1, clickCount );
    However, I can't imagine how the test you are describing could ever yield more than one click event... I am guessing the problem is elsewhere, but this will help you verify
    Mike

  • Cinema 4d Lite not recognizing mouse clicks?

    Hello everyone. I've been working on a project in After Effects CC and was reading about the integration of Maxon Cinema 4d Lite. I wanted to try to make my 2D diamond into a 3D model and it seemed the perfect application to do so. Unfortunately, whenever I open the program (I've tried through File - New - Maxon Cinema File...and Layer - New - Maxon Cinema File... and even once a file is technically created, I've tried going to "edit original". I've also tried to export something else as a Maxon Cinema file and then importing it to see if it would work), it doesn't work.
    Basically, since try #1 the program doesn't seem to be recognizing my mouse clicks. As soon as I click on a menu it goes away. I can hold down the mouse button, but then I can't choose anything on the menu. I've done all the updates on all software, restarted, shut down, cleaned cache, etc. etc. There was one thing that worked, but it only worked for a mouse click at a time! I found that if I found the application file within my program files (C:\Program Files\Adobe\Adobe After Effects CC\Support Files\Plug-ins\MAXON CINEWARE AE\(CINEWARE Support)\lite)....if I have Cinema 4d open, and I double click on the .exe file like I'm trying to launch the program, then the program will recognize one mouse click. But if I try to do anything else, it doesn't respond. I could do this all day and night to get my project done but there's GOT to be an easier way!
    If anyone has any suggestions, I would gladly give them a try!
    Oh, and I'm on a Windows 8.1 64bit computer. If there are any details I didn't include that would be helpful, please let me know. Thank you!

    Thank you Mylenium. I wasn't sure what details to provide, but I'll do my best to cover everything you asked about.
    As far as the computer, my PC is running Windows 8.1 Pro (64-bit). The hardware is as follows:
         Processor: AMD FX8120 (8-core, 3.10GHz)
         Graphics: NVIDIA GeForce GTX550 Ti
         Input Device: Wacom Intuos3 Tablet (using provided mouse, not pen while using C4D)
         Memory: 16 GB usable (have 32 installed but haven't spent the time to figure out how to get it all to work with Windows 8)
         Screen Resolution: on Monitor #1 (HDMI) and Monitor #2 (Analog) it is set to the recommended 1920 x 1080
    I managed to be able to get in to the Preferences within C4d somehow and these are the things I thought might be pertinent:
         OpenGL settings: it IS turned ON (Linear, Anti-Alias = 4, Max transparency = 2, Max Lights = 8, Max Shadows = 2, and Use Shader Cache is checked)
         Memory settings: the cache is defaulted to the C drive. I set my cache in AE to the B drive, which I would prefer but I C4d won't let me change this at the moment)
         Input Devices: PSR Cursor = False, Tool Cursor = true, Mouse Move Activation = True, Graphics Tablet = False, Hi-Res Tablet = True, Open Commander Dialog on Mouse Position = True
    I'm thinking the fact that the Graphics tablet is unchecked in C4d might be the issue? I can try to change it with the trick I originally mentioned, but let me know if there is anything else you see that you think might help. Did I miss anything? I really appreciate it! Thank you.

  • JEditorPane - mouse click simulation doesn't work

    Hi all,
    I have a little problem with my JEditorPane. I want to implement the posibility to put signs on a document loaded in a jeditorpane and save them. One solution is to save the position of the scrollbar, but because the font size can be changed it will not be working. So I want to simulate a cmouse click on the first row of text from viewport to put there the caret and take after that his position. The problem is that the simulation for the mouse click donesn,t work. The event is simulated, but the caret position is not changing.
    I tried also using Robot class, but this implementation give me a serie a mouse events and it moves the cursor to the requested position and it's not the behaviour that I want.
    Here is my code:import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JButton;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.text.BadLocationException;
    public class Reader {
         JEditorPane jEditorPane;
         JScrollPane editorScrollPane;
         private JFrame frame;
         private JPanel readerPane;
         private JPanel commandsPane;
          * @param args
         public static void main(String[] args) {
              new Reader();
         public Reader() {
              frame = new JFrame();
              createReader();
              createCommands();
              addPanes();
              frame.setSize(1000, 850);
              // frame.setExtendedState(frame.MAXIMIZED_BOTH);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              loadHtml();
         private void addPanes() {
              GridBagLayout layout = new GridBagLayout();
              frame.setLayout(layout);
              GridBagConstraints c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.gridx = 1;
              c.gridy = 0;
              c.ipadx = 0;
              c.ipady = 0;
              c.weightx = 1;
              c.weighty = 2;
              frame.add(readerPane, c);
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.HORIZONTAL;
              c.gridx = 1;
              c.gridy = 1;
              c.ipadx = 0;
              c.ipady = 10;
              c.weightx = 0;
              c.weighty = 0;
              c.gridwidth = 1;
              c.gridheight = 1;
              frame.add(commandsPane, c);
         private void createCommands() {
              commandsPane = new JPanel();
              commandsPane.setBackground(Color.white);
              JButton backButton = new JButton("PUSH");
              commandsPane.add(backButton);
              backButton.addMouseListener(new MouseListener() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseEntered(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseExited(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mousePressed(MouseEvent e) {
                        MouseEvent click = new MouseEvent(jEditorPane,
                                  MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(),
                                  16, 10, 200, 1, false, 1);
                        MouseListener[] listeners = jEditorPane.getMouseListeners();
                        for (int i = 0; i < listeners.length; i++) {
                             listeners.mouseClicked(click);
                   @Override
                   public void mouseReleased(MouseEvent e) {
                        // TODO Auto-generated method stub
         private void createReader() {
              jEditorPane = new JEditorPane();
              jEditorPane.setEditable(false);
              jEditorPane.setSelectionColor(Color.green);
              jEditorPane.addMouseListener(new MouseListener(){
                   @Override
                   public void mouseClicked(MouseEvent e) {
                        System.out.println("clicked");
                        System.out.println("caret pos = "
                                  + jEditorPane.getCaretPosition());
                   @Override
                   public void mouseEntered(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseExited(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mousePressed(MouseEvent e) {
                        // TODO Auto-generated method stub
                   @Override
                   public void mouseReleased(MouseEvent e) {
                        // TODO Auto-generated method stub
              editorScrollPane = new JScrollPane(jEditorPane);
              editorScrollPane.setBorder(null);
              editorScrollPane.getVerticalScrollBar().setPreferredSize(
                        new Dimension(0, 0));
              readerPane = new JPanel();
              readerPane.setBackground(Color.black);
              readerPane.setLayout(new GridBagLayout());
              JPanel spacePane = new JPanel();
              spacePane.setBackground(Color.white);
              GridBagConstraints c = new GridBagConstraints();
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.NONE;
              c.ipadx = 500;
              c.ipady = 650;
              c.weighty = 1;
              c.weightx = 1;
              c.gridx = 1;
              c.gridy = 1;
              c.gridwidth = 1;
              c.gridheight = 1;
              readerPane.add(spacePane, c);
              spacePane.setLayout(new GridBagLayout());
              c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.weighty = 1;
              c.weightx = 1;
              c.gridx = 0;
              c.gridy = 0;
              c.gridwidth = 1;
              c.gridheight = 1;
              c.insets = new Insets(20, 20, 20, 20);
              spacePane.add(editorScrollPane, c);
         private void loadHtml() {
              System.out.println("load html file");
              jEditorPane.setContentType("text/html");
              jEditorPane.setText("<html><body>" +
                        "<p>some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing " +
                        "some text here for testing some text here for testing some text here for testing some text here for testing </p>" +
                        "</body></html>");
              jEditorPane.revalidate();
    If tou run this code you can observe that when the "PUSH" button is pressed the jeditorpane receives a mouseclick event, but the caret position is not changing.
    Strange is that when you click with the mouse over the editor pane the caret position is changed and I don't understand what is wrong.
    Can you help me please?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You can use viewToModel() method to get caret position for x, y location. No need to click.
    Regards,
    Stas

Maybe you are looking for

  • Problem with SQL Listener Name

    I installed SQL 2012 with Always on. It has 3 nodes. Here is the detail information about the server:- Server Name Failover Mode SQL Listener Name Node 1 Automatic ABCD Node 2 Automatic ABCD Node 3 Manual ABCD It seems application is having problem t

  • Using MLS exchange with a mac? Does anyone know how?

    Ok, so I'm new to the real estate world and for some reason everything out there is not compatible with a mac and it is very frustrating! How am I supposed to work from home if I can't even get onto the MLS system. It says you have to use Internet Ex

  • Error 1004 when downloading OS X Lion from the App Store.

    Computer: First Generation Macbook Air Problem: I get Error 1004 when attempting to download OS X Lion from the app store.

  • Retina MacbookPro, Freezing after Mountain Lion Update.

    Hello, I recently updated to mountain lion on my rMBP. My machine freezes every 30 minutes or so and All that works upon freezing is my cursor, I cannot do anything but a restart that fixes the problem for another 30 minutes. Some apps I had open whe

  • Custom Tag - how to use tag value= %=jsp% / ?

    Hello friends, I am new to custom tags. I have written simple tags that handle value="some hard-coded stuff">. But cannot not implement jsp-supplied values? Could you please help with advice? Basically, how to implement a custom tag that would allow: