I'm making a calculator program with Java using Java's Swing toolkit, and I want it to be similar to Windows' (default) calculator.
I have a JTextField
for entering the numbers. You can see the cursor being displayed. I want to hide it.
I tried doing this:
textField.getCaret().setVisible(false);
but it didn't help. I also tried invoking it before and after I created and initialized the window but it still didn't work. The cursor was there.
I looked up the JTextField and Caret documentation but didn't find anything that could be useful for me, other than the setVisible()
method which didn't work.
How can I hide the insert caret/cursor?
you could just make it invisible, you can try
textField.setCaretColor(Color.WHITE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With