Help us understand the problem. What is going on with this article?

Processing 3.0で実行中にwindowのsizeの変更やタイトルバーを非表示にする方法

More than 3 years have passed since last update.

processing3.0になってvoid setup(){}内でしかsize()の設定ができなくなったり、windowのタイトルバーを非表示にするframe.setUndecorated(true)がそのまま書くと「fullscreen()を使え」的なerrorが出るから
processing2.0の時に書いたコードが使用できなくなってる... orz

そこでマルチディスプレイにフルスクリーンサイズにしたりサイズをランダムに変更できるようにprocessing3.0仕様に書き換えたのがこれ

size_change.pde
import processing.awt.PSurfaceAWT;

void setup(){
  //windowサイズの初期化
 surface.setResizable(true); 
}

void draw(){
  background(#FFFFFF);

}
void keyPressed() {
  if ( (key == 'a')) {
    //smoothCanvas.getFrame()関連のメソッドを使えるようにする

    PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
    PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();

    smoothCanvas.getFrame().setAlwaysOnTop(true);
    smoothCanvas.getFrame().removeNotify();

    //タイトルバー非表示
    smoothCanvas.getFrame().setUndecorated(true);

    //マルチディスプレイ用にsetLocation(x,y);のパラメータのxをマイナスにする
    smoothCanvas.getFrame().setLocation(-1368, 0);
    smoothCanvas.getFrame().addNotify();

    // //window上で"左クリック+a"でフルスクリーンサイズ
    smoothCanvas.getFrame().setSize(1368,720);



}

 if ((keyPressed == true) && (key == 'b')){
    PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
    PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
    smoothCanvas.getFrame().setAlwaysOnTop(true);
    smoothCanvas.getFrame().removeNotify();
    smoothCanvas.getFrame().setUndecorated(true);
    smoothCanvas.getFrame().setLocation(-1368, 0);
    smoothCanvas.getFrame().addNotify();

    //window上で"左クリック+b"でランダムにwindowサイズが変更する
    smoothCanvas.getFrame().setSize(round(random(100, 500)), round(random(100, 500)));


  }
 }

左クリック+Aでフルスクリーン
左クリック+Bでランダムにサイズ変更できます

ちなみにマルチディスプレイを使わないでPC単体の場合は

smoothCanvas.getFrame().setLocation(-1368, 0); 
のところを
smoothCanvas.getFrame().setLocation(0, 0); 
とパラメーターを変えて下さい

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした