Results 1 to 2 of 2
  1. #1
    pinks_70986 is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

    Default java.swing.popup not hiding

    Hello I have application which has a textfield. This textfield is associated with a popup which shows suggestions(starting with enterd letter) after user enters a letter in it.Its like autocomplete for a textfield.the problem is if i enter a it shows all words starting with a if i press b it shows all words starting with ab n if press c and if theres no suggestion available the popup doesnt hide. the code is as shown below.Please help.
    public void csearch(String letter)throws SQLException

    {
    String word=null;
    DefaultListModel model = new DefaultListModel();
    option=false;

    String SQL="Select cname from company";
    Statement stat1 = conn.createStatement();
    stat1.executeQuery(SQL);
    ResultSet rs = stat1.executeQuery(SQL);



    int i=0;
    while(rs.next())
    {
    word=rs.getString(1);
    word=word.trim();
    if(word.startsWith(letter))
    {

    model.addElement(word);
    i++;
    option=true;
    }

    }


    final JList l = new JList(model);
    l.setOpaque(true);
    l.addListSelectionListener(newListSelectionListene r()
    {public void valueChanged(ListSelectionEvent e)
    {
    if(l.getSelectedIndex()!=-1)
    {

    a.nametxt.setText((String)l.getSelectedValue());
    pop.hide();//it works fine for this
    }


    }
    });


    PopupFactory factory= PopupFactory.getSharedInstance();
    int x=a.nametxt.getX();
    int y=a.nametxt.getY()+a.nametxt.getHeight();

    pop = factory.getPopup(a.nametxt,l,x+5,y+30);



    if(option==true)
    {
    pop.show();
    }
    else {
    pop.hide();//here is the problem
    }

    stat1.close();
    conn.close();

    }
    }

  2. #2
    pinks_70986 is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

    Default

    Please suggest something which is better than this popup to do autocomplete if you know

Similar Threads

  1. Java Popup Window & Url Query String Value
    By Rivelyn in forum New To Java
    Replies: 4
    Last Post: 01-20-2011, 05:03 AM
  2. URL Hiding
    By sandeeprao.techno in forum Advanced Java
    Replies: 4
    Last Post: 11-20-2008, 12:55 PM
  3. Creating popup menus with Swing
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:49 PM
  4. how we get popup window in java
    By baserohit in forum Advanced Java
    Replies: 1
    Last Post: 03-22-2008, 04:39 AM
  5. Popup in Java
    By fernando in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •