我在使用 JFrame
时遇到问题,当我设置 undecorated = true
并且它最大化时,它会将 JFrame
变为全屏模式,隐藏 Windows 任务栏。有什么方法可以在不设置 undecorated = false
的情况下解决这个问题吗?
最佳答案
替代解决方法
// 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);
输出
关于java - JFrame 最大化时隐藏窗口任务栏并设置未装饰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48218497/