ほとんどのデスクトップ環境では、1 つまたは複数のアクション バーがあり、場合によってはウィンドウがドッキングされています。
最大化されたウィンドウは、画面の横にあるこれらのさまざまなものによって使用されていないすべてのスペースを使用します。それが私が「利用可能なスペース」と呼んでいるものです
利用可能なスペースを検出し、可能であれば発生する可能性のある変更をリッスンする Java API はありますか?
基本的な考え方は、次のように、画面デバイスへの参照を取得し、画面の境界から画面のはめ込みを差し引くことです。
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
Rectangle bounds = new Rectangle(0, 0, 0, 0);
if (gd != null) {
GraphicsConfiguration gc = gd.getDefaultConfiguration();
bounds = gc.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
bounds.x += insets.left;
bounds.y += insets.top;
bounds.width -= (insets.left + insets.right);
bounds.height -= (insets.top + insets.bottom);
}
次に、実際に必要な画面デバイスを決定することが次の問題になります。この例では、デフォルトの画面を使用しています;)