title: [ NOT SOLVE] issue with list model list.removeAllElements java swing
body: <p>i m using java swing and i want to make search box same as google so i used texfiels and Jlist and values added into it from database where List is setvisible(false) at start of program and it become visible(true) when data entered into JlistModel. </p>
  
  <p>i will simulate program using JOptionpane.showMesssageDialoge i found bug at RemoveAllElement</p>
  
  <p>my source code is ,</p>
  
  <pre><code>    TMSearch=new JTextField();
      TMSearch.setBounds(200,220,350,30);
      add(TMSearch);
      TMSearch.addKeyListener(new KeyAdapter()
      {
  
          public void keyTyped(KeyEvent ke)
          {
  
          String QueryValue;
              if(ke.getKeyChar()== '\b' )
              {
                  QueryValue=TMSearch.getText();
  
  
  
              }
              else    
              {
                  QueryValue=TMSearch.getText()+ke.getKeyChar();
  
  
              }
              if(ke.getKeyChar()== '\b' &amp;&amp; TMSearch.getText().length() == 0 )
              {
              BMReset.doClick();
              }   
  
      try     
          {
  
              Class.forName("com.mysql.jdbc.Driver");
  
              con=DriverManager.getConnection("jdbc:mysql://localhost/medi","root","");
  
              if(con==null)
              {
                  JOptionPane.showMessageDialog(null,"ERROR");
              }
  
        MListModel.removeAllElements();   
              ps=con.prepareStatement("select * from medicine where cname like ? or mname like ?");
              ps.setString(1,QueryValue.concat("%"));
              ps.setString(2,QueryValue.concat("%"));
  
  
              rs=ps.executeQuery();
  
  
              while(rs.next())
          {           
  
                      int mid=rs.getInt("mid");
                      String  cname=rs.getString("cname");
                      String mname=rs.getString("mname");
                      float price=rs.getFloat("price");
                      String date=rs.getString("exp_date");
                      int mpunit=rs.getInt("mpunit");
                      int quantity=rs.getInt("quantity");
                      String temp;
                      temp=mid+"  "+cname+"  "+mname+"  "+price+"  "+date+"  "+mpunit+"  "+quantity;
  
                      MListModel.addElement(temp);
                      MListPane.setVisible(true); 
  
  
  
      ListFlag=1;
          }
          }
          catch (ClassNotFoundException e)
          {
          } 
          catch (SQLException e) 
          {
          }
          catch (Exception e) 
          {
          }   
  
  
  
  
          }
      }); 
  </code></pre>