I'm writing a sketch in Processing and I'm curious how I can get the position of the OS's window that the sketch lives in. If I use getPosition()
(part of java.awt
) I only get the position of the viewport within the window.
2699 次
1 に答える
2
getLocationOnScreen()
から継承したものを使用できますが、最初java.awt.Component
にアプレットを確認する必要があります。isShowing()
void draw(){
if(frame.isShowing()) println(frame.getLocationOnScreen());
}
またはもう少しグラフィカル:
void draw(){
if(frame.isShowing()) {
java.awt.Point pt = frame.getLocationOnScreen();
background(255);
rectMode(CENTER);
rect(map(pt.x,0,displayWidth,0,width),//use screenWidth instead of displayWidth in Processing 1.5.1 or older
map(pt.y,0,displayHeight,0,height),//use screenHeight instead of displayHeight in Processing 1.5.1 or older
10,10);
}
}
どこ
Frame frame = ( (PSurfaceAWT.SmoothCanvas) ((PSurfaceAWT)surface).getNative()).getFrame();
P2D
(またはこの回答FX2D
をチェックするなどの他のレンダラーについて)
于 2012-12-16T12:25:48.177 に答える