• 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 increase the height of a JScrollpanes dynamically

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is a outer panel with border layout, then a panelUpper at BorderLayout.NORTH and a panelBottom at BorderLayout.BorderLayout.SOUTH and a JScrollPane scrForm at BorderLayout.CENTRE.
the scrForm contain a panel pnlForm
scrForm.getViewport().add(pnlForm)
and at runtime, the pnlForm will add a panel panelPAMM
pnlForm.add(pnlPAMM)
so the pnlForm will increase its height at runtime,
now the problem is when the pnlForm incrrease its height, the outer JScrollpane scrForm shows a vertical scrollbar to let user scroll down to the increased area, but I want the scrForm to increase its height to accomodate the pnlForm instead of showing the vertical scrollbar, only when the JScrollpane scrForm increase to a maximum height then it show the vertical scrollbar instead, how to implement it?
 
peter tong
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have try to increase the JViewport.viewsize by
scrForm.getViewport().setViewSize(new Dimension(400, 800));
but it does not help, the scrForm height has not been increased.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your description makes little sense.

scrForm at BorderLayout.CENTER will occupy all the available space
leftover in the frame after allocating the other BorderLayout positions.

so, do you mean that when pnlForm increases its height you want the
actual JFrame to also increase its height (which will increase scrForm's height),
until scrForm's max height has been reached, then the scrollbars appear?

if so, that would look really weird
 
peter tong
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:your description makes little sense.

scrForm at BorderLayout.CENTER will occupy all the available space
leftover in the frame after allocating the other BorderLayout positions.

so, do you mean that when pnlForm increases its height you want the
actual JFrame to also increase its height (which will increase scrForm's height),
until scrForm's max height has been reached, then the scrollbars appear?

if so, that would look really weird



yes, this is what I want to archieve, is there any way to implement it?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call pack() on the JFrame again, or its setSize() method.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic