-2

I want to shrink my JFrame less than 100 pixels length and width, but it seems like a frame has a limit in shrinking the window. Is there any possible way to shrink the window any further? Let's say, making a boxed window setSize(50,50). How can one do that correctly? I feel so limited that you can't make the window size as small as you want to.

I think it has something to do with the title bar, but how can you adjust the size of the title bar?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • You should really show us more code, but absent that - invoke [`setMinimumSize(Dimension)`](https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setMinimumSize(java.awt.Dimension)) to change the ***minimum size***. – Elliott Frisch Jul 03 '21 at 14:20
  • 1
    *I think it has somethin to do with the title bar, but how can you adjust the size of the title bar?* - exactly and you can't shrink adjust the minimum size because of the decorations on the title bar which is OS controlled. You can always use an "undecorated frame" and create your own title bar. Why would you ever want a frame of size (50, 50). What purpose does this serve? – camickr Jul 03 '21 at 14:35
  • What if I want to make a real simple program? It's just so I can. I feel limited knowing I can't really adjust the dimensions anyway I want. – Reynaldo Santos Jul 03 '21 at 14:57
  • 2
    (1-) *I can't really adjust the dimensions anyway I want.* - that is NOT how you design an application. Components in a Swing application will determine their own size. You then pack() the frame and the components will be displayed properly. This will allow your application to run correctly on different platforms and allow you to easily change properties of components. Learn how to use Swing the way it was designed to work, not how you think is should work. – camickr Jul 03 '21 at 15:02
  • 1
    *"Relax man."* Has that ever worked - in the history of humankind? I agree with the general point of @camickr on this one. It looks like you are trying hard to create an unusable GUI. If the app. actually needs something that small, put it in a tooltip or something. But I really doubt it makes sense anywhere but in your imagination. My advice, focus on making 'standard' GUIs that people can actually use, at least for the first 100 or so. By then you'll probably look back on this question and laugh (like I did!). – Andrew Thompson Jul 03 '21 at 20:38
  • It was just a simple question. All I wanted to do was make a practice GUI that just had a couple of buttons to test the interactions. I can't believe I got judgment instead . This is insane. But at least I did get one good answer where I was told that the title bar does limit the size. So now the question is, how to adjust the size of the titlebar. – Reynaldo Santos Jul 05 '21 at 13:39
  • *All I wanted to do was make a practice GUI* - and you were given advice on how this is normally done. Normally beginners appreciate the suggestions so you don't waste time attempting to do something that can't be done. *So now the question is, how to adjust the size of the titlebar.* - how this different than your original question? You have been told you can't adjust the minimum size. and you were given the answer on how to get around the problem, if you really want to do this on your own. You are welcome for all the help you have been given, even though you don't seem to appreciate it. – camickr Jul 06 '21 at 01:15

1 Answers1

1

Is there a minimum size for JFrames?

Yes. The title bar limits the smallest width and height of the frame. Remove it at your (& by that I mean the hapless user's) peril.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433