Forums Register Login

How to Resize JScrollPane used in a JPanel?

+Pie Number of slices to send: Send
Hi ,

I am adding a scroll pane of textArea to a JPanel. And this JPanel is added to another Panel where I can have a tablepanel(a component)

Its like a panel consisting of tablepanel and JPanel .

Can you help me with this?

I am not able to resize the panel / scroll pane (by dragging the edge of scroll pane, so that I can see the whole decription(when its abundant) of property without using scroll bars.)


Code :

private JPanel createPanel() {
final JTextArea textArea = getNewTextArea();
//gets text area of properties description. Dynamically changes
// when upon selection of particular property
textArea.setBackground(Color.GREY);
textArea.setRows(4);
textArea.setText("Description of property set here.");
final JScrollPane scrollPane = new JScrollPane(textArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setPreferredSize(new Dimension(600, 60));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(scrollPane, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(50, 40));
panel.setVisible(true);

return panel;
}
+Pie Number of slices to send: Send
you'll need to experiment with different layout managers

e.g. run this, and it should display what I think you are describing,
then swap the new JPanel() lines, recompile and rerun

+Pie Number of slices to send: Send
Wonderful! Its working fine. I can use certain layout managers as per my application requirement. Thank you very much.
[ October 02, 2006: Message edited by: Raja Sekhara ]
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 31841 times.
Similar Threads
Can't make JTableHeader reorderingAllowed
JscrollPane with JTabbedPane for NullLayout
scroll pane in jpanel help
How to work with a ScrollPane in a SplitPane?
JButton and opening new window
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:23:14.