Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resizing JFrame

 
steve nicholls
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello-
I am having a problem whenever I resize my GUI. If I click and drag one of the GUI corners, to a size less than the content in the Frame, the content (all text boxes, labels, JTable...) is redrawn as a tiny unreadable mess.
I tried placing all the content on one Panel and using scroll pane with this panel, although this does not work (acts the same as above, no scrollbars appear).
I also looked into the JFrame library but all they have is setResizable(boolean). I don't think its reasonable to assume the user won't want to resize.
Is there a simple solution to this problem? Any advice would be appreciated. Thanks.
-Steve
 
Jawad Kakar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Layout Manager are you using? try a different Layout. I used GridBagLayout.
Jawad
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am having a problem whenever I resize my GUI. If I click and drag one of the GUI corners, to a size less than the content in the Frame, the content (all text boxes, labels, JTable...) is redrawn as a tiny unreadable mess.

What you want to do is to programmatically control the minimum size for your frame:

Eugene.
 
steve nicholls
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using GridBag Layout also.
Ideally, I would like to see scrollbars if the user resized the GUI too small. Eugene, I like your idea, but the user is still somewhat limited in what they want on their display. I will probably go this route if I can't get my scroll bars.
Doesn't this seem like a common problem that UI developers run into all the time. I'm a little surprised I haven't found anything that directly addresses this problem.
More advice and suggestions are welcome (and encouraged), but I might just let this go if I can't figure it out in a couple days. Thanks!!
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ideally, I would like to see scrollbars if the user resized the GUI too small.

Look at the GUI screens of some well-design Java application, such as JBuilder. You will never see scrollbars appearing no matter how you resize the frame. Instead, all the frames always have a minimum size. I suggest you do exactly the same, -- all the components of your frame should be visible at all times.
Eugene.
 
steve nicholls
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay Eugene you've sold me, no scrollbars. BTW, I really appreciate the help. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic