Java modal window with maximize button

后端 未结 3 2021
灰色年华
灰色年华 2021-01-02 06:26

How could I create a window which is modal and has a maximize button?
So is it possible to create a modal JFrame or create a JDialog with maxim

3条回答
  •  再見小時候
    2021-01-02 06:32

    On most look and feels, modal windows (such as JDialog) do not have a maximise button simply because they're not supposed to be maximised (or minimised) at all.

    It's possible with some tricks to add a maximise button, but it would be completly against the way JDialog is supposed to work. If you need a maximise button, the best solution would be using a JWindow or a JFrame instead of a JDialog. Those windows support maximisation and minimisation.


    WARNING: You shouldn't do that, no matter what.

    A trick to do this in JDialog:

    setUndecorated(true);
    getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    

提交回复
热议问题