开发者

How to disable the minimize button in JFrame?

Can I disable the minimize button in JFrame?

I have already tried setUndecorated() and setResizable() but both did not work.

I'm trying to add images to a panel at a random location (which works) but when the JFrame is minimized by clicking at the minimize button (not when frame minimi开发者_开发技巧zes by clicking the background window) images assemble at the top in a row.

Can someone help?

Thanks!


If you also want to disable the maximize button then you can use a JDialog instead of a JFrame... as far as I know you cannot disable the minimize button in a JFrame. JDialog only has a close button. Hope this helps


i m trying to add imags to a panel at a random location which i m able to do) bt wen frame is minimized by clicking at the minimize button (not wen frame minimizes by clicking at the background window) images assemble at the top in a row.

Well, it sounds like you are adding labels to a panel and using the setLocation() method to position the labels.

The problem is that by default a JPanel uses a FlowLayout so whenever you do anything to the frame like minimize, maximize, iconify or resize the frame the layout manger is invoked and the labels are arranged according the the rules of the layout manager.

If your requirement is to have random positioning, then you need to use a "null layout".

Read the section from the Swing tutorial that explains how Absolute Positioning works for more information and a working example.


Use JDialog instead of JFrame it has only the Close button on the top.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