[英]Java InputVerifier find component who causes the “focus lost”
I have an InputVerifier
for a jTextField
and of course the InputVerifier
is triggered when I loose the focus of the text field for example through clicking on a button. 我有一个
InputVerifier
的jTextField
和过程中的InputVerifier
当我通过点击一个按钮松动,例如文本字段的焦点被触发。
If I would use a FocusListener
I could do: 如果我要使用
FocusListener
我可以这样做:
focusLost(FocusEvent e) {
e.getOppositeComponent()
}
which gives me the component which is the reason that the focus is lost in this case the clicked button. 这给了我组件,这是在这种情况下单击按钮失去焦点的原因。
Is there a way to do something like this in an InputVerifier
too ? 有没有办法在
InputVerifier
做类似的事情? Basically I need to know if the reason that the InputVerifier
is triggered is because a button was pressed. 基本上,我需要知道是否触发
InputVerifier
的原因是因为按下了按钮。
Basically I need to know if the reason that the InputVerifier is triggered is because a button was pressed.
基本上,我需要知道是否触发InputVerifier的原因是因为按下了按钮。
If you want to prevent the verification when you click a specific button then you can use: 如果要在单击特定按钮时阻止验证,则可以使用:
button.setVerifyInputWhenFocusTarget( false );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.