开发者

How can I set the MaximumSize on a JDialog?

开发者 https://www.devze.com 2023-03-20 14:59 出处:网络
I tried to do something like: public static void main(final St开发者_Go百科ring[] args) { JDialog dialog = new JDialog();

I tried to do something like:

  public static void main(final St开发者_Go百科ring[] args)
  {
    JDialog dialog = new JDialog();

    dialog.add(new JButton("XXXXXXX"));
    dialog.setVisible(true);
    dialog.setSize(new Dimension(100,100));

    dialog.setMaximumSize(new Dimension(100,100));
  }

But I can still resize this dialog above the 100,100 limit I set. Any suggestions? Thanks!


Try this:

addComponentListener(new java.awt.event.ComponentAdapter()
{
    public void componentResized(ComponentEvent event)
    {
        setSize(100,100);
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消