wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JScrollPane size problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane size problem" Watch "JScrollPane size problem" New topic
Author

JScrollPane size problem

Paul Mrozik
Ranch Hand

Joined: Feb 10, 2013
Posts: 117

I have the following window:



Code snippet:



What you don't see is the button panel, unless one resizes and moves the window. This is starting to make me think: How will this look on OS X? Ubuntu? Will I have to modify the application's behavior for all these systems? What should I do to make the buttons visible? Why are they hiding under the taskbar?

I'd be grateful for your help.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10491
    
    9

Have you provided any preferred sizes or any other dimensions to your scroll pane? Looking at your image, it seems to be the case because he vertical scroll bar is showing.
The usual way is to add the scroll pane to a container which has a border layout
e.g.

This way the scroll bars show up as and when required.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Paul Mrozik
Ranch Hand

Joined: Feb 10, 2013
Posts: 117

Maneesh Godbole wrote:Have you provided any preferred sizes or any other dimensions to your scroll pane? Looking at your image, it seems to be the case because he vertical scroll bar is showing.
The usual way is to add the scroll pane to a container which has a border layout
e.g.

This way the scroll bars show up as and when required.


Thanks for your input Maneesh.

The vertical scrollbar is showing because the content of the wrapped JPanel (childComponentToBeWrapped) doesn't fit. I've also disabled the horizontal scrollbar. I haven't set any preferred sizes, although I did try but it had no effect. I am probably doing something wrong, but I don't know why the JPanel below the JScrollPane is pushed under the taskbar.



Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10491
    
    9

Could be the layout then. Please post your SSCCE (<=link, please read) so we can take a look
Paul Mrozik
Ranch Hand

Joined: Feb 10, 2013
Posts: 117

Maneesh Godbole wrote:Could be the layout then. Please post your SSCCE (<=link, please read) so we can take a look


Okay, I tried to make it as SSCCE as possible and I'm pasting the code below. The only thing that makes this a bit nonstandard is the MigLayout package, available here. I'm also adding a GridLayout example if you want to compile right away, which I haven't tuned, and although the buttons show up, the rest of the window slides under the taskbar as well.[/url]

First MigLayout:



And GridLayout:



In both cases, the bottom of the window slides under the taskbar.


Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 667
    
  11
I don't know MigLayout, but GridLayout makes all components equal in size.

I've tried your code, and since your scrollpane is 529 pixels high, the buttonpanel gets a height of 529 too. making the frame getting a height of about 1100 pixels. That's bigger than my screensize.

You could do the following:


and



I've tried it, and it works!

Greetz,
Piet

Paul Mrozik
Ranch Hand

Joined: Feb 10, 2013
Posts: 117

Piet Souris wrote:I don't know MigLayout, but GridLayout makes all components equal in size.

I've tried your code, and since your scrollpane is 529 pixels high, the buttonpanel gets a height of 529 too. making the frame getting a height of about 1100 pixels. That's bigger than my screensize.


You're right, that's exactly what happens.


You could do the following:


and



I've tried it, and it works!

Greetz,
Piet



It certainly does, works like a charm with MigLayout as well. Thank you Piet!
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 667
    
  11
You're welcome!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JScrollPane size problem