当前位置: 技术问答>java相关
请问jlist怎样实现鼠标双击事件打开一个对话框
来源: 互联网 发布时间:2017-04-11
本文导语: 请问jlist怎样实现鼠标双击事件打开一个对话框 | import javax.swing.event.ListSelectionEvent; import javax.swing.JList; JList jList1 = new JList(); class SymMouse extends java.awt.event.MouseAdapter { public...
请问jlist怎样实现鼠标双击事件打开一个对话框
|
import javax.swing.event.ListSelectionEvent;
import javax.swing.JList;
JList jList1 = new JList();
class SymMouse extends java.awt.event.MouseAdapter
{
public void mouseClicked(java.awt.event.MouseEvent e)
{
Object object = e.getSource();
if(object==jList1)
jList1_mouseClicked(e);
}
}
void jList1_mouseClicked(java.awt.event.MouseEvent event)
{
if(event.getModifiers()==MouseEvent.BUTTON1_MASK&&event.getClickCount()==2)
{
JOptionPane.showMessageDialog(this,"正在测试","警告",JOptionPane.WARNING_MESSAGE);
}
}
SymMouse picker = new SymMouse()
jList1.addMouseListener(picker);
import javax.swing.JList;
JList jList1 = new JList();
class SymMouse extends java.awt.event.MouseAdapter
{
public void mouseClicked(java.awt.event.MouseEvent e)
{
Object object = e.getSource();
if(object==jList1)
jList1_mouseClicked(e);
}
}
void jList1_mouseClicked(java.awt.event.MouseEvent event)
{
if(event.getModifiers()==MouseEvent.BUTTON1_MASK&&event.getClickCount()==2)
{
JOptionPane.showMessageDialog(this,"正在测试","警告",JOptionPane.WARNING_MESSAGE);
}
}
SymMouse picker = new SymMouse()
jList1.addMouseListener(picker);