Boa noite!.. Pesquisei em alguns tutoriais porém não obtive sucesso… O problema é o seguinte, possuo uma JList em um frame e gostaria de implementar um evento de clique duplo em elementos da lista, o evento irá abrir um novo frame. Alguém poderia me dar uma dica? Desde já agradeço…
Eu acho que seria algo assim
// JList doesn't provide any special support for handling double or triple (or N) mouse clicks however it's easy to handle them using a MouseListener. Use the JList method locationToIndex() to //determine what cell was clicked. For example:
final JList list = new JList(dataModel);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int index = list.locationToIndex(e.getPoint());
System.out.println("Double clicked on Item " + index);
}
}
};
list.addMouseListener(mouseListener);
//Note that in this example the dataList is final because it's referred to by the anonymous MouseListener class.
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JList.html
thanks man… foi de grande ajuda
Pow ninguém nunca me deu um código pronto!