Terai Atsuhiro 2022-07-07 (木) 14:16:48

final Dimension minDim = new Dimension(256, 100);
JFrame frame = new JFrame(){
  public void validate(){
    Rectangle rect = getBounds();
    if(minDim.width>rect.width || minDim.height>rect.height){
      int mw = ((minDim.width>rect.width)?minDim.width:rect.width);
      int mh = ((minDim.height>rect.height)?minDim.height:rect.height);
      setBounds(rect.x, rect.y, mw, mh);
    }
    super.validate();
  }
};
final int mw = 256;
final int mh = 100;
final JFrame frame = new JFrame();
frame.addComponentListener(new ComponentAdapter(){
  public void componentResized(ComponentEvent e){
    int fw = frame.getSize().width;
    int fh = frame.getSize().height;
    frame.setSize((mw>fw)?mw:fw, (mh>fh)?mh:fh);
  }
});