1

I just want to have a fixed sized JPanel which locks in its size (The user should NOT be able to change the size). How am I supposed to do that?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Sam
  • 2,702
  • 5
  • 31
  • 45
  • 1
    PS: Please help yourself by providing your source code. – Larry Morries Oct 14 '11 at 04:04
  • 2
    Deleted request for a "clear and definitive answer". You're asking for free advice man. If you don't understand an answer, please feel free to ask for clarification. – Hovercraft Full Of Eels Oct 14 '11 at 04:11
  • Related threads - http://stackoverflow.com/questions/3651206/fixed-width-variable-height-in-jpanel-with-flow http://stackoverflow.com/questions/7223530/how-can-i-properly-center-a-jpanel-fixed-size-inside-a-jframe http://stackoverflow.com/questions/316454/can-you-set-a-permanent-size-for-a-jpanel-inside-of-a-jframe – KV Prajapati Oct 14 '11 at 04:31

2 Answers2

5

JPanel is not resizable by the user.

If you are referring to JFrame, you can use setResizable(false);. Say abc is a frame, abc.setResizable(false);

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
COD3BOY
  • 11,964
  • 1
  • 38
  • 56
2

The panel might be placed in a non-resizable area of a layout (e.g. the non CENTER constraints of a BorderLayout).

For more details, we would need some ASCII art of the proposed GUI in two sizes (the first to show the layout, the 2nd to show how extra width & height should be assigned) and an SSCCE of your best attempt.

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