How to separate double click action and single click action

in my mouse action listerner for JTable.
i do two actions, when user doule click column header, sort the column,
when single clicked, select all cells in this column.
but when user double clicked, the action attached with single click also triggered.(column sorted but also selected)
how to separate them.

Ok, so despite my earlier suggestion being basically the only solution offered anyway on the web it appears that Lokust is correct and that the single click operation would be performed as well as the double click one. to get round this u have to implement a Timer, i'm not going to post my whole code here because most of it is irrelevent, just add this code in the correct places and it should work fine. apologies to all format junkies for not using code tags!
import java.util.Timer;
import java.util.TimeTask;
public class WhateverClassName implements MouseListener {
private Timer t;
private boolean doubleclick;
myTable.addMouseListener(this);
public void mouseClicked(MouseEvent e) {
     t = new Timer();
     if (e.getClickCount() == 2){
          doubleclick = true;
     else if(e.getClickCount()==1){
          t.schedule(new MyTimerTask(),500);
/*You need all these methods as well */
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
public void mouseEntered(MouseEvent arg0) {
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
public void mouseExited(MouseEvent arg0) {
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
public void mousePressed(MouseEvent arg0) {
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
public void mouseReleased(MouseEvent arg0) {
class MyTimerTask extends TimerTask{
/* (non-Javadoc)
* @see java.util.TimerTask#run()
     public void run() {
          if(doubleclick){
               System.out.print("double click");
          else{
               System.out.println("single click");
          t.cancel();
This assumes that for it to be considered a double click user has to click twice within .5 seconds.
Let me know if that works or not, sorry its a bit messy!

Similar Messages

  • After update I am no longer able to open email attachments by just clicking on the attachment. I now have to click control and then click open linked file. How can I open attachments by simply clicking on them?

    After update I am no longer able to open email attachments by just clicking on the attachment. I now have to click control and then click open linked file. How can I open attachments by simply clicking on them?

    Unless you believe middle-click is yours and don't like it being usurped, mine is set globally to "Enter".

  • At the top of my homepage, I'm getting a message "Downloading the latest applications", but the circle to the left keeps spinning, and no applications are downloaded. I don't know how to stop this, tried right and left clicking on the bar. This occurs

    At the top of my homepage, I'm getting a message "Downloading the latest applications", but the circle to the left keeps spinning, and no applications are downloaded. I don't know how to stop this, tried right and left clicking on the bar. This occurs every time I open Firefox. How can I stop or disable this?
    == This happened ==
    Every time Firefox opened
    == Several weeks ago.

    See http://kb.mozillazine.org/Software_Update (Software Update not working properly)
    Remove the files in the ''updates'' and ''updates\0'' folder:
    Vista/Windows7:
    C:\Users\<user>\AppData\Local\Mozilla\Firefox\Mozilla Firefox\ (updates)
    C:\Users\<user>\AppData\Local\VirtualStore\Program Files\Mozilla Firefox\ (updates)
    %LOCALAPPDATA%\Mozilla\Firefox\Mozilla Firefox\updates\

  • I am having problems with my Magic Trackpad.  All I can do is move the cursor and single click.  I using the most current version of Lion.

    I am having problems with my Magic Trackpad.  All I can do is move the cursor and single click.  I using the most current version of Lion.

    In System Preferences > Trackpad > your preferences should look like this screenshot.  If they don't then some 3rd party driver is conflicting.  The most common conflict is USBoverdrive. 

  • Very Urgent (How can i add fade in and fade out Action)

    Hi, How can i add fade in and fade out action on the JButton when the mouse is over the button.its mean that when the mouse is over the button then the button's Label is fade in and out.
    plz give code example
    thanks

    If you want to fade in and out anything, you should look at the Composite interface. A Composite is part of a Graphics2D object. You should be able to gradually change this on the button, but maybe within a different thread?

  • Double click instead of single click

    recently like a month ago i started noticing when i ried to open a new tab in firefox or close,i opened two new tabs or close two tabs then i found out it wasn't firefox is that when i single click on something  i guess ny computer recognizes that as a double click and that's what it does,it double clicks on the icon,video or whatever i click on,can anyone tell me how to revert this to its default configuration,by the way i didn't mess with it or tried to change it or what ever,most of the times it double clicks on anything but not all the time

    @karantani: exactly as cfr said: it happens after some time and without any warning. If you're not sure just try another mouse. 5years is hell of a lot for a mouse if you use it on everyday basis for many hours. I even had this on new Logitech mouse just after couple of months (they're all doing just shit nowadays, I miss days of old heavy, robust keyboards and mouses, of electronics like Walkman - it was some nice engineering, everything was working just fine for many, many years. Right now your lucky if product will hold it's planned obsolescence). There is a lot you can do, I fix mine by sticking piece of paper to lift badly designed buttons, but in many cases switches just have enough.

  • [Solved] Gwenview 5 lost icons and single click

    Hi,
    I don't use KDE but I do use Gwenview. Since upgrading to 5 Gwenview has lost some icons (outlined in red below), and I now have to double click on directories and images to open them instead of single click. Is it possible to fix these issues without installing a full KDE desktop?
    Thanks, Jamie
    Last edited by JamieKitson (2015-02-10 22:30:10)

    I get a much larger list in "kcmshell5 icons".  I think because I installed "plasma-meta", and removed "kdebase-workspace".
    kcmshell5 --list
    The following modules are available:
    kf5.kservice.sycoca: Trying to open ksycoca from "/home/johnm/.cache/ksycoca5"
    autostart - Automatically Started Applications
    bell - System Bell
    bluedeviladapters - Configure Bluetooth adapters
    bluedevildevices - Manage Bluetooth devices
    bluedeviltransfer - Configure Bluetooth file sharing and transfers
    cache - Configure web cache settings
    clock - Date and Time
    colors - Application Color Scheme
    componentchooser - Default Applications
    cookies - Configure the way cookies work
    cursortheme - Mouse Cursor Theme
    desktop - Navigation, Number and Layout of Virtual Desktops
    desktoppath - Paths to Personal Files
    desktoptheme - Desktop Theme
    devinfo - Device Viewer
    dma - DMA information
    emoticons - Emoticon Theme
    filetypes - Configure file associations
    fontinst - Font Installation, Preview and Removal
    fonts - Fonts
    formats - Numeric, Currency and Time Formats
    icons - Icon Theme
    interrupts - Interrupt information
    ioports - IO-port information
    joystick - Joystick
    kcm_activities - Configure the activities system
    kcm_baloofile - Configure File Search
    kcm_infosummary - Hardware Information Summary
    kcm_keyboard - Keyboard Hardware and Layout
    kcm_kscreen - Manage and configure monitors and displays
    kcm_lookandfeel - Look And Feel
    kcm_memory - Memory information
    kcm_pci - PCI information
    kcm_phonon - Phonon Audio and Video
    kcm_plasmasearch - Configure Search
    kcm_splashscreen - Splash Screen Theme
    kcm_ssl - SSL Versions and Certificates
    kcm_useraccount - User information such as password, name and email
    kcmaccess - Accessibility Options
    kcmkded - Background Services
    kcmkwineffects - Desktop Effects
    kcmlaunch - Application Launch Feedback
    kcmnotify - Event Notifications and Actions
    kcmsmserver - Desktop Session Login and Logout
    kcmtrash - Configure trash settings
    kcmusb - USB devices attached to this computer
    kcmview1394 - Attached IEEE 1394 devices
    keys - Global Keyboard Shortcuts
    khotkeys - Configure Input Actions settings
    kwincompositing - Compositor Settings for Desktop Effects
    kwindecoration - Look and Feel of Window Titles
    kwinoptions - Window Actions and Behavior
    kwinrules - Individual Window Behavior
    kwinscreenedges - Active Screen Corners and Edges
    kwinscripts - Manage KWin scripts
    kwintabbox - Navigation Through Windows
    mouse - Mouse Controls
    netpref - Configure generic network preferences, like timeout values
    nic - Network interface information
    opengl - OpenGL information
    powerdevilglobalconfig - Advanced Power Management Settings
    powerdevilprofilesconfig - Energy Saving
    proxy - Configure the proxy servers used
    screenlocker - Screen Locking Timeouts
    scsi - SCSI information
    smb - Use to configure which windows (SMB) filesystems you can browse
    smbstatus - Samba status monitor
    solid-actions - Manage actions available to the user when connecting new devices
    spellchecking - Spell Checker Dictionaries and Options
    standard_actions - Standard Keyboard Shortcuts for Applications
    style - Widget Style and Behavior
    translations - No description available
    useragent - Configure the way Konqueror reports itself
    wayland - Information about the Wayland Compositor
    webshortcuts - Configure web shortcuts
    workspaceoptions - Workspace Behavior
    xserver - X-Server information
    Since you still probably have kdebase-workspace, maybe you can fix it with "kcmshell4 icons" instead.

  • JComboBox in JTable to activate when double-click instead of single-click

    I like to know if it is possible to change the default behaviour of JComboBox within the JTable,
    such that instead of single click on the JTable cell for the combo box's popup to appear, I double click on it instead.
    If it is possible please give some advice.
    Thanks.

    I couldn't get to settings because I couldn't scroll and don't know where that is located. I just saw a similar question from someone else. Three clicks on home button worked to turn off voiceover !! Phew!

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • PcmanFM and single-click delay

    Howdy-ha, folks.  Does anyone know of a way to change the delay of (or do away with) automatic item selection on mouse hover in PcmanFM while using single-click mode?  I love this filemanager, and love using single-click, but it's irritating to have an entire selection range deselected because I can't hit a hotkey combo quickly enough.  Judging by the config file in ~/.config/pcmanfm, I'd guess not?  Or is there perhaps a third-party solution/work-around?

    I suppose Thunar could be considered a work-around, although I prefer PcmanFm.   Maybe I'll screw around with the source for it later today...  I know about as much about C as I do about the history of 19th-Century Appalachian quilting (I just arbitrarily assume it's written in C, which tells you what my qualifications for coding are), but I have an idea of where to start looking anyway.

  • Double click and single click Event

    Hi
      I want to add a Single Clcik event and Double click event  both on the same movie clip in as3 , its working but call both the event same time so how to fix it , please help us if u have any solution ..(

    did you double click enable your object AND add a doubleclick listener?  if so, what's the problem?

  • Originally when I cliked on a new email in the inbox, it opened immediately. Now I have to double click on it to open. How do I get back to the single click?

    It now takes a double click to open an email. How do you get it to open on the first click?

    There is no need to open two threads for the same question.
    https://support.mozilla.org/en-US/questions/998701

  • Automatic Troubleshooting Info Adder doesn't work. A window will open in the top corner. Click Allow, and then click Install. If the automated way

    When trying to use this miserable help system and use the Automatically add button, I get asked to install an addon, which I allow, and click Install, but it never seems to work.
    I know how to do it manually so don't bother telling me how to do it manually. I want it to work properly, automatically, like it is suppposed to.

    I see that you added this information manually via the clipboard.
    You appear to have installed quite an impressive amount of extensions, both enabled and disable extensions, and that could be a possible cause or there are otherwise problems with gathering this information.
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    What kind of problem do you have that you want to send us this information as it could be related to this issue?
    Is Firefox crashing?
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter
    *https://support.mozilla.org/kb/Mozilla+Crash+Reporter

  • BUG - Artboard resizes on own when clicking height and then clicking width field

    Bug with artboard -
    I click on a square to create an artboard. Without changing anything if I click in the width field and then the height without changing anything, the art board resizes as shown in the second image in pic 1 (art board values change as shown in pic 2). If instead I click first in the height field and then width, they change as shown in the third pic (settings as in pic 3)
    Pic 1
    Pic 2
    Pic 3

    what version?

  • Magic Mouse ribght-clicking even when single-click mobe is enabled

    I have a late 2007 MBP. I bought a Magic Mouse today, but when I paired it and downloaded the software for it, when "Secondary click" was not enabled, it would behave as if it was right-clicking. When I enable "Secondary Click", both left and right parts of the mouse right-click. What's going on here?

    Welcome to Apple Discussions.
    If it's under warranty you can either bring it to an AASP or call AppleCare at 800-275-2273. You don't need to bring it into a store if you don't have one in your area.
    Regards,
    Roger

Maybe you are looking for

  • Complain

    To, Nokia Company Subject: - Complain of Phone model nokia asha 311 Hi, I am Avinash sawant customer of nokia phone model nokia asha 311.I have purchase handset on 30th march 2013 since i am having problem of network drop, call drop, phone restart, p

  • HT1414 i accidentally deleted the phone app, how do I get it back

    This happened after a number of issues with ios7.  If anyone knows how to fix it, I would be so greatly appreciative.  Also, if anyone knows the answers to the following questions I would be thankful forever: Why spotlight is only available from the

  • Displaying report params in Header text

    I have built a number of reports that link to each other in a drill down/master-detail style. These work great. I want the child report to display the name of the parent object in the header text as a title, i.e, In the parent 'vehicles' report I cli

  • Can't find the constructor

    i have the following code   static java.lang.Comparable [] d;   //a constructor to fill up the d array   sortingClass(java.lang.Comparable data[]) {     d = data;   int findLargest() {     java.lang.Comparable largestSoFar = d[0];     int where = 0;

  • New JAVA Update = Broken; HELP PLEASE

    Yesterday I was alerted to a new update for Java. I installed it and now JAVA doesn't work on this site I always use for work. Is this happening to anyone else? Any ideas on how to fix? Help please. Thanks.