Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Resize JScrollPane used in a JPanel?  RSS feed

 
Raja Sekhara
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Raja Sekhara
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!