0

I was wondering how does one put spacing and set the size of a JTextArea component in Java.

eg

//I've tried
        questInfo = new JTextArea(20,30);
        questInfo.setMargin(new Insets(10,10,10,10));

When I preview the gui, It just shows JTextArea filling in the pane from top to bottom and left to right, no spacing in between the pane

John
  • 25
  • 1
  • 8

1 Answers1

8

Apparently, this happens due to UI overriding the margin. Please refer to this question. You might resolve it using:

questInfo.setBorder(BorderFactory.createCompoundBorder(
        field.getBorder(), 
        BorderFactory.createEmptyBorder(5, 5, 5, 5)));
Community
  • 1
  • 1
PseudoAj
  • 5,234
  • 2
  • 17
  • 37