javax.swing.plaf.basic.BasicButtonListener.focusLost(...) implementation in JDK 8_60

时间:2016-04-07 10:30:43

标签: java swing focus jbutton action

I've noticed a strange change in the BasicButtonListener from JDK_1.6.0_17 -> JDK_1.8.0_60. The method focusLost(...) is now calling model.setPressed(false); before model.setArmed(false); If you press the mouse on a button and type the TAB-Key, the focusLost event causes the button to perform the action. Now you can combine this bahavour with any situation like - you enter a text and a focusLost of the text-component causes a dialog to appear (validation or something) while you want to press a button (save for example). In that case the button would be triggered. (This is only a fictional example so please don't talk about how bad this implementation concept is ;) In one case, the entire focus-sub-system went down, I call it that way, because the entire application had no focus at all. Swing Focus logging showed: Peer request failed I haven't found any useful clues regarding the problem, so I'm posting it here. Please reply if you know more regarding that change/problem. My workaround for now is to change back the order of those two methods. PS.: Someone wrote it's a problem on Windows OS only but not on Linux. I can't verify that, because I have only Win10@Work. Here is the diff of that method

0 个答案:

没有答案