How to differentiate between Single click and double click event in List

I am facing a problem while using list in awt.
I want to execute some code on single click and other on double click but when double click event occurs it also executes the single click code.
because i have added both actionlistener and itemlistener on the list.
How to sort out this problem.
please help me out.
Thanks buddies.

Hello Meeraj_Kanaparthi
Thanks for helping i m giving u the code i have tried.
Plz help me on this...
Thanks........
import java.awt.*;
import java.awt.event.*;
class CheckList extends Frame implements MouseListener
     List l1;
     int x;
     int y;
     CheckList()
     setSize(500,500);
     setLayout(new FlowLayout());
     l1=new List(10);
     add(l1);
     l1.add("Item 1");l1.add("Item 2");l1.add("Item 3");l1.add("Item 4");l1.add("Item 5");
     x=6;
     y=0;
     l1.addMouseListener(this);
//     l1.addItemListener(this);
     show();
     public void execute(int y)
     if(y==1)
     {System.out.println("3");
          l1.remove(l1.getSelectedIndex());
     if(y==2)
     {System.out.println("4");
          l1.add("item " + x);
          x++;
     public void mousePressed(MouseEvent e)
          System.out.println("Pressed");
     public void mouseReleased(MouseEvent e)
          System.out.println("Released");
     public void mouseEntered(MouseEvent e) {}
     public void mouseExited(MouseEvent e) {}
     public void mouseClicked(MouseEvent e)
     if (e.getClickCount()==1)
          System.out.println("1");
          y=1;
     if (e.getClickCount() == 2)
     {System.out.println("2");
          y=2;
          execute(y);
     public void actionPerformed(ActionEvent ae)
     public void itemStateChanged(ItemEvent it)
     public static void main(String ag[])
     new CheckList();
}

Similar Messages

  • Does any one knows how to differentiate between outgoing mail and incoming

    Hi,
    I'm using the IV webclient inbox.
    Does any one knows how to differentiate between outgoing mail and incoming mail in the result list ?

    Hi,
    I'm using the IV webclient inbox.
    Does any one knows how to differentiate between outgoing mail and incoming mail in the result list ?

  • How to handle both single click and double click from mouse

    hey,
    I looked in past threads and didn't get a proper answer for capturing both single and double click from the mouse.
    in most applications the single click action does not interfere with the double click action, for example in a text editor, single click sets the cursor in between the text, double click marks a word, triple click marks a sentence, they do not bother each other, they all can happen first the single then the double and then the triple, but what if i have a very distinct action for each of the actions, the e.getClickCount() returns every time the number of clicks and if i use
    if(e.getClickCount()==1)
        doSingleClick();
    if(e.getClickCount()==2)
        doDoubleClick();it will always do first the single click and then the double click, which works fine with the example i gave, but not with what i want to do, so i was thinking to over come this that i will use another thread to run my tasks if dt has past since the last click and by the last click counts to perform the correct action and go to sleep until the next mouse click notify it, what do you think?
    run this to get what i mean...
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MouseClickTest {
         static long previousTime = System.currentTimeMillis();
         public static void main(String[] args) {
              JPanel panel = new JPanel();
              JButton component = new JButton("Hit me, please");
              component.addMouseListener(new MouseAdapter(){
                   public void mouseClicked(MouseEvent me){
                        if(me.getClickCount()==1)
                             System.out.println("Now I will do single click action");
                        if(me.getClickCount()==2)
                             System.out.println("Now I will do DOUBLE click action");
    //                    System.out.println("Click count: " + me.getClickCount());
              panel.add(component);
              Launcher.launch(panel);
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Launcher {
         public static JFrame launch (Container contents, String title, Color backgroundColor) {
              JFrame frame = new JFrame (title);
              if (backgroundColor != null) {
                   frame.setBackground (backgroundColor);
                   contents.setBackground (backgroundColor);
              } else {
                   frame.setBackground (contents.getBackground());
              frame.getContentPane().add (contents, BorderLayout.CENTER);
              frame.pack();
              frame.addWindowListener (new WindowAdapter() {
                   public void windowClosing (WindowEvent e) {
                        System.exit (0);
              frame.setVisible (true);
              return frame;
         public static JFrame launch (Container contents, String title)      {
              return launch (contents, title, null);
         public static JFrame launch (Container contents, Color backgroundColor) {
              return launch (contents, contents.getClass().getName(), backgroundColor);
         public static JFrame launch (Container contents) {
              return launch (contents, contents.getClass().getName());
    }

    Read my comments and solution in this posting; [http://forums.sun.com/thread.jspa?forumID=57&threadID=705244]
    and then choose a better design for your application.

  • How can i perform the right click and double click operation in ipad.

    I have an email application i.e web application working fine in desktops, in that application if i will double click on the mail that mail will be open, and after opening that mail if i will right click on the mail it will show the different functionality .
    But i cant do that in ipad, is there solution to this problem ????

    mm.thejeshwini wrote:
    That application is a web-based application and the desktop version of the application has the functionality to open or pop-up a new window when double clicked on a particular text and now i want the same functionality to be performed on ipad. And some functionality to be worked for right-clicked also.
    I understand what you have and what you want. However, the iPad is not a desktop computer. What you want may not be possible. The developer may have already created an app specifically for the iPad. Have you checked the App Store?

  • How to differentiate between printed form and form sent by Mail

    Hello All,
    We have a requirement where we need to print a different text in the smartform based on whether the PO is being printed or being sent by mail. There is a radio button in PO Output screen which lets you select whether to print the PO or send it by mail. Would anyone know which table holds this data?
    Thanks for your time.
    Regards,
    Johnson

    Hi
    Which SRM version are you using ?
    <u>You can change smartform in transaction SMARTFORMS. Choose From BBP_PO and click on edit button. Go to Global Settings\Global definitions and go to Initialization tab.</u>
    <u><b>You will find the relevant field in SF_PO structure</b>
    Based on the PO GUID, read the PO relevant data using the function module BBP_PD_PO_GETDETAIL. Hope here you can identify the table / field names as well.
    </u>
    <u>Also, you can add
    IF... ENDIF statements and add a flag variable
    based on the current status of document. And use this flag to differntiate between the two statuses.</u>
    <i><u>Related link -></u></i>
    Re: SRM PO Print
    <u>SRM PO Print</u>
    Re: How to change default smartform triggered while printing for shopping cart
    PO output (classic scenario)
    Revised PO
    Re: SRM PO SMARTFORM
    delete printed PO
    <u>Trigerring Smartform</u>
    Trigering Smartform
    Re: SRM PO Form
    Do let me know.
    Regards
    - Atul

  • Differentiate between oa page and iStore page(jsp)

    Hi,
    How to Differentiate between OA page and iStore pages?

    If the URL contains the JSP tag as OA.jsp or RF.jsp, then its an OAF application else if you see some custom jsp, eg, jftchrome.jsp etc, then the application is JTT/JTF based application:
    eg:
    OAF application:
    http://sampledomain.oracle.com:5000/OA_HTML/*OA.jsp*?.......
    http://sampledomain.oracle.com:5000/OA_HTML/*OA.jsp*?.......
    JTT Application
    http://sampledomain.oracle.com:5000/OA_HTML/*jtfchorme.jsp*?.......

  • Differentiate between Simple, Medium and Complex Queries.

    Hi Gurus,
    I am a Tech. Architect on this new project. I would like to know how to differentiate between Simple, Medium and Complex Queries in BW because I need this info to work on the Estimates. Has this differentiation got anything to do with the Backend config also?
    Thanks in Advance.
    Chandu.

    Hi
    You need to understand the requirements and consider the following before you classify........
    1) Queries that are based on multiple key figures--which may result in cell definition.
    2) Queries with complex calculations.
    3) Queries that are based on Variable Exits
    Regards
    Srinivas Bandi

  • Mouse click - double click and right click

    How can i add a listeners to the mouse right click and double click?

    Double click is pretty easy. Just check the number of clicks you recieved as a result of the mouseClicked event of a MouseListener. Like so:
    public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
    //double click
    }

  • Programming button for single and double click

    I know how to programme a button to play a certain movie segment. However, in my current project I need to be able to programme a button in the menu so that
    1. on rollover - nothing
    2. on single mouse click - button colour changes + a parapraph of text appears on the menu screen in a predefined space
    3. on double click - a movie clip plays
    It might be a simple qiestion but I would greatly appreciate it if you could point me in the right direction.
    Thanks.

    Nick76 wrote:
    I know how to programme a button to play a certain movie segment. However, in my current project I need to be able to programme a button in the menu so that
    1. on rollover - nothing
    Do not change the highligh and it will look like nothing is happening (make sure auto activate is not beign used)
    2. on single mouse click - button colour changes + a parapraph of text appears on the menu screen in a predefined space
    3. on double click - a movie clip plays
    It might be a simple qiestion but I would greatly appreciate it if you could point me in the right direction.
    Thanks.
    Single and Double clicks cannot be done like that. (Some players using layered menus do require a click to get things seen but not really what you are speaking about.)
    Flash or Director may be better for this?

  • Doubt - mouse double click invokes both single and double click

    Hi Friends,
    I added mouse listener to a java component. In the mouseClicked() method, I have implementation for both mouse single and double click. When I try to double click that component it invokes the single click method first and the it invokes the double click method. My problem is when I try to double click that component it should invoke my double click method alone not single click too.
    I'd be very grateful if someone can help me.
    Thanks and Regards,
    Sangeetha J

    Your problem: a double click is two single clicks. The first click will always fire a single-click event. How's the computer supposed to know that another click is to follow?
    All I think you could do is to instantiate a timer in the one-click method, set to whatever amount of time you think a double-click should take. If you get a second event while the timer's still active, it was a double-click and you can stop the timer and do the double-click action. Otherwise your timer should execute the single-click action after it timed out.
    But this will make your GUI look like it's responding slowly to single-clicks.

  • How to differentiate between Parent and Child in IBASE?

    Hi. I am working on enhancing a BAPI :BAPI_GOODSMVT_CREATE by calling the following function module IBPP_CREATE_IBASE at its exit.
    The BAPI is being called from an SAP ME system and will be passing MATNR and Serial Number of Parent and Child materials to create the IBASE in ECC system. I am confused as to how to differentiate between whether a object is Parent or a Child when the BAPI: BAPI_GOODSMVT_CREATE is called.

    if you have NULL valued fields. If
    you do a compare and one or both are NULL, then the result is always NULL,
    never true or false. Even comparing two fields which are both NULL will
    give NULL as result, not true! Or if you have something like "select
    sum(field) from ..." and one or more are NULL, then the result will be
    NULL. Use always "if field is NULL ..." for NULL checking and for safety
    maybe something like "select sum( IsNull(field,0) ) from ...". Check the
    function ISNULL() in the manual.

  • How do I set Firefox to automatically open downloads instead of having to go to my downloads and double click to open?

    Whenever I have used Firefox on a PC it at least gave me the option to open certain file types automatically. I download a lot of files and the time adds up when I have to open the downloads box and double click on the file each time.

    Hi,
    This could help you: [https://support.mozilla.org/en-US/kb/Managing%20file%20types#w_changing-download-actions Changing download actions]

  • How to do data migration between single node and multi node HANA systems ?

    Data migration between single node and multi node HANA systems ?
    What are limitations ?
    What should be the best practices ?

    Data migration between single node and multi node HANA systems ?
    What are limitations ?
    What should be the best practices ?

  • Remediation for single-clicking a double-click action

    I'm using the double mouse click feature of a Click box in a
    software simulation lesson we've built in captivate. Unfortunately
    when the user single-clicks in the Click box, no remediation shows
    to tell the user that they must double-click in the box to complete
    the step.
    Anyone have any ideas on how to provide the user with
    remediation on single clicking a double click Click box?
    Thanks,
    Scott Witlen
    McKessson Provider Technologies

    Um... there are no macros. Captivate is a closed system with
    no documented API outside of some variables you can read and in
    some cases, set to make Captivate do some simple navigation-related
    things. Search the Captivate help file for 'variables' and you'll
    find a list.
    Outside of that, the only official ways to "enhance"
    Captivate are either to:
    - Create your own standalone functionality in Flash and
    insert it in Captivate as a self-contained animation. This can be
    problematic due to the closed nature of the Captivate runtime, as
    well as the layering imposed by the use of skins and borders.
    - Make Javascript calls to the browser and put the
    functionality there. Since there is limited interactivity between
    Javascript and Flash, this is much more limited in scope than
    inserting your own self-contained animations
    Some folks have also opened up a published SWF with a
    decompiler program and viewed the Adobe source code in an effort to
    make their inserted animations do cooler things, but that is very
    much an unsupported activity.

  • Leopard Registering Single Clicks as Double Clicks

    I have a terrible problem under 10.5.1 with the system registering about 40% of my single clicks as double clicks. It seems to be getting worse, as well. I thought it was an issue with the mouse on my Wacom tablet or with the Wacom driver, but in trying to troubleshoot it I found I had the same problem when using my original Apple mouse.
    It's extremely problematic. For example, I've customized my Finder toolbar to include the delete icon. However, if I click the delete icon and the system registers it as a double click, it will delete not only the file I intended, but it's parent directory. Is anyone else experiencing this?

    I have the same problem. I have concluded that it is a software problem either with OS X or some third party software on the computer.
    I originally thought it was a problem with Logitech's control center as that was the mouse I was having problems with. However, I recently replaced that mouse and uninstalled the logitech software and am still having problems with my new mouse from a different vendor. All the while, the trackpad will still register single clicks as double clicks.
    In my observations I found that once I restart the computer, single clicks will be registered as normal for the first few minutes of computer use. After that, any time the mouse is clicked more than once without being moved, no matter how much time has passed, it will register the subsequent clicks as double/triple/etc. clicks. So if, for example, I were to click an application icon once, not move the mouse, come back a day later and click again, it will double click. I also found that if the mouse is moved ever so slightly, it might still register as a double click.
    Additionally, if I am scrolling through any window but don't move the mouse, it will register the subsequent clicks as double clicks, even when you are clicking on a different item. An example of this is if I am scrolling down a finder window with a lot of files in column view, click on a file to see it's icon preview, then scroll down without moving the mouse and click on another file, it will register as a double click and launch that item.
    Other observations: I was having this problem in the early days of my OS install, so I went ahead and reinstalled the system. The problem came back in a day or so and I can't pinpoint it to any one piece of software that has been installed. I'm wondering if it is an OS issue.

Maybe you are looking for