Reputation:
Any method available to place the JTextArea
to the right of the JPanel
?
Upvotes: 0
Views: 1885
Reputation: 23263
This depends on the LayoutManager
that your JPanel
uses, not the JTextArea
itself. Unless you specify a LayoutManager
when creating your JPanel
, it will be using FlowLayout
.
Upvotes: 1
Reputation: 1499900
Do you mean in the right hand side within the JPanel
?
If so, you could construct the JPanel
with a BorderLayout
as its layout manager, then add the JTextArea
with
panel.add(textArea, BorderLayout.EAST);
It's possible that BorderLayout
isn't what you want though, depending on the right of your controls. There are many options available. I suggest you read a layout tutorial for more details.
If that's not what you mean, please clarify the question.
Upvotes: 1
Reputation: 4785
Try adding a spacer component to the JPanel first which will push the text area to the right. The code to create such a component is: Box.createHorizontalGlue();
Upvotes: 0