How to keep the highlight border of a JComponent, when custom border is set
- by Frederik Wordenskjold
I have a JTextField, where I've set some custom properties:
nameField.setPreferredSize(new Dimension(275,40));
nameField.setBackground(bgColor);
nameField.setForeground(txtColor);
nameField.setFont(new Font("HelveticaNeue",Font.PLAIN,22));
nameField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
When the component has focus, there is no highlight shown around the field. On a Mac, it is usually a blue glowing rectangle, indicating that this component has focus.
If I comment out the nameField.setBorder(...), the highlight reappears. How do I keep the highlight, but also my custom border!?
Basically, I just want the highlight-border to show when the component has focus, and no border when the component is unfocused.