When double clicked on item, it also fires single click

Hi,
I want to seperate a single click and a double click. I try doing this by using:
if (e.getClickCount() == 1)
fireSingleClick();
else if (e.getClickCount() >= 2)
fireDoubleClick();
But when I doublic click, it also fires the singleclick. Does anyone know how to prevent this?
thanks,
Hugo

Using the suggestions found on this page I came up with something that I think is a little easier to implement. First of all a few observations:
1) From my testing on Windows 98 it appears that the click count is incremented as long as the click is within about 500 milliseconds. To be consistent I set this as the default value for my class (not the 300 that appears to be used in most threads)
2) A double click will be processed immediately. On the other hand, a single click has to wait 500 milliseconds before being processed, just to make sure another click isn't received (which would make it a double click). Just seems a bit strange that a double clicks executes faster than a single click.
Here's the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class ClickListener extends MouseAdapter implements ActionListener
    MouseEvent lastEvent;
    Timer timer;
    long time;
    public ClickListener()
        this(500);
        time = System.currentTimeMillis();
    public ClickListener(int delay)
        timer = new Timer( delay, this);
    public void mouseClicked (MouseEvent e)
        if (e.getClickCount() > 2) return;
        lastEvent = e;
        if (timer.isRunning())
            timer.stop();
            doubleClick( lastEvent );
        else
            timer.restart();
    public void actionPerformed(ActionEvent e)
        timer.stop();
        singleClick( lastEvent );
    public void singleClick(MouseEvent e) {}
    public void doubleClick(MouseEvent e) {}
    public static void main(String[] args)
        JFrame frame = new JFrame( "Double Click Test" );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.addMouseListener( new ClickListener()
            public void singleClick(MouseEvent e)
                System.out.println("single");
            public void doubleClick(MouseEvent e)
                System.out.println("double");
        frame.setSize(200, 200);
        frame.setVisible(true);
}

