Reputation: 43
I want to make a program such that the components behave as shown in the pictures below
I would also want TextArea to be "scrollable" when it's not big enough to show all the text at once.
Any tips? :)
Upvotes: 1
Views: 455
Reputation: 324118
The secret of layout management is to nest panels with different layout managers to achieve your desired layout.
So you start with the default BorderLayout of the frame.
Then you create a panel for your buttons and add the panel to the frame:
JPanel buttonPanel = new JPanel( new FlowLayout(...) );
buttonPanel.add( button1 );
..
frame.add(buttonPanel, BorderLayout.PAGE_START);
Next you add your text area to the frame:
JTextArea textArea = new JTextArea(10, 30);
frame.add(new JScrollPane(textArea), BorderLayout.CENTER);
Now the two things happen with the text area:
Read the section from the Swing tutorial on Layout Managers for more information and working examples.
Upvotes: 1