Search code examples
javaborderjtextarea

How to change border width of JTextarea in java


How to change the border width? I want a lighter border.

Below is my try

// Set border
Border border = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
textarea.setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5)));

JTextarea border width


Solution

  • The LineBorder of the text area is 1 pixel wide.

    The JScrollPane also has a LineBorder 1 pixel wide.

    Don't add the LineBorder to the textarea. Just use the EmptyBorder.