开发者

Ignoring Java mouse events on AWT components that were generated from lightweight components

开发者 https://www.devze.com 2023-03-25 18:29 出处:网络
I have a JFileChooser that is opened on top of an AWT component (we use a GLCanvas for som开发者_JAVA技巧e openGL rendering). If I double click the icon in the file chooser to close it, the mouse clic

I have a JFileChooser that is opened on top of an AWT component (we use a GLCanvas for som开发者_JAVA技巧e openGL rendering). If I double click the icon in the file chooser to close it, the mouse clicks are passed to the GLCanvas. I have read that mouse events on the lightweight components will be passed to the heavyweight components, but is there a way to detect when this is happening? Double clicking on the GLCanvas performs another operation, which I would prefer not happen when the user is just double clicking to close the dialog.


You could create event handlers for the mouse events on the lightweight components and then do nothing inside of them, that should stop the propagation to the heavier components.

Something like:

    public void mousePressed(MouseEvent e) {}

    public void mouseReleased(MouseEvent e) {}

    public void mouseEntered(MouseEvent e) {}

    public void mouseExited(MouseEvent e) {}

    public void mouseClicked(MouseEvent e) {}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号