How can I change the border color of JTextField? I tried someField.setBorder(new LineBorder(Color.RED,2)), but it is giving me
mismatcherror(incompatible types: javafx.scene.paint.Color can not be converted to java.awt.Color).
Thanks for answers in advance.
Please check your import section. You should import java.awt.Color like this:
import java.awt.Color;
If you want to create borders with the LineBorder class, then you can do:
import java.awt.Color;
import javax.swing.border.LineBorder;
textField.setBorder(new LineBorder(Color.RED, 2));
Another option is to create borders with the BorderFactory class, like this:
import java.awt.Color;
import javax.swing.BorderFactory;
textField.setBorder(BorderFactory.createLineBorder(Color.RED, 2));
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