Chaozy
Chaozy

Reputation: 47

How to set a line border around JTextArea?

I have a JTextArea in my panel, but it is hard to distinguish it from the background. I tried setBound() but it doesn't really help. Screenshot of my GUI

(The textarea is next to the 'DESCRIPTION')

Is there any way to have a clear bound around it other than changing the colour of the background? Say having a line bound like what JTextField has(I put one next to 'EXPENSE' in my GUI).

Upvotes: 0

Views: 1069

Answers (1)

Chaozy
Chaozy

Reputation: 47

Thanks for the guys in the comment area! I put the textarea into a JScrollpane. It does create a border:

using JScrollPane

Then I also added a line border to make it more clear.

des.setBorder(BorderFactory.createLineBorder(Color.BLACK));

Thanks again to Andrew Thompson, the suggestion about using GridBagLayout does make everything look much better.

Using GridBagLayout

Upvotes: 1

Related Questions