Code example for JList

Methods: addMouseListener

0
		 
	} 
	 
	 
	private void initSuggestionList() { 
		list = new JList();
		list.addMouseListener(new MouseListener() {
			private int selected;
 
			@Override 
			public void mousePressed(MouseEvent e) {
			} 
 
			@Override 
			public void mouseReleased(MouseEvent e) {
				if (selected == list.getSelectedIndex()) {
					// provide double-click for selecting a suggestion 
					setText((String) list.getSelectedValue());					
 
					dialog.setVisible(false);