user7196232
user7196232

Reputation:

Maximize frame and deactivate resizing

I want a frame that is maximized and after that I want to block resizing. For that I wrote the following Code:

public PaintingWindow() {
    initComponents();
    this.setExtendedState(MAXIMIZED_BOTH);
    this.setResizable(false);
}

The problem: The window isn't maximized any more if I add the setResizeable(false). Without it it is working.

How can I evade it? Thanks for all answers!

Upvotes: 1

Views: 208

Answers (1)

Ulug Toprak
Ulug Toprak

Reputation: 1222

I had a similar issue with JFrame i was able to solve it by frame.setVisible(true); before frame.setResizable(false);

JFrame frame = new JFrame("MyFrame");
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setSize(screenSize);
frame.setVisible(true); 
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

Upvotes: 2

Related Questions