简体   繁体   English

JFrame隐藏窗口任务栏时最大化并设置未修饰

[英]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. 我在使用JFrame时遇到问题,当我将undecorated = true设置为最大化时,它将JFrame变为全屏模式,从而隐藏了Windows任务栏。 Is there any way to work around it without set undecorated = false ? 没有设置undecorated = false方法是否可以解决?

在此处输入图片说明

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 产量

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM