William
William

Reputation: 497

JFrame hiding windows taskbar when maximized and sets undecorated

I'm having an issue with JFrame, when i set my undecorated = true, and it's maximized, it turns the JFrame to full screen mode, hiding the Windows taskbar. Is there any way to work around it without set undecorated = false?

enter image description here

Upvotes: 0

Views: 760

Answers (1)

Digvijaysinh Gohil
Digvijaysinh Gohil

Reputation: 1475

Alternative workaround

// Gets the screen resolution
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// Gets the width and height
double width = screenSize.getWidth();
double height = screenSize.getHeight();
// Subtract height of taskbar from height in my case 50 
frame.setSize((int)width, (int)height - 50);
frame.setLocationRelativeTo(null);  // Set frame at center of the screen
frame.setUndecorated(true); // Removes title bar
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

output

enter image description here

Upvotes: 1

Related Questions