Plz help.
I am working to create application kind of auto-suggestion. I am using JTextPane along with Jlist on PopupMenu. I am not able to get the Action Event on JList.
and other problem is that my KeyPress Event of JTextPane are getting overlapped with JList hence nothing is selected when Enter is pressed or even Mouse is clicked.
Plzzzzzzzz help as soon as Possible.

public class ListListener implements ListSelectionListener {
        public void valueChanged(ListSelectionEvent e) {
         try{
                  popupMenu.setVisible(false);
             TextPane1.setText(wpop.putloc(jTextPane1.getText(),list.getSelectedValue().toString(),jTextPane1.getCaretPosition()));
               }
            catch(Exception ex)
            {
               
            }
        }
        
    }
private void ListPopUp(String str[])
    {
        
            model1=new DefaultListModel();
            size=model1.getSize();
            list =new JList();
            list.removeAll();
            list.addListSelectionListener(new ListListener());
            for(int i=0;i<str.length;i++)
             model1.addElement(str[i]);
            list.setModel(model1);

            int ht=(model1.getSize()*24);
            if(ht>250)
                ht=250;
            a.setPreferredSize(new Dimension(100,ht));
            list.setPreferredSize(new Dimension(75,model1.getSize()*12));
            a.setViewportView(list);
            
            popupMenu=new JPopupMenu("Popup");
            popupMenu.add(a);
            popupMenu.setInvoker(jTextPane1);
            ActionListener lis =new PopupActionListener();
          //popupMenu.setSize(40,model1.getSize()*12);
            //popupMenu.pack();
            //popupMenu.setPopupSize(null);
            popupMenu.show(jTextPane1, 30, 20);

            size=model1.getSize();

            jTextPane1.setRequestFocusEnabled(true);
            jTextPane1.grabFocus();
    }
This article has been dead for over six months. Start a new discussion instead.