Any method available to place the JTextArea
to the right of the JPanel
?
3 Answers
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.
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
.
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();