利用可能なすべてのモニターのソリューションが同じである場合、答えてください。
AWTの場合:
すべてのコントロールには getMonitor() メソッドがあり、そこから画面位置の取得を次のように計算できます。
Monitor widgetMonitor = mTextWidget.getMonitor();
Rectangle monitorRect = widgetMonitor.getBounds();
if(monitorRect.x < 0){
// shown in left monitor, starting from the main monitor
}
if(monitorRect.x > monitorRect.width){
// shown in right monitor, starting from the main monitor
}
SWTの場合:
それは私の元のコードのほんの一部です。戻り値が null でないかどうか、次のように尋ねる必要があります。
int monitorWidth = 0;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screenDevices = ge.getScreenDevices();
if(screenDevices.length > 0){
monitorWidth = screenDevices[0].getDisplayMode().getWidth();
}
Point ownerLocationOnScreen = owner.getLocationOnScreen();
int screenMovingX = 0;
if(ownerLocationOnScreen.x < 0){
screenMovingX = -monitorWidth;
}
if(ownerLocationOnScreen.x > monitorWidth){
screenMovingX = monitorWidth;
}