I have problem that when i click JComboBox i will display all ProductName in JComboBox but when i click it again the items becomes dusplicate means again select statement called i only want that if i click once it will update the JComboBox not as many times i click it will update i am using Action on Click This is my Code
Please help me.

          try
            {
                java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                java.sql.Connection xcon = java.sql.DriverManager.getConnection("jdbc:odbc:NADEEMSONS","sa","123");
                Statement st=xcon.createStatement();
                ResultSet result = st.executeQuery("Select PNAME from products_details");
                while(result.next())
                {
                    String cmb = result.getString("PNAME");
                    cmbProduct1.addItem(cmb);
                }

            }
            catch(java.lang.ClassNotFoundException | java.sql.SQLException ex1){}

well, if this is the code that runs when you click, what you describe is completely normal.
what you could do, is at the end of your actionPerformed execution, set the button to disabled.
or, better yet, since the contents of your db may have changed, as first action of your actionPerformed, remove all the current items in your combobox.

How i do this i have tried following code but on mouse exit it will remove all items i want that the item which i select will not remove can you give me some idea please..

    private void cmbBillPro1MouseClicked(java.awt.event.MouseEvent evt) {                                         
            try
            {
                java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                java.sql.Connection xcon = java.sql.DriverManager.getConnection("jdbc:odbc:NADEEMSONS","sa","123");
                Statement st=xcon.createStatement();
                ResultSet result1 = st.executeQuery("select pname from products_details");           

                while(result1.next())
                {
                    String pname = result1.getString("PNAME");
                    cmbBillPro1.addItem(pname);
                }

            }
            catch(java.lang.ClassNotFoundException | java.sql.SQLException ex1){} 
    }                                        

    private void cmbBillPro1MouseExited(java.awt.event.MouseEvent evt) {                                        
            cmbBillPro1.removeAllItems();
    }                                       

Done I have put cmbBillPro1.removeAllItems(); in begining of action performed and my problem solved Thanks

This question has already been answered. Start a new discussion instead.