MouseClicked method was called two times

Hi all!
I 've written a program containing a GUI component, and I added a MouseAdapter for it and overided the mouseClicked() method.
But as I run the program and click the mouse on that component, the mouseClicked() was called two time ( I just made an single click)
Anyone can tell me why?
Thanks!

Is it true that if we add the same MouseListener
twice, we will receive two times call to mouseXXXX()
method?I assume there would be some kind of check like this:
if (!listenerList.contains(candidateListener)) listenerList.add(candidateListener);to ensure that it isn't added twice, because there should never really be a situation where it would be legitimate or useful to have the same instance added as a listener more than once.

Similar Messages

  • ListSelectionListener is always called two times...

    Hello,
    Icreated a JTable and added a ListSelectionListener to this table. I want an action being performed each time the selection within the table changes. If I change the selection via mouse this works quite fine, but if I do so with the mouse the method in the Listener is alwas called two times...why ?
    Here's a little bit of source-code, perhaps you'll get what I mean:
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
         if (lsm.isSelectionEmpty()) {}
         else { // always called 2 times...
              int selectedRow = lsm.getMinSelectionIndex();
         System.out.println("Test");
         Kunde temp = (Kunde)ShowKunde.kunden.elementAt(selectedRow);
         System.out.println(temp.getName());
              try {
                   kontoTemp = new KontoTemp(temp);
                   kontoTemp.setBuchungenTemp();
                   tableTemp.setModel(kontoTemp);
                   kontoBestand = new KontoBestand(temp);
                   kontoBestand.setBuchungenBestand();
                   tableBestand.setModel(kontoBestand);
                   frame.repaint();
              } // try
              catch (Exception ex) {
                   System.err.println(ex.getMessage());
              } // catch
              }});

    Hi
    you could check is the value is adjusting:
    if (e.getValueIsAdjusting()) {
        return;
    // your code hereviel erfolg
    Phil

  • [NSNotificationCenter defaultCenter] selector method get called 2 times

    i am sending NSSNotifcation to root view controller in iPhone app but its observer method getting notified two times how its possible can any one guide me
    i have use this code to post notification in my detail view controllers which are going to get added in popover view
    -(void) viewDidAppear:(BOOL)animated
        [super viewDidAppear:YES];
        [[NSNotificationCenter defaultCenter] postNotificationName:SetPopOverSizeNotification object: [NSNumber numberWithFloat:480]];
    and added observer in my root view controller
    - (void)viewDidLoad
        [super viewDidLoad];         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPopoverSize:) name:SetPopOverSizeNotification object:nil];
    the method implementation is as follows
    #pragma mark - Popover Notification Method
    - (void)setPopoverSize:(NSNotification *)notification
         NSNumber *height = (NSNumber *)notification.object;
          [myPopover setPopoverContentSize:CGSizeMake(320, [height floatValue]) animated:NO];
    Also removing observer as follows
    - (void)viewDidUnload {
        [super viewDidUnload];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:SetPopOverSizeNotification object:nil];

    Hi Saravanan,
    I am  calling this component directly from my application. This component is not used anywhere. The component name is : ERC_C_REQ_MGMT_UI and the application name is: erc_a_req_mgmt
    I am calling an application configuration ERC_A_REQ_MGMT to execute it.
    Regards
    Vishal Kapoor

  • CommandLink in dataTable rendered method is called multiple times

    I have a dataTable in which one of the columns contains a commandLink. The commandLink has the "rendered" option bound to a backing bean method. When the page is submitted, the backing bean method gets called 8 times for each row in the table if the value returned is "true" and 3 times per row if the value returned is "false". Since the page is designed to "navigate" back to itself, I can understand it getting called more than once, but 8 times??? What's up with that?

    Because you have a bug in your code.
    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • Why windowClosing is called two times?

    Hi,
    I'm saving my project in JFrame windowClosing event. But it is called two times...
    How to prevent it?
    this.addWindowListener(new java.awt.event.WindowAdapter() {
         public void windowClosing(java.awt.event.WindowEvent e) {
         saveCurrentProject();
    Thanks,
    Andr�

    Thanks, problem solved.
    this.addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent e) {
    saveCurrentProject();
    System.exit(0); // <-- new line
    Andre

  • Object synchronization method was called from an unsynchronized block of co

    I have installed DotNETWebControlConsumer_3.0_sp1
    in my machine I am very much new to Plumtree
    I am building the application in vs 2005 or .Net 2.0 environment and plumtree 6.0
    here is my web.config file code
    <httpModules>
    <add type="Com.Plumtree.Remote.Loader.TransformerProxy, Plumtree.WCLoader, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d0e882dd51ca12c5" name="PTWCFilterHttpModule"/>
    </httpModules>
    and I get the error Object synchronization method was called from an unsynchronized block of code
    I just removed the html format for posting purpose i mean all the less than and greater than sign
    please I need it so badly

    Regarding your first issue (because it looks as if you removed the <httpModules> node from your web.config to move on from that issue), I changed 'Aqualogic.WCLoader' to 'Plumtree.WCLoader' in <httpModules ../>, added a reference to Plumtree.WCLoader in my project , then added another <add assembly="Plumtree.WCLoaderyadayada...> accordingly to the <assemblies> node in the web.config and then it worked. Well, almost, now I'm seeing a new error:
    [NullReferenceException: Object reference not set to an instance of an object.]
    Com.Plumtree.Remote.Transformer.PTTransformer.HandleRequest(HttpContext ctx) in e:\buildroot\Release\wcfilter\3.0.x\filter\src\Com\Plumtree\Remote\Transformer\PTTransformer.cs:60
    Com.Plumtree.Remote.Transformer.PTTransformer.BeginRequestHandler(Object sender, EventArgs e) in e:\buildroot\Release\wcfilter\3.0.x\filter\src\Com\Plumtree\Remote\Transformer\PTTransformer.cs:54
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    Mine is a .net 2.0 portlet that will work if I don't try to use the WCC 3.0SP1 (by pulling the <httpModules> node. But then I'm guaranteed no inline refresh. I have no fix yet, but when I do, I'll post it. I've contacted Plumtree Support in the meantime because others must be having the same problem.
    p.s. Also using edk 5.3 signed, though I'm going to upgrade to 5.4 and see if that does anything.

  • I was charged two times for the same game

    I was charged two times for the same game...how can I get my money back?  I even was emailed a receipt for them both...no one noticed?  Please help me.

    How to report an issue with Your iTunes Store purchase

  • Finalize() method being called multiple times for same object?

    I got a dilly of a pickle here.
    Looks like according to the Tomcat output log file that the finalize method of class User is being called MANY more times than is being constructed.
    Here is the User class:
    package com.db.multi;
    import java.io.*;
    import com.db.ui.*;
    import java.util.*;
    * @author DBriscoe
    public class User implements Serializable {
        private String userName = null;
        private int score = 0;
        private SocketImage img = null;
        private boolean gflag = false;
        private Calendar timeStamp = Calendar.getInstance();
        private static int counter = 0;
        /** Creates a new instance of User */
        public User() { counter++;     
        public User(String userName) {
            this.userName = userName;
            counter++;
        public void setGflag(boolean gflag) {
            this.gflag = gflag;
        public boolean getGflag() {
            return gflag;
        public void setScore(int score) {
            this.score = score;
        public int getScore() {
            return score;
        public void setUserName(String userName) {
            this.userName = userName;
        public String getUserName() {
            return userName;
        public void setImage(SocketImage img) {
            this.img = img;
        public SocketImage getImage() {
            return img;
        public void setTimeStamp(Calendar c) {
            this.timeStamp = c;
        public Calendar getTimeStamp() {
            return this.timeStamp;
        public boolean equals(Object obj) {
            try {
                if (obj instanceof User) {
                    User comp = (User)obj;
                    return comp.getUserName().equals(userName);
                } else {
                    return false;
            } catch (NullPointerException npe) {
                return false;
        public void finalize() {
            if (userName != null && !userName.startsWith("OUTOFDATE"))
                System.out.println("User " + userName + " destroyed. " + counter);
        }As you can see...
    Every time a User object is created, a static counter variable is incremented and then when an object is destroyed it appends the current value of that static member to the Tomcat log file (via System.out.println being executed on server side).
    Below is the log file from an example run in my webapp.
    Dustin
    User Queue Empty, Adding User: com.db.multi.User@1a5af9f
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    Joe
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin pulled from Queue, Game created: Joe
    User Already Placed: Dustin with Joe
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    INSIDE METHOD: false
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    User Dustin destroyed. 9
    User Joe destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    INSIDE METHOD: true
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    INSIDE METHOD: true
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    It really does seem to me like finalize is being called multiple times for the same object.
    That number should incremement for every instantiated User, and finalize can only be called once for each User object.
    I thought this was impossible?
    Any help is appreciated!

    Thanks...
    I am already thinking of ideas to limit the number of threads.
    Unfortunately there are two threads of execution in the servlet handler, one handles requests and the other parses the collection of User objects to check for out of date timestamps, and then eliminates them if they are out of date.
    The collection parsing thread is currently a javax.swing.Timer thread (Bad design I know...) so I believe that I can routinely check for timestamps in another way and fix that problem.
    Just found out too that Tomcat was throwing me a ConcurrentModificationException as well, which may help explain the slew of mysterious behavior from my servlet!
    The Timer thread has to go. I got to think of a better way to routinely weed out User objects from the collection.
    Or perhaps, maybe I can attempt to make it thread safe???
    Eg. make my User collection volatile?
    Any opinions on the best approach are well appreciated.

  • EjbActivate() and ejbPassivate() methods are called million times!!! :(

    Hello All,
    Am I missing some thing here?
    We have a project with many Entity Beans, and all of them have relations with one another. The simple example I can give is Entity A has one to many relation with Entity B.
    i.e There could be one Entity A and for this there could be many Entities B these two entities are managed by CMR fields.
    Entity A has a PK, this would act as a FK in Entity B.
    In the EJB Post create method of Entity B I am trying to find a suitable entity A and trying to execute setEntityA(suitableEntityA), while this method is getting executed here is the things that happen
    the container tries to find all Entity B (if there are 10,000 records in B table then ejbActivate() of B is executed 10,000 times) then it sets the relation with Entity A, then at the end of the Transaction the container will call ejbPassivate() method on Entity B 10,000 times!!! oh god what is happening here...!!!?????
    can some one tell me if I am missing some settings?
    The same thing happends for all the other EJBs which have one to many CMR fields, i.e ejbActivate() and ejbPassivate() of each of these Entity Beans will be called for those many number of times for as many records found in the Datbase of the corresponding Entity.
    I have the follwing setting in my orion-ejb-jar.xml file
    <entity-deployment name="EntityA"
    max-tx-retries="0"
    max-instances="-1"
    location="EntityA"
    table="A"
    data-source="jdbc/oracleDS"
    exclusive-write-access="false"
    locking-mode="optimistic"
    update-changed-fields-only="true"
    delay-updates-until-commit="true">
    similar xml construct for Entity B also!!!
    If some one knows more about this please let me know.
    Thank you
    -Mallik

    Found one more thing for this CMP-CMR relationship and ejbActivate() and ejbPassivate() process of CMP Entity's.
    In this above example if say
    Entity A (Dept) ------ Entity B (Employee) (1:M) has one to many relationship
    Employee holds a FK value which is PK in Dept (dept_id).
    Suppose asssume that there are 10,000 employees working for a dept_id = 5.
    (i.e there are 10,000 records in Employee that references Dept table with dept_id =5)
    Now I want to add one more employee to this dept_id = 5, then I create an Employee entity and in the ejbPostCreate() method of Employee entity I lookup Dept Entity with Dept_PK=5, until this every thing is fine. Now I call setter method with in Employee Entity to set the dept such as setDept_dept_id(detpEntity5), at the execution of this method EJB container calls starts calling Employee Entity's the ejbActivate() method for 10,000 times this equals the number of references Employee table has to Dept table with Dept_ID=5, then at the end of the transaction the container calls ejbPassivate() method 10,000 times to passivate all those ejbs that it activated.
    Did some one experience the same thing with CMP EJBs? please let me know what I have to do to avoid such things?
    Thank you
    Mallik

  • DoGet method is called 2 times when a switch-case statement is used

    Hello all,
    I have a servlet that, when run from browser, runs the doGet method 2 times.
    I have a switch case statement within the servlet and when I comment out this servlet, it runs 1 time as expected.
    Here is the code:
    public class RSSServlet extends HttpServlet {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            System.out.println("CALLED SERVLET");
            response.setContentType("text/xml;charset=UTF-8");
            PrintWriter out      = response.getWriter();
            DBQueriesRSS queries = new DBQueriesRSS();
            String queryType     = request.getParameter("queryType");
            String strCount      = request.getParameter("count");
            int count            = (strCount != null && !strCount.equalsIgnoreCase("null") && strCount.length() > 0) ?
                Integer.parseInt(strCount) : 25;
             if(queryType != null && !queryType.equalsIgnoreCase("null") && queryType.length() > 0) {
                System.out.println("IN IF STATEMENT");
                switch(Integer.parseInt(queryType)) {
                    case 1 : out.println(queries.getDefault(count));System.out.println("1");       break;
                    case 11: out.println(queries.getDefault(count));System.out.println("11");       break;
                    case 21: out.println(queries.getTopDaily(count));System.out.println("21");      break;
                    case 22: out.println(queries.getTopWeekly(count));System.out.println("22");     break;
                    case 23: out.println(queries.getTopMonthly(count));System.out.println("23");    break;
                    case 24: out.println(queries.getTopYearly(count));System.out.println("24");     break;
                    case 31: out.println(queries.getTopNDailyBW(count));System.out.println("31");   break;
                    case 32: out.println(queries.getTopNWeeklyBW(count));System.out.println("32");  break;
                    case 33: out.println(queries.getTopNMonthlyBW(count));System.out.println("33"); break;
                    case 34: out.println(queries.getTopNYearlyBW(count));System.out.println("34");  break;
                    default: out.println(queries.getTopWeekly(25));System.out.println("default");    break;
                System.out.println("OUT OF SWITCH");
            System.out.println("OUT OF IF");
            out.close();
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
           processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo() {
            return "Short description";
        // </editor-fold>
    } The results from running this servlet are:
    http://localhost/proxy/RSSServlet??queryType=34&count=66
    CALLED SERVLET
    IN IF STATEMENT
    34
    OUT OF SWITCH
    OUT OF IF
    CALLED SERVLET
    IN IF STATEMENT
    34
    OUT OF SWITCH
    OUT OF IFAnyone see anything obvious?
    TIA!

    in your case you want 'count' to be a class attribute rather than a local variable. But yes, incrementing it each time that the method is called will serve your purpose.

  • Init method is called multiple times

    Hi,
    init method in my servlet is called more than 1 time.
    I think it is supposed to be called only 1 time,when the application is loaded.
    anything to do with web.xml ???
    or else what r the situations that init method is called more than 1 time
    thanks

    Hi,
    actually I figured out the problem.
    I am using logger staements for debugging.
    I am also using singlethread model for servlet.
    I came to know that it creates multiple instances of servlet...
    which inturn calls init method multiple times.
    i took out that singlethread model,now it is working perfect.
    Thanks

  • Transactional business method is called 4 times on failure

    Hi I'm experiencing a strange situation. does anybody have an idea what is wrong or just going on?.
    There is a stateful session bean which has a transactional business method called 'apply' to delegate insert/update requests to Toplink which will persist data in database. 'trans-attribute' is defined 'Required'. Toplink registers with the OC4J's external transaction.
    when there is an error in commiting the data apply method is called 3 more times (4 times in total).
    any idea????
    thanks
    -Erdem.

    Hi Erdem,
    This question has been discussed previously on this forum.
    [However, when I searched the forum archives to make sure, I couldn't find it -- but I _know_ I had a similar problem _and_ found the answer while monitoring this forum!]
    In any case, I think the behaviour that you are seeing is caused by the "max-tx-retries" attribute in the "orion-ejb-jar.xml" file. Here is a resource with some more details:
    http://kb.atlassian.com/content/orion/docs/deployment/orion-ejb-jar.xml.html
    You may also find relevant information at one (or more) of the following Web sites (if you haven't already looked at them):
    http://technet.oracle.com
    http://tahiti.oracle.com
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.elephantwalker.com
    Hope this helps.
    Good Luck,
    Avi.

  • Listener method is called multiple times

    why is a listener method called multiple times when the user interacted
    with the component just once?

    Because you have a bug in your code.
    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • Stateless session's one method to call  two bmp's create method

    JSP calls one stateless session's one method and the method calls two bmps'
              create method.
              However, When the second bmp run the create operation, the exception
              happens.
              But the date that the first bmp insert is not rollbacked.
              How can I rollback all data, when the exception happens?
              

    Use JSP actions.
    <jsp:useBean id="shoppingCart" class="com.package.Cart" scope="session">
    <jsp:setProperty name="shoppingCart" property="userName" value="Guest" />
    </jsp:useBean>

  • Action method getting called multiple times.

    Hi All,
    The problem that I am facing is pretty weird.
    The issue is the i have an input field that takes date as input field.
    This field is inside a data taable
    FYI: I tried converter still same problem.
    So when ever I enter wrong data as "asda" inside this date field I get a validation error. which is good. So assume it took me 3 submit clicks to fix all my errors on the page.
    So now when I click the submit for the 4th time.
    The action method gets trigerred 4 times.
    Desperately waiting for a fix.
    Thank you in advance.
                                            <h:dataTable id="disbursementTable"
                                                 value="#{certTemplateBean.disbursements}" var="disbursement"
                                                 binding="#{certTemplateBean.disbursementTable}"
                                                 columnClasses="disburseDate,disburseAmt,disburseAction"
                                                 styleClass="disbursementTable" cellspacing="0" cellpadding="1">
                                                 <h:column >
                                                      <h:inputText id="disburseDate" styleClass="#{certTemplatesListBean.errorHolder.disburseDate} ms" size="10"
                                                                value="#{disbursement.date}">
                                                           <f:validator validatorId="RegExp" />
                                                           <f:attribute name="regexp" value="[0-9]{2}/[0-9]{2}/[0-9]{4}" />                                             
                                                           <f:attribute name="fieldRef" value="Disbursement Date :" />
                                                           <f:attribute name="message" value="Invalid Date" />
                                                           <f:attribute name="bean" value="certTemplatesListBean" />
                                                      </h:inputText>
                                                 </h:column>
                                            </h:dataTable>
                                            <h:commandLink id="addPro"
                                                 action="#{certTemplatesListBean.doAddUpdateCertTemplate}">
                                                 <h:outputText value="Add Profile direct"/>
                                            </h:commandLink>

    Probably got to do with the JSF jar files. I am not sure though. Can you check if the below link is useful?
    http://jira.jboss.com/jira/browse/AJSF-127

Maybe you are looking for