【问题标题】:How can I prevent a Jframe from overlapping with taskbar in Windows 8.1?如何防止 Jframe 与 Windows 8.1 中的任务栏重叠?
【发布时间】:2014-05-03 01:09:20
【问题描述】:

我需要在启动时将 Jframe 设置为全屏,但是当我这样做时,它会与任务栏重叠。

我看了这篇文章:

Setting a JFrame without overlapping with taskbar

但我仍然无法在 Windows 8.1 上让 Jframe 全尺寸不重叠任务栏。

我的主 Jframe 的构造函数如下所示:

public Principal(Conexion c) throws SQLException {
    initComponents();
    GraphicsConfiguration config = getGraphicsConfiguration();
    Rectangle usableBounds = SunGraphicsEnvironment.getUsableBounds(config.getDevice());
    setMaximizedBounds(usableBounds);
    setExtendedState(MAXIMIZED_BOTH);
}

这个问题有解决办法吗?

【问题讨论】:

  • 为了尽快获得更好的帮助,请发布MCVE(最小完整且可验证的示例)。删除了 Netbeans 标记,因为您将在 Eclipse 中以完全相同的方式执行此操作(即“编写 Java 代码”)。
  • 先删除setMaximizedBounds
  • 在 Windows 7 上快速玩了一下,并使用 setMaximizedBoundssetExtendedState 做一些奇怪的事情。就个人而言,我会避免它 (setMaximizedBounds)

标签: java swing jframe fullscreen taskbar


【解决方案1】:

查看以下代码可能会对您有所帮助

public NewJFrame() {
    initComponents();
    this.setResizable(true);
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);

}

如果你使用 netbeans,那么在 Resizable 上勾选 true

【讨论】:

    猜你喜欢
    • 2013-11-07
    • 1970-01-01
    • 2017-07-24
    • 2017-03-08
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多