2
I wonder how to leave only one edge on one JTextField
, similar to data entry when logging into Gmail, that is, with a border at the bottom.
2
I wonder how to leave only one edge on one JTextField
, similar to data entry when logging into Gmail, that is, with a border at the bottom.
5
You can create borders with the class MatteBorder
as follows:
textField.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.BLUE));
The method createMatteBorder
allows you to define the thickness of each component edge in addition to the color. Simply enter 0 in all except the third parameter, which is equivalent to the size of the bottom edge.
Take an example:
Of course to get the image effect above, you need to apply the same background color of your screen to JTextField
, something like:
textField.setBackground(seuFrame.getBackground());
or
textField.setBackground(painelDoTexField.getBackground());
otherwise, although it only has a visible border, the background will turn white, highlighting the field of the rest of the screen.
Browser other questions tagged java swing jtextfield
You are not signed in. Login or sign up in order to post.
It worked really well thank you!
– Felipe Moreno Borges
@Felipemorenoborges :)
– user28595