クライアント サーバー アプリケーションがあり、クライアント側でスイングを使用しています。私のスイング クライアントには、1 つのメイン ウィンドウ (jframe) と、多数のパネル、ツールバー、およびメニューバーがあります。クライアントがglasssPaneを使用してサーバーからの応答を待っている間に、すべてのクライアントアクション/マウスイベントを削除したい(または単にグラブして何もしない)。ここに私が書いたコードがあります:
private final static MouseAdapter mouseAdapter = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
System.out.println("MouseClicked..!");
}
};
private static Cursor WAIT_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
private static Cursor DEFAULT_CURSOR = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
と
public static void startWaitCursor(JComponent comp)
{
MainWindow root = ((MainWindow) comp.getTopLevelAncestor());
root.getGlassPane().setCursor(WAIT_CURSOR);
root.getGlassPane().addMouseListener(mouseAdapter);
root.getGlassPane().setVisible(true);
}
public static void stopWaitCursor(JComponent comp)
{
MainWindow root = ((MainWindow) comp.getTopLevelAncestor());
root.getGlassPane().setCursor(DEFAULT_CURSOR);
root.getGlassPane().setVisible(false);
}
しかし、グラブ マウス イベントを管理できません。glassPane でのカーソルの変更は正常に機能していますが、mouseAdapter を追加できないか、glasssPane を最上位コンポーネントにすることができません。
何か案が?
ありがとう。