I've got a problem with requestInWindow
in Java where I need to focus on a textfield when its container becomes visible.
It works sometimes, but there are those times when a gui will run slowly because of os operations. For example if an antivirus is scanning the computer, programs will respond a bit slow.
Such is the case here. If the os is not doing anything heavy, requestInWindow
works fine, otherwise it does not.
So I want to know, is there a way to be absolutely dead sure that now JTextField
is visible, then we can kick in requestInWindow
at that moment. I tried a lot of things like SwingUtilities.invokeLater
and SwingWorker
.
In case you want know why I need this, look at a POS. The user does not have time to be moving around the mouse trying to focus on the field where they have to enter barcode or amount paid, all they need is to have the system do that for them, what they do is only hit the keypad.