Similar Messages

  • How to open each CS version file in its proper version program when double-clicked?

    Hello everyone,
    This one is about the coexistence of Indesign CS4 and CS5.
    In my company: I'm working with Indesign CS4, but a colleague is testing CS5 in real day-to-day works, and everyday I come across CS5 files that I need to correct, so I have CS5 installed too. Now, when I boot in the morning, and no Indesign program is open yet, whenever I double-click on an Indesign file, the system will open it with CS5, no matter if the file is CS4 or CS5. I find this quite annoying, of course. I want each version file to get open right away in the proper version of the program. I'd think this is happening to a lot of people, but I've been looking for the issue in the forums and haven't found anything.
    Of course I'm using roundabouts like having my colleague write "_CS5" at the end of each file, put CS4 in my startup items (so that once the program is open, the issue works the other way around and any Indesign file opens just in CS4 when double-clicked…).
    Also, all the Indesign files appear on the desktop as CS5 files
    I would welcome any ideas on the subject, thanks!

    Muchas gracias! really useful. I'm gonna try it.

  • IE Script error when double clicking on a view in Abap Webdynpro component

    Hello experts,
    I am running mini SAP trial version 2004 with Internet explorer 7.0 and also installed gui patch 23.
    I am making a sample application in SE80 and when double clicking on a view in Abap Webdynpro component I get following error:
    <b>Internet Explorer Script Error</b>
    An error has occured in the script on this page.
    Line: 1
    Char: 1
    Error: 'wdp_show_menu' is undefined
    Code: 0
    URL: http://satellite5200:8000/sap/bc/wdvd/painting.html?_vdrespkey=EOJ6V1JQMX0VLTQ7AP6DQM64Y&_vdframe=painting&sap-client=000
    Do you want to continue running scripts on this page?
    Thanks in advance.
    Bhupendra

    Hi Bhupendra,
       If you are seeing this error in the Se 80 editor , i guess you can ignoire that ...While running the application it will not show any error.
    Thanks
    Anzy

  • RH7 HTML - Receive IE script error message when double-clicking link to auto-size pop-up

    Hi, all,
    Anybody ever seen this situation? When double-clicking on a link to an auto-size pop-up, I get the following Internet Explorer script error message:
    This error also occurs when I double-click the link in preview mode within the project. A colleague that is running the same version of IE with the same settings is not receiving this error. A couple of other co-workers are running a different version of IE, and one gets this error and one does not.
    This error does not occur if you single-click the link (which you would normally do), nor does it occur if you double-click a link to a fixed-size pop-up. Once you receive this message and click Yes or No, the link sometimes works correctly when you double-click. I haven't been able to establish a pattern. Also, if you single click the link to display the pop-up, click off of it, and then double-click the link, the error does not occur.
    As you can tell by now, this problem is kind of hard to pin down. I've done some research and I have yet to stumble upon anything that deals with this issue. Unless there is a solution out there, I can do one of two things: 1) change all of the auto-size pop-ups in the project to fixed-sized, which defeats the purpose of creating auto-size pop-ups, or 2) tell our customer not to double-click links.
    Any advice you could give would be welcome.

    Hi there
    Indeed it has been reported on many occasions over the years. Unless someone like Willam has some way cool error detection magick with the scripts, the best approach we have always offered is this.
    Educate your users on the way computers and HTML works. HTML works using SINGLE clicks, not DOUBLE clicks.
    The reason for the error is because the first click caused the computer to launch a JavaScript command to open the sized popup. The second click that followed in rapid succession confused things by asking the script to stop what it was doing and run again.
    Maybe it would help to explain it to your users like this. If you visited a restaurant and when the server asked what you wanted to order, would the become confused if you said to them: I'll have the T-Bone Steak and nearly immediately you repeated it by saying again I'll have the T-Bone Steak.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Show long text for Quality Notification when double click field in alv

    I have an ALV grid called using a FM and I am using the user command routine to do somthing when a particular cell is  clicked.  I want to  call up the root cause text from the action box of the QN via QM03 .  I am building a BDC table to call with a CALL transaction but when I write my BDC up to that point, the program is running the BDC but not going to the point where the long text is displayed is i am in mode 'N'.
    FORM user_command USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      READ TABLE itab INDEX rs_selfield-tabindex.
      CASE r_ucomm.
        WHEN '&IC1'.
          CASE rs_selfield-fieldname.
    * When double click on root cause, display root cause long text
            WHEN 'ZZ_URCOD'.
              PERFORM display_root_cause_text.
              CALL TRANSACTION 'QM03' USING gt_bdc MODE 'N'.
      ENDCASE.
    ENDFORM.                    "user_command
    FORM display_root_cause_text .
      FREE gt_bdc.
      PERFORM fill_bdc USING 'SAPLIQS0'     '0200'      'X'.
      PERFORM fill_bdc USING 'RIWO00-QMNUM'  itab-qmnum  space.
      PERFORM fill_bdc USING 'SAPLIQS0'     '7200'      'X'.
      PERFORM fill_bdc USING 'BDC_OKCODE'  '=10\TAB03'  space.
      PERFORM fill_bdc USING 'SAPLIQS0'     '7200'      'X'.
      PERFORM fill_bdc USING 'BDC_CURSOR'
                             'QMICON-LTURSACHE(01)'     space.
      PERFORM fill_bdc USING 'BDC_OKCODE'  '=UX01'  space.
    ENDFORM.                    " DISPLAY_ROOT_CAUSE_TEXT
    Any one have any suggestions of know of a BAPI that I can achieve the same thing?
    Thanks
    Larissa Maryniuk

    Hello,
    also try to use the messages clause (of type BDCMSGCOLL).
    This will return the system messages.
    call transaction 'XXXX' using BDCTAB
                                            mode 'P'
                                            messages into MSG_TAB.
    Try to change the mode from 'N' to 'P' and try to place a breakpoint and check what happens.
    Alternatively, you can read the Quality Notification text using FM READ_TEXT, and then show this data to the user in pop-up, rather than calling the tx.
    Hope this helps.

  • Audio and video don't open together in viewer when double clicked

    Hello everyone!
    I'm having an annoying problem... it isn't something terribly important, but has decreased my work flow speed. Recently, I've had some trouble opening clips from the timeline in the viewer with the double click.
    If I double click the video portion of the clip, even if both the video and two audio tracks are highlighted (and are still linked) only the video portion of the clip will appear (along with "filters" and "motion" tabs) in the viewer, and similarly when double clicking the audio tracks, though both video and audio are highlighted, only the audio tracks and "Filters" tab show up in the viewer. Additionally, once the item is double clicked at the left with the jigsaw pieces that can be used to set video and audio destinations, if I've clicked on an audio portion so only audio shows up in the viewer, only the jigsaw pieces for the two audio tracks (a1, a2) are visible, video track (v1) is no longer present, and vice versa.
    I'd appreciate any advice that you all have! It's really driving me batty, in addition to not knowing what I did to make it that way, I can't figure out how to change it back!
    Heather

    Thanks for the advice.
    The clips already appeared to be linked, and the selection "link" was checked, however when I unlinked and then relinked I found that the audio and video would open up at the same time in the viewer... problem apparently solved! However, the clips I had been working with I had to nudge audio and video a few frames apart (out of sync) to get the audio and video to line up. (gives the little red box with a +or- number in it on the clip).
    When I unlinked and then relinked, the clip lost those red boxes and went back to being synced (as far as FCP is concerned) with the audio and video unaligned.
    So, the problem appears to be coming from when I move the audio and video of a clip out of sync... why is this? Is this something I'm just going to have to deal with?
    Thanks
    H

  • Quick - Adobe Genius Needed: Footage and stills are black when double clicked - audio but no image ? What the ... ?

    I am doing the training video as this is the first time i have used premiere pro cc or any version of it at all.  I have downloaded the footage and stills as shown in the video but when i go to double click the beach footage it comes up as black - i can hear the waves but the video isn't playing. Same with the stills, they do not show up when double clicked either, they are just black. Dont know what to do.  Your help would be greatly appreciated.
    Cheers

    Without a screen shot, it's hard to know why the footage/stills are black. Double-clicking the asset opens it in the Source monitor, as opposed to the Project monitor, which could be black if the playhead is not set to a portion of the timeline that shows a movie clip or still. Perhaps your Source monitor is closed or hidden for some reason. After double-clicking the asset, select Window > Source Monitor in the main menu. You should be able to select the specific asset (e.g., Shot_01.mp4) and then see it on the screen. Make sure you also select Window > Workspace > Editing so that your panel layout shows the various panels properly.
    HTH,
    Stefan

  • Error when double clicking rdf file?

    I'm using Reports 10g R2 on Windows XP Pro SP2. When I try to double click on a report file (ANMSC.rdf) the Report Builder starts, but doesn't open the report file. I get the following error:
    Windows cannot find D:\ANMSC.rdf. Make sure you typedthe name correctly, and then try again. To search for a file, click the Start button, and then click Search.
    Also, report files have a generic icon instead of the Oracle Reports icon.
    Does anyone know why Oracle Reports can't open the file when double clicking?

    I'm using Reports 9i and the same happens.

  • 2013 excel won't open when double clicked

    Hello,
    I am using window's 7. I am having an issue with excel. An excel file will not open when double clicked.
    Thank you,

    Hi,
    Does this issue happen to a certain Excel file or all Excel files?
    If this only happen to a certain Excel file, where is the file stored? We may try to open a blank Excel file, and then open the certain Excel file via File > Open and then navigate to the file to see the result.
    If this issue happens to all Excel files, please go to Task Manager, click Processes tab and make sure Excel.exe is not listed there. If Excel.exe is listed, end the process and then try to opening Excel file to see the result.
    If above doesn't fix the issue, we may also try to
    run a repair of your Office installation to see the result. It seems that the method fixed a similar issue for a number of users according to another thread.
    Please have a try and let me know the result.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • When double-clicking thumbnails, images "mosaic" or "tile"

    Since the Snow Leopard Graphics Update, images flash briefly in a jagged "mosaic" or "tile" manner before they convert to full size when double-clicking thumbnails. This happened briefly right after installing the update, then went away after a restart, but now it's back. Running Aperture 3.0.3 on my MBP 2.5GHz with OS 10.6.4.

    Thanks for your replies guys. First I don't know happened to the screenshot I posted but here it is again. I hope you guys were/are able to get anything from it.
    When I first noticed the issue I backed up my iPhoto library. Next I upgraded to Snow Leopard since this computer was running Leopard. I also upgraded to iPhoto '09 since it was running an older version. Still no fix. I then uninstalled iphoto and its pref files with appzapper and then reinstalled iPhoto '09. Again no luck. I then created a new user account and the same thing happens- no fix.
    @Terrance- I opened the app Monolingual and I see that the default languages selected include: Austrailia, Canada, New Zealand, UK, and US English, which I deleted. The Language just "English" is not selected and was not deleted. Could this be it?
    Thanks again. I will look into the links you provided, Madison and will be back to report with points.

  • Problem while displaying the data when double clicked on JTable element

    Hi All,
    i have one List box( JList ) and one table (JTable). Both JTable and JList are positioned on the same Frame. I am able to drag the elements from JList to JTable and also i have added the mouse click action on both List box and JTable.
    if i double click on JList element, that will popup one dialog box.
    if i double click on JTable cell element that was dragged from JList, that will popup same dialog box which was opened earlier for JList action.
    But my problem here is:
    Suppose if i drag the four elements one by one from JList to JTable and (after four elements dragged) double clicked the first element which was dragged first that displayed the popup dialog box structure correctly but the data displayed in that was not correct. It is showing the data of recent dragged element( i.e, fourth element).
    But if i double click on JList element that is showing the correct data according to the double clicked element.
    What might be the problem here, why it was not displaying the correct data when double clicked on JTable element.
    Please help me here.
    Many thanks in advance.
    The following code is used in mouse clicked event method of JList
    private void listMouseClicked(java.awt.event.MouseEvent evt) {                                              
             if(evt.getClickCount()==2){
             AssigningResourcesUI assignResource=new AssigningResourcesUI(this,true);
             assignResource.show();
    }                AND The following code is used in mouse click enevet method of JTable.
    private void tableMouseClicked(java.awt.event.MouseEvent evt) {                                          
            if(evt.getClickCount()==2){
             int row=table.rowAtPoint(new Point(evt.getX(), evt.getY()));
             int col=table.columnAtPoint(new Point(evt.getX(), evt.getY()));
             if(row==-1||col==-1){
                 return;
              Object obj=table.getModel().getValueAt(row, col);
             if(obj==null||(obj.equals(""))){
               }else{
             AssigningResourcesUI assignResource=new AssigningResourcesUI(this,true);
             assignResource.show();
         }            Thanks & Regards,
    Maadhav....
    Edited by: maadhav on Jul 1, 2009 7:22 AM

    I doubt it is related to your problem but:
    int row=table.rowAtPoint(new Point(evt.getX(), evt.getY()));Why are you creating a new Point? Just use evt.getPoint().
    Object obj=table.getModel().getValueAt(row, col);Don't get the data through the model method, get the data through the table method:
    Object obj = table.getValueAt(...)
    This way it will work even if the table happens to be sorted.
    Instead of creating a AssigningResourcesUI object, just disply the value retrieved from the model. That way you know whether the problem is with the mouse event code or your UI class. Like Walter suggested above I"m guess the problem is with your UI class.

  • Photos Won't Enlarge When Double Clicked

    Hi, Can anyone tell me if the photos I've imported to my unpublished iWeb site will only enlarge when double clicked when the site is published? Do I need to be associated with a web browser for this to work? It's driving me nuts. Thanks.

    Welcome to the discussions. Yes, photos placed on iWeb's Photos template page only enlarge when published and viewed via a web browser. (The Slideshow also will only play in a browser.) Note that photos on other template pages will not enlarge when clicked — unless you've set up a hyperlink to do that.

  • How to get the alv grid report in another screen when double click on basic

    Hi.
    I have created an alv report using class cl_gui_alv_grid.I got another report in the same screen,when double clicked on basic list(using double_click event).I want to get this report in another screen.What i have to do?(In classical reports i worked with sy-lsind = 1 ,but how to do here?)
    How to set color to the selected rows in the alv grid report?I worked with change_data_from_inside method of cl_gui_alv_grid.But it didn't work out..
    With Regards,
    Ramana.

    On double click event . you will have to call another screen say 9000.
    now within screen 900 PBO.. you will have to prepare the fieldcatalog/layout.. and the table to be displayed there.
    in PAI of screen 9000, you can return to the original ALV.
    method double_click.
    call screen 9000.
    endmethod.
    " now in PBO create a module display_alv2
    module display_alv2.
    'prepare the fieldcat/layout info for new alv
    'add the data to the new ALV table
    'instantiate the grid call.. etc
    'call the ALV
    endmodule
    "in PAI
    module exit.
    case sy-ucomm.
    when 'ENT1'.
      leave to screen 0.
    endcase.
    endmodule
    while preparing the field catalog you can mention the EMPHASIZE field, whish will give color to tht column
    E.g
    *--Service Order
        ls_fieldcat-tabname   = 'IT_FINAL_VALID'.
        ls_fieldcat-fieldname = 'AUFNR'.
        ls_fieldcat-scrtext_m = 'Service Order'.
        ls_fieldcat-ref_table = 'AUFK'.
        ls_fieldcat-ref_field = 'AUFNR'.
        ls_fieldcat-col_pos   = 1.
        ls_fieldcat-outputlen = 12.
        ls_fieldcat-emphasize = 'C400'.  "This will add color to the cell
        APPEND ls_fieldcat TO fcat_valid.
    Hope this helps.

  • How does this happen: The picture of recent apps you get when double clicking the home button showed in Settings-Wifi that I had been connected to a network I have not been near for two months. Its not a recent "image" of Settings-Wifi. Can anyone explain

    How does this happen: The picture of recent apps you get when double clicking the home button showed in Settings-Wifi that I had been connected to a network I have not been near for two months. Its not a recent "image" of Settings-Wifi. Can anyone explain?

    Greetings,
    I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
    At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
    The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
    I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
    You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
    Good Luck - Cheers,
    M.

  • When double click itunes icon it shows " The file itunes library.itl can not be read because it was created by a newer version of itunes" so what can i do?

    when double click itunes icon it shows " The file itunes library.itl can not be read because it was created by a newer version of itunes" so what can i do?

    Unless you have attempted to downgrade to an older version of iTunes this is likely to be a sign of a corrupt library. See Empty/corrupt library after upgrade/crash.
    tt2

Maybe you are looking for