1

起動時にOSX(https://sourceforge.net/projects/ipscan/)でオープンソースJavaアプリケーション「AngryIPScanner」の画面位置を修正する必要があります。

アプリケーションを起動してセカンダリモニター(ミラーリングされていない)の拡張スペースに移動し、次の2つのいずれかを実行する場合:1)アプリを実行している状態でセカンダリモニターのプラグを抜くか、2)セカンダリモニターにあるときにアプリを終了しますモニター。

2番目のモニターのプラグを抜いてからアプリを起動すると、アプリは、プラグが差し込まれていなくても、画面が読み込まれ、現在は存在しない2番目のモニターに配置されます。

画面をメイン画面領域に戻すには、2番目のモニターを接続して、メイン画面に戻す必要があります。次に、2番目のモニターのプラグを抜いて、問題はありません。

アプリの起動時に、アプリは現在の画面サイズと以前の画面サイズを確認する必要があると思います。変更されている場合は、画面を10,10の位置の近くに配置して、メインのアクティブな画面に表示されるようにします。

Stack Overflowで検索すると、現在の画面情報は次のように表示されます。

GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();

これをファイルに保存し、以前のデータを現在のデータと呼び戻し/比較するにはどうすればよいですか?データが変更されている場合は、アプリケーションのウィンドウを10,10の場所に移動しますか?

私はOSXでiOSとRubyを書いている初心者ですが、Javaを使ったことがありません。私はこのプログラムが大好きですが、このバグは私を殺し、コードに積極的に取り組んでいる人はいないようです。

誰か助けたいですか?

ところで...これはAngryIPScannerWebサイトのバグ84です。

たぶん誰かが私がCLIから次のコードスニペットを実行する方法を説明できますか?

int resolution =Toolkit.getDefaultToolkit().getScreenResolution();
System.out.println(resolution);

ありがとう、

パダパ

4

2 に答える 2

2

何かのようなもの:

public class ShowMeTheScreenSize {

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                System.out.println("VirtualBounds = " + getVirtualBounds());

                for (int index = 0; index < getScreenDeviceCount(); index++) {
                    System.out.println("[" + index + "] Device bounds = " + getScreenDeviceBounds(index));
                }

                System.exit(0);
            }
        });
    }

    public static int getScreenDeviceCount() {

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

        return ge.getScreenDevices().length;

    }

    public static Rectangle getVirtualBounds() {

        Rectangle bounds = new Rectangle(0, 0, 0, 0);

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice lstGDs[] = ge.getScreenDevices();
        for (GraphicsDevice gd : lstGDs) {

            bounds.add(gd.getDefaultConfiguration().getBounds());

        }

        return bounds;

    }

    public static Rectangle getScreenDeviceBounds(int index) {

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice lstGDs[] = ge.getScreenDevices();

        return lstGDs[index].getDefaultConfiguration().getBounds();

    }
}

どの出力...

VirtualBounds = java.awt.Rectangle[x=0,y=0,width=3840,height=1200]
[0] Device bounds = java.awt.Rectangle[x=0,y=0,width=1920,height=1200]
[1] Device bounds = java.awt.Rectangle[x=1920,y=0,width=1920,height=1200]

私のマシンで

于 2012-12-11T02:09:26.960 に答える
1

ここで説明するように、Mac OS Xは、表示されているウィンドウが画面外に移動するのを防ぐのに役立ちます。1つの方法は、ウィンドウを禁止された場所に移動するコマンドです。これにより、ウィンドウが強制的に到達します。

polo.setLocation(Short.MIN_VALUE, Short.MIN_VALUE);
于 2012-12-11T03:14:31.047 に答える