• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Resize JScrollPane used in a JPanel?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic