1 Reply Latest reply on Aug 22, 2006 3:33 AM by 794342

    Have JFrame respect the minimum size (stop resizing) - Partial solution


      I remember I searched for a solution to make JFrame respect the minimum size of itself or it's components, but unfortunately there is no solution, at least not a satisfactory one.
      The force-a-resize-if-it-gets-too-small "solution" looks really bad so I desided to drop the whole thing.

      However I've been testing around with different Look & Feels and changing the layout, and what I discovered is that when setting setDefaultLookAndFeelDecorated(true) the minimum size is respected.

      I haven't seen anyone mentioning this I thought I'd post it here.
      import javax.swing.*;
      import java.awt.*;
      class RespectMinimumSize extends JFrame {
          RespectMinimumSize() {
           setMinimumSize(new Dimension(400, 400));
          public static void main(String [] args) {
           JDialog.setDefaultLookAndFeelDecorated(true); // Works with JDialog as well
           new RespectMinimumSize();