• 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

can scrollPane be resized automatically?

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when we resize a JFrame, is it possible to resize the containing scroll pane with the frame automatically? is there any function?
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried it? I would have thought most of the layout managers would automatically resize all Components. So don't use null layout.

Please tell us what happens when you try.
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
This is the following snap of code that I have tried. But can not resize scroll pane with the frame.


It's not working...
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using setBounds for anything other then a top-level container? If you set the size of the panel you are adding the scroll pane to, there cannot be any change of size. That might be your problem.
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Part1 of my application.

Part2 of my application.

To set the components at the right places I have to use the setBounds. I am using setBounds to fix the labels, textboxes and the buttons on the toplabel container. then the top conatiner is being fixed on the base container as:

and then the basePanel is added on the main Frame as:

here frameSizeX and frameSizeY are int type and I set the size of the frame using these. If I do not use line 1 or line 2 then the frame will not show anything.
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little change on the above post instead of
*the basePanel is added on the main Frame as
the basePanel is added on the ScrollPanel and scrollPane is added on the main frame in turn.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what sort of LayoutManager are you using on the Frame? You may find there is no change of size if you use null layout, whereas you will get change of size with Grid or GridBag. I think you get a change of size with Border, too.
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On frame i am using the BorderLayout, and fixed the scrollpane on it using add(scrollPane, BorderLayout.CENTER);
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Mr. Ritchie,

You were right. I was using null layout for the frame layout. Now I have turned it to BorderLayout and its workibg perfect.

Thanks a lot.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sandeep Mukherji:
hello Mr. Ritchie, I was using null layout for the frame layout. Now . . . its workibg perfect.

Thanks a lot.

You're welcome
 
reply
    Bookmark Topic Watch Topic
  • New Topic