• Post Reply Bookmark Topic Watch Topic
  • New Topic

Proper sizing for dynamic components

 
Sebastiao Fernandes
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need some help with proper component sizing.

I am building a DB app in NetBeans v.6.5. I'm using the GUI designer for the most part and coding around it.

Here's what I'm trying to accomplish:

The user submits a school course's id. The DB is queried for the multiple choice test for that course and presents it to the user.

I am having great difficulty with the presentation. Specifically, the test questions and choices are being squished together vertically, making them unreadable.

I have tried fiddling with changing the size of things (eg. JRadioButton.setMinimumSize()) but with little success.

Here's my code for producing the test. I've omitted the NetBeans code for brevity:


In addition to the above, questionPanel is contained in a JScrollPanel whose properties (and code) were defined by the NetBeans GUI designer.

I hope that's enough details. I can certainly provide the GUI-designers code if it's needed.

Oddly enough, after fiddling with some size properties in NetBeans the problem fixed itself. But, while fiddling with similar settings (to improve the GUI layout) the problem has returned.

Thanks!
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Layout Managers
 
Sebastiao Fernandes
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for pointing me back to Layout managers. I had looked at those earlier when making my initial design but didn't get so deeply involved with them.

I'm still having some difficulty. I tried setting the vGap for my GridLayout components but that doesn't have much effect.

It seems to me that the problem lies in the JScrollPanel. Rather than sizing everything so it can be read, and a scrollbar be utilized if necessary, the app is trying to fit everything into the single pane. Since that code is NetBeans-generated I've included it in its entirety:



Any other suggestions on what to try? Changing Layout properties or JScrollPanel properties or something else?

Thanks!
 
Sebastiao Fernandes
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings all,

I seem to have solved this problem. And quite elegantly at that ;)

I re-set the preferred size of questionPanel (the JPanel inside the JScrollPane) to an appropriate side.

The code:



So, that's my solution. I'm happy that it's working because this was driving me nuts.

Academically, I'm wondering if anyone else has a suggestion.

Thanks for your help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!