开发者

cursor does not change to I-bar on mouseover JTextField

开发者 https://www.devze.com 2023-04-09 00:54 出处:网络
Initially the cursor changes to i-bar on mouseover, but after clicking a button (which basically calls setEnabled(false) and then setEnabled(true) on the JTextField) ,the cursor doe not change to i-ba

Initially the cursor changes to i-bar on mouseover, but after clicking a button (which basically calls setEnabled(false) and then setEnabled(true) on the JTextField) , the cursor doe not change to i-bar on mouseover JTextField.

What could be the reason? Any help or hint in right direction is most welcome.

The focus is also present in b开发者_如何转开发oth cases.


Try using setEditable(true) / setEditable(false) instead of setEnabled.

Thus, the JTextField will still be focusable and its content can be copied into the clipboard, which is not possible when it is disabled. That's the reason why the I cursor is not displayed (because you cannot select the field content).

Edit (after OP comments):

I tried to reproduce what you described but it worked perfectly: I have a JTextField and 2 buttons (one enabler and one disabler); whatever the manipulations, the cursor always has the correct shape when the field is enabled.

I have tested this behavior on Windows, Java6 64 bits, with default LAF.

You should definitely post a snippet that can demonstrate the problem and also tell more about your environment.

0

精彩评论

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

关注公众号