这个就是你所单击组件的双击方法,直接调用doubleclick事件重写就可以了
public class Frame {
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(3);
frame.setSize(500, 400);
final JList list = new JList(new String[]{"A", "B", "C", "D"});
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
JOptionPane.showConfirmDialog(null, list.locationToIndex(e.getPoint()));
}
}
});
frame.setContentPane(list);
frame.setVisible(true);
}
}