background image

 
contentPane = (JPanel)this.getContentPane();
 contentPane.setLayout(borderLayout1);
 this.setSize(

new

 Dimension(532, 468));

 this.setTitle("Frame Title");
 jPanel1.setLayout(xYLayout1);
 jList1.addMouseListener(

new

 Frame1_jList1_mouseAdapter(this));

 contentPane.add(jPanel1, BorderLayout.CENTER);
 jPanel1.add(jScrollPane1, 

new

 XYConstraints(18, 34, 209, 326));

 jScrollPane1.getViewport().add(jList1, null);
 jList1.setListData(strData);
 }
 

//Overridden so we can exit when window is closed

 
 

protected

 void processWindowEvent(WindowEvent e) {

 super.processWindowEvent(e);
 

if

 (e.getID() == WindowEvent.WINDOW_CLOSING) {

 System.

exit

(0);

 }
 }
 

//

 

具体实现按钮双击的功能的方法, 很简单的算法,不做解释了

 
 

public

 boolean checkClickTime() {

 long nowTime = (

new

 

Date

()).getTime();

 

if

 ( (nowTime - clickTime) < 300) {

 clickTime = nowTime;
 

return

 true;

 }
 clickTime = nowTime;
 

return

 false;

 }
 void jList1_mouseReleased(MouseEvent e) {
 

//判断是否双击,是的话写你要实现的功能

 
 

if

 (checkClickTime()) {

 System.out.println("Click Double");
 }
 }
 }
 

class

 Frame1_jList1_mouseAdapter

 

extends

 java.awt.event.MouseAdapter {

 Frame1 adaptee;
 Frame1_jList1_mouseAdapter(Frame1 adaptee) {