• Post Reply Bookmark Topic Watch Topic
  • New Topic

Having difficulty sizing a viewport to fit inside a JDialog...any suggestions?  RSS feed

 
Ray Jaramillo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JRefreshTable in a JScrollPane on a JPanel with 2 buttons. The whole thing is in a JDialog of a fixed size. I am unable to make the viewport of the JScrollPane small enough to fully display the whole JPanel in the JDialog. Both buttons and the bottom of the table is always cut off. I feel like i have tried everything. I have tried adding a scrollPane to the JDialog and that moves my buttons on the JPanel around. Anyone have any suggestions?
Here is the code. I have omitted the action listeners for the buttons to compact the code a little.

 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JPanel uses a FlowLayout. Try creating it with a different one, like a BorderLayout or a BoxLayout.
 
Ray Jaramillo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Rob,

Thank you for the reply. Of course it was the Layout. I am a little embarrassed for not knowing that to begin with. I guess sometimes you need an outside view to tell you what you are missing. Once I took a look at changing to a BoxLayout I was able to get the desired results.

Thanks again!
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!