1

はい、いくつかの質問が近づいています:)

Java にはバグがあります (2011 年から存在し、報告されていますが、それを修正する努力もされていないようです - VM のネイティブ側で処理する必要があります)

つまり、「装飾されていない」ウィンドウ、または PLAF ルック アンド フィールで描画されたウィンドウを最大化すると、ウィンドウのタスクバーが隠れてしまいます。細かい -必要な場合は望ましいが、タスクバーを最大化したウィンドウがそれをカバーしたい場合。「常に一番上」のプロパティを設定しても違いはありません。

はい、ウィンドウのサイズを変更できますが、タスクバーがどこにあるか、または画面のサイズからタスクバーを引いたサイズを知る必要があります-その方法を知っていますか?

それが行われている場合は、タスクバーのない画面で最大化していることを知る必要があります。マルチモニター仮想デスクトップの場合...

何か案は :)

4

2 に答える 2

5

はい、ウィンドウのサイズを変更できますが、タスクバーがどこにあるか、または画面のサイズからタスクバーを引いたサイズを知る必要があります-その方法を知っていますか?

はい:

1. 使用しているグラフィック デバイスを調べます (pPointが探している画面の 1 つであると仮定します)。

GraphicsConfiguration graphicsConfiguration = null;
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
    if (gd.getDefaultConfiguration().getBounds().contains(p)) {
        graphicsConfiguration = gd.getDefaultConfiguration();
        break;
    }
}

2. 画面の境界を確認します (一部の境界の位置は、複数の画面では負になることに注意してください。たとえば、メイン画面の左側にセカンダリ画面がある場合など)、画面サイズと、通常はタスクバーやその他のグラフィック アーティファクトである画面:

Rectangle screenBounds = graphicsConfiguration.getBounds();
Dimension screenSize = screenBounds.getSize();
Insets screenInsets = Toolkit.getDefaultToolkit()
     .getScreenInsets(graphicsConfiguration);
于 2012-06-26T19:15:02.077 に答える
2

ありがとう

ウィンドウがシステムによって最大化された直後に呼び出される上記のコードを次に示します。タスクバーをチェックし、それに応じてウィンドウのサイズを変更します。

Javaに関する限り、setBoundsはウィンドウを「最大化解除」するため、「getExtendedState()」は最大化されていない状態で返され、独自のフラグを維持する必要があることに注意してください。また、最後に最大化されたウィンドウ サイズをキャッシュする必要があるため、後でウィンドウを復元する場所がわかります。面倒ですが、機能します。

Rectangle bounds;
Rectangle fbounds = frame.getBounds();
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();

// as system maximized this at this point we test the center of the window
// as it should be on the proper screen.
Point p = new Point(fbounds.x + (fbounds.width/2),fbounds.y + (fbounds.height/2));
GraphicsConfiguration graphicsConfiguration = null;
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices())
{
    if (gd.getDefaultConfiguration().getBounds().contains(p)) {
        graphicsConfiguration = gd.getDefaultConfiguration();
        break;
    }
}
if(graphicsConfiguration != null)
{
    bounds = graphicsConfiguration.getBounds();
    Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfiguration);

    bounds.x += screenInsets.left;
    bounds.y += screenInsets.top;
    bounds.height -= screenInsets.bottom;
    bounds.width -= screenInsets.right;
} else {
    bounds = env.getMaximumWindowBounds();
}
if(fbounds.equals(bounds)) {
    bounds.height -= 1;
}
frame.setBounds(bounds);
于 2012-06-27T17:04:40.823 に答える