• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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 ]
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic