我认为把一切都搞砸了。我尝试在MouseEntered
事件触发时创建弹出窗口。我怎样才能解决这个问题?
Popup p=factory.getPopup(c,null,x,y);
我不确定参数
此代码的其余部分:
public class pop extends JFrame{
class mypopUpShow implements ActionListener{
JComponent c;
// final Random random;
public mypopUpShow(JComponent c){
this.c=c;
}
@Override
public void actionPerformed(ActionEvent ae) {
Random random=new Random();
int x = random.nextInt(200);
int y = random.nextInt(200);
PopupFactory factory=PopupFactory.getSharedInstance();
Popup p=factory.getPopup(c,null,x,y);
p.show();
}
}
public pop() {
JPanel Panel=new JPanel();
final Timer t=new Timer(100, new mypopUpShow(Panel));
MouseListener listener=new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent me){
t.start();
}
};
setSize(300,300);
Panel.addMouseListener(listener);
add(Panel);
}
public static void main(String...arg){
new pop().setVisible(true);
}
}