osx - How can I implement Java/Swing controls that are disabled until after the window is activated? -


i implementing java/swing application macos, common mouse button related behavior disabled until window activated. in other words, when mouse button pressed on inactive window, window activated nothing else happens. (there exceptions. buttons when clicked activate window , run normal action.) there way this? basic problem time application gets mouse pressed event, window active. thought far correlate window activated event , mouse pressed event time, might not reliable.

you can make button's contains() depends on frame's active or not:

    final jframe frame = new jframe();      jbutton button = new jbutton() {         @override         public boolean contains(int x, int y) {             return super.contains(x, y) && frame.isactive();         }     }; 

when frame deactive , region of button clicked, button won't accept mouse event since contains() returns false, button's parent tested contains() instead (and parent's parent until returns true), still makes frame active, button not given chance response mouse click.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -