0

In the netbeans designer, every frame and panel I'm using is set to [415,330], but when I run the program it looks like the window is still set to [400,300] or something close to that. I'm changing the minimum, maximum and preferred size. Do I need to do something else?

EDIT: Restarted netbeans and the problem fixed itself.

alexanderd5398
  • 332
  • 1
  • 4
  • 16
  • Could we see some code that reproduces the issue? – Elliott Frisch Jan 10 '15 at 18:35
  • A frame has borders, the preferred/min/max size doesn't take those into account and the viewable are is been set to meet yr requirements then the frame is likely been added around it.... – MadProgrammer Jan 10 '15 at 18:45
  • @MadProgrammer If the viewable area was set to meet my requirements why is the window smaller than what I set? – alexanderd5398 Jan 10 '15 at 20:05
  • 2
    Probably because it's been packed to meet the requirements of the content. Best bet. Ditch the form editor and hand code your UI's until you understand how the API fits together – MadProgrammer Jan 10 '15 at 20:13
  • @MadProgrammer So it will just set itself to however big it needs to be to fit all the components on the screen? It was doing that before and I solved it by just setting a label with no text to the position I want to my screen to be. I just tried that now and the screen was set back to the same size as before. – alexanderd5398 Jan 10 '15 at 20:32
  • *"I'm changing the minimum, maximum and preferred size."* See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) – Andrew Thompson Jan 10 '15 at 23:54

1 Answers1

1

Even if you've set the size with minimumSize and preferredSize, you might have forgotten to call Window.pack() in which Swing will resize the components (and all of it's subcomponents) according to the sizes set.

You call it in your window (or whatever is building your window) after all the preferred sizes are set.

Waqas Ahmed
  • 1,321
  • 1
  • 14
  • 23