<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with setvisible() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=setvisible%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:31:02 +0000</pubDate>
         <description>Tagged with setvisible() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedsetvisible%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>setVisible(false) cause myButtons to stop working</title>
      <link>https://forum.processing.org/two/discussion/27958/setvisible-false-cause-mybuttons-to-stop-working</link>
      <pubDate>Sat, 12 May 2018 13:01:52 +0000</pubDate>
      <dc:creator>Cluric</dc:creator>
      <guid isPermaLink="false">27958@/two/discussions</guid>
      <description><![CDATA[<p>Good aftenoon.
First, sorry for my poor english !</p>

<p>I have an issue with my ControlP5 Buttons. I'm using a "Window" class, wich contains (among other stuff) an arrayList of Button. When i change the current window, I want to hide the previous buttons and show the buttons of the new window.
Of course i'm using .setVisible(boolean), but apparently, doing so cause my "new" buttons to not work properly.</p>

<p>Here is the location in the code where I found the problem:
<code>for(i = 0; i &lt; listeBoutons.size(); i++){ listeBoutons.get(i).setVisible(false); }</code></p>

<p><code>for(i = 0; i &lt; fenetreActive.boutons.size(); i++){ fenetreActive.boutons.get(i).setVisible(true); }</code></p>

<p>"listeBoutons" is my ArrayList which contains ALL the Buttons of my application (I need this elsewhere). 
I'm lazzy, so I basically try to make all the buttons invisible THEN using fenetreActive (which is my "window") acces to the Buttons of the new windows and make them visible. It's a harsh way to proceed but seems to work : all my button have the correct .isVisible() state (i've check by printing some tracks with .getInfo() )</p>

<p>If I use JUST the second loop, as expected when I change the window, new buttons appears and the "old" stay on the screen. Every single one of them work PERFECTLY fine in that case.
But, if i add the first loop, in charge of "removing" the old buttons from my screen... they do disapear... but the new ones are not functional. Weird thing is : the new buttons appear on screen (with correct text, size etc...) but won't react to any Event.</p>

<p>I'm a bit lost. My program is working as if, by hidding my Buttons, I had disabled them all.</p>

<p>Here is a sample of my controlEvent function :</p>

<p><code>void controlEvent(ControlEvent event){
    println("Event received from" + event.getName());
    if(event.getName().equals("Begin")){
       changeWindow("Menus");
    }
    else if(event.getName().equals("OtherName")){
       println("something");
    }
    //Etc...
    }
}</code></p>

<p>I'm not used to work with ControlP5, so my understanding of the problem may be wronged. It would be great if someone could explain to me what the problem really is !</p>
]]></description>
   </item>
   <item>
      <title>Strange overlapping of sprites with Sprite library, what's wrong?</title>
      <link>https://forum.processing.org/two/discussion/25637/strange-overlapping-of-sprites-with-sprite-library-what-s-wrong</link>
      <pubDate>Tue, 19 Dec 2017 07:00:31 +0000</pubDate>
      <dc:creator>Paraf0x</dc:creator>
      <guid isPermaLink="false">25637@/two/discussions</guid>
      <description><![CDATA[<p>Hello and good day.<br />
I work with the Sprite library by Peter Lager.<br />
My current project is a 2D platformer and I got a rly strange problem but I cant't find the exact source.<br />
I restricted the problem of the overlapping Sprites to the WorldManager class in the <code>void registerWorld(int index)</code> function.<br />
I use  <code>S4P.updateSprites(sw.getElapsedTime()); S4P.drawSprites();</code><br />
to display the sprites.<br />
It seems that all 3 worlds get registered by S4P at the same time.<br />
The content of the 3 worldfiles I got here is like that,</p>

<pre><code>OOOOOOOOOO

O________O

OZZZZZZZZO
</code></pre>

<p><img src="https://i.imgur.com/Y18MQdf.png" alt="" /></p>

<pre><code>//GameProject_Disconnect
import sprites.*;
import sprites.maths.*;
import sprites.utils.*;
import java.util.*;
import java.lang.*;

StopWatch sw;
WorldManager wm;

void setup() {
  size(500, 500);
  sw = new StopWatch();
  wm = new WorldManager(this);
}


void draw() {
  background(0);
  S4P.updateSprites(sw.getElapsedTime());
  S4P.drawSprites();
}

//WorldManager 

class WorldManager {
  FileManager fm;
  WorldTranslater wt;
  ArrayList&lt;World&gt; worlds;

  WorldManager(PApplet _pa) {
    fm = new FileManager();
    wt = new WorldTranslater(_pa);
    initWorlds();
    registerWorld(0);
  }


  void registerWorld(int index) {
    Sprite[][] tempW = worlds.get(index).getWorldMap();
    for (int i=0; i &lt; 5; i++) {
      for (int j=0; j &lt; 10; j++) {
        S4P.registerSprite(tempW[i][j]);
      }
    }
  }


  private void initWorlds() {
    worlds = new ArrayList&lt;World&gt;();
    for (int i=0; i &lt; fm.getNumberOfWorlds(); i++) {
      World tempWorld = new World(
        fm.getFileContent(i), 
        wt.translateWorld(fm.getFileContent(i)), 
        fm.getTrimmedFilename(i), 
        fm.getWorldPath(i));
      worlds.add(new World());
      worlds.set(i, tempWorld);
    }
    println("Worlds successful loaded!");
  }
}

//FileManager

class FileManager {
  private String worldPath; // Path of the world files. 
  private String[] rawFilenames; // Filenames with prefix and suffix.
  private String[] trimmedFilenames; // Filenames without prefix and suffix.
  private ArrayList&lt;String[]&gt; fileContent; // Save the file content here. 
  private int numberOfFiles; // Number of worlds found.

  FileManager() {
    worldPath = new String(sketchPath() + "/Worlds/");
    readFileDirectory();
    numberOfFiles = rawFilenames.length;
    trimFilenames();
    fileContent  = new ArrayList&lt;String[]&gt;();
    initFileContent();
  }
  // Give me the content of one file chosen by index.
  String[] getFileContent(int index) {
    return fileContent.get(index);
  }

  int getNumberOfWorlds() {
    return numberOfFiles;
  }

  String getWorldPath(int index) {
    return new String(worldPath + rawFilenames[index]);
  }

  String getRawFilename(int index) {
    return rawFilenames[index];
  }

  String getTrimmedFilename(int index) {
    return trimmedFilenames[index];
  }

  private void initFileContent() {
    for (int i=0; i &lt; numberOfFiles; i++) {
      fileContent.add(new String[0]);
      fileContent.set(i, parseFile(rawFilenames[i]));
    }
  }

  // Get all filenames from the world directory.
  private void readFileDirectory() {
    rawFilenames = getFilenames(worldPath);
  }
  // Cut the prefix and suffix off.
  private void trimFilenames() {
    trimmedFilenames = cutFilenames(getFilenames(worldPath));
  }

  // Reade the content of the file.
  private String[] parseFile(String filename) {
    BufferedReader reader = createReader(worldPath + filename);
    String line = null;
    String[] tempWorld = new String[5];
    int counter = 0;
    try {
      while ((line = reader.readLine()) != null) {
        tempWorld[counter] = line;
        counter++;
      }
      reader.close();
    } 
    catch (IOException e) {
      e.printStackTrace();
    }
    return tempWorld;
  }

  // Return all the raw filenames in a directory as an array of Strings.
  private String[] getFilenames(String dir) { 
    File file = new File(dir);
    if (file.isDirectory()) { 
      String[] names = file.list();
      return names;
    } else {
      // If it's not a directory.
      println("ERROR: There is no worlds directory!");
      return null;
    }
  }

  // Delete the prefix and the suffix of the filename.
  private String[] cutFilenames(String[] filenames) {
    String[] names = filenames;
    for (int i=0; i &lt; names.length; i++) { 
      names[i] = names[i].substring(2, names[i].length()-4); // -4 for the ".txt" suffix.
    }
    return names;
  }
}

//WorldTranslater

class WorldTranslater {
  PApplet pa;
  // Agreements for the height and width of a world.
  final int mapWidth = 10;
  final int mapHeight = 5;

  private String[] crypticWorld;
  private Sprite[][] translatedWorld;

  final String wall = "Sprites/Wall.png";
  final String background = "Sprites/Background.png";
  final String ground = "Sprites/Ground.png";
  final String platform = "Sprites/Platform2.png";
  final String nothing = "Sprites/Nothing.png";

  final int viewDistance = 1; // The higher the number, the closer is the picture in the foreground.

  WorldTranslater(PApplet _pa) {
    pa = _pa;
    crypticWorld    = null;
    translatedWorld = new Sprite[mapHeight][mapWidth];
  }
  // Give me the fancy sprite array from this cryptical String array plz.
  public Sprite[][] translateWorld(String[] cw) {
    crypticWorld = cw;
    translateCWorld();
    return translatedWorld;
  }

  // Translate the crypticWorld to a world with fancy sprites.
  private void translateCWorld() {
    Sprite sp; 
    for (int i=0; i &lt; mapHeight; i++) {
      for (int j=0; j &lt; mapWidth; j++) {
        sp = distinguishSprite(crypticWorld[i].charAt(j));
        sp.setPos(new Vector2D(sp.getWidth()*j, sp.getHeight()*i));
        translatedWorld[i][j] = sp;
      }
    }
  }

  // Check which token is which sprite.
  private Sprite distinguishSprite(char c) {
    if (c == 'O') {
      return new Sprite(pa, wall, viewDistance);
    } else if (c == 'X') {
      return new Sprite(pa, background, viewDistance);
    } else if (c == 'Z') {
      return new Sprite(pa, ground, viewDistance);
    } else if (c == '_') {
      return new Sprite(pa, platform, viewDistance);
    } else if (c == ' ') {
      return new Sprite(pa, nothing, viewDistance);
    }
    println("ERROR: Invalid token");
    return null;
  }
};

//WorldObjekt

class World {
  private String[] rawWorldMap;
  private Sprite[][] worldMap;
  private String name;
  private String path;

  World() {
    rawWorldMap = null;
    worldMap = null;
    name = null;
    path = null;
  }

  World(String[] _rawWorldMap, Sprite[][] _worldMap, String _name, String _path) {
    rawWorldMap = _rawWorldMap;
    worldMap = _worldMap;
    name = _name;
    path = _path;
  }

  public Sprite[][] getWorldMap() {
    return worldMap;
  }

  String[] getRawWorldMap() {
    return rawWorldMap;
  }

  String getName() {
    return name;
  }

  String getPath() {
    return path;
  }
};
</code></pre>
]]></description>
   </item>
   <item>
      <title>Check visible state</title>
      <link>https://forum.processing.org/two/discussion/22433/check-visible-state</link>
      <pubDate>Sun, 07 May 2017 08:26:15 +0000</pubDate>
      <dc:creator>Fenestron</dc:creator>
      <guid isPermaLink="false">22433@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to check the visibility state?</p>

<p>For example, I have this code:</p>

<pre lang="java">
void draw() {
  if (!isVisible()) {
    surface.setVisible(true);
  }
}

/**
 * <a href="/two/profile/return">@return</a> true if visible, false otherwise
 */
boolean isVisible() {
  
}
</pre>

<p>What should the <code>isVisible()</code> method look like?</p>
]]></description>
   </item>
   <item>
      <title>surface.setVisible() on different renderers</title>
      <link>https://forum.processing.org/two/discussion/21847/surface-setvisible-on-different-renderers</link>
      <pubDate>Thu, 06 Apr 2017 01:04:54 +0000</pubDate>
      <dc:creator>linuxman</dc:creator>
      <guid isPermaLink="false">21847@/two/discussions</guid>
      <description><![CDATA[<p>My idea is to have a fullscreen sketch controlled by a "allwaysontop" G4P GWindow. Sometimes there won't be 2 screens and the main window and GWindow will be on the same screen,  and sometimes I will need to access the desktop to drop files. I want to turn the fullscreen window invisible.</p>

<pre><code>int nFrame = 0;
boolean visible = true;

void setup() {
  size(300, 200);
}

void draw() {
  background(255);
  nFrame++;
  println(nFrame);
  if(nFrame % 60 == 0) {
    surface.setVisible(visible = !visible);
  }
}
</code></pre>

<p>This test shows that setVisible works as expected with the default renderer. On Linux, the invisible window behave as a minimized application. With P2D, P3D and FX2D, frame count stops the moment the window is invisible. The behavior is erratic: sometimes it looks minimized, later it disappears. If it looks minimized you can click on the indicator to "turn it on". Usually crashes if you try setVisible(true) enough times. 
For now I will continue with JAVA2D, but P2D has better fullscreen support and speed. Any idea?</p>
]]></description>
   </item>
   <item>
      <title>image a P3D PGraphics buffer in/over a 2D "main window"</title>
      <link>https://forum.processing.org/two/discussion/22238/image-a-p3d-pgraphics-buffer-in-over-a-2d-main-window</link>
      <pubDate>Thu, 27 Apr 2017 09:53:07 +0000</pubDate>
      <dc:creator>mala</dc:creator>
      <guid isPermaLink="false">22238@/two/discussions</guid>
      <description><![CDATA[<p>This is driving me slightly mad... I have so far tried using a second applet to achieve the same but the results aren't great, as the second window has a border, can be dragged about etc. Whilst I would prefer the 3D "view" to just look like part of the rest of my 2D GUI.</p>

<p>I'm now trying to use a P3D offscreen buffer and then using image(), draw that to the 2D sketch... but I'm stuck with an error asking for size(). But I have no idea where/how I should be supplying this size() value, if I put it in settings() it applies to the main 2D sketch which I don't want.
Can anyone help please?!</p>

<p>simple version code :</p>

<pre><code>    PGraphics p3d;

    DBox myBox;
    void settings() {
      //size(400,400,P3D);
    }

    void setup() {
      size(800, 800);

      p3d = createGraphics(400, 400, P3D);
      p3d.beginDraw();
      p3d.noStroke();
      myBox = new DBox();
      p3d.background(128);
      myBox.render(this.g);
      p3d.endDraw();
    }

    void draw() {
      background(100);
      fill(255, 0, 0);
      ellipse(400, 400, 650, 650);
      image(p3d, 200, 200);
    }

    class DBox {

      DBox() {
      }

      void render(PGraphics pg) {
        pg.fill(0, 0, 255);
        pg.box(40);
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Exit sketch but preserve parent process</title>
      <link>https://forum.processing.org/two/discussion/13467/exit-sketch-but-preserve-parent-process</link>
      <pubDate>Tue, 10 Nov 2015 11:54:38 +0000</pubDate>
      <dc:creator>munkey</dc:creator>
      <guid isPermaLink="false">13467@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
Im new to processing and I have just got started using it with java. At the minute I have a java swing application which spawns a separate sketch window using PApplet.runSketch(). When the window is closed either by pressing escape, pressing the X or calling .exit() on the PApplet, the entire program including the swing main program closes with it.</p>

<p>Is there a way I can make it so when sketch is closed it does not kill off my entire program and just closes the sketch window?</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Indoor Navigation</title>
      <link>https://forum.processing.org/two/discussion/20609/indoor-navigation</link>
      <pubDate>Thu, 02 Feb 2017 15:51:09 +0000</pubDate>
      <dc:creator>M_Rigby</dc:creator>
      <guid isPermaLink="false">20609@/two/discussions</guid>
      <description><![CDATA[<p>Hello.</p>

<p>I asked a similar question to this a few days ago, please see:
<a rel="nofollow" href="https://forum.processing.org/two/discussion/20564/indoor-navigation-using-rfid-technology#latest">https://forum.processing.org/two/discussion/20564/indoor-navigation-using-rfid-technology#latest</a> - but the spec of my application has now changed.</p>

<p>I am new to Processing and a beginner when it comes to programming in general so apologies for my lack of correct vocabulary when it comes to explaining things.</p>

<p>I am trying to create an application which gives the user a top-down view of a hospital building plan and allows them to choose, from a drop down menu, where they would like to go within the hospital. Each location has predefined co-ordinates and when the user chooses that location, a line will be draw from their current location to the location they have chosen. Obviously the line that is draw cannot be straight from point to point, as that would mean the line would be cutting through 'rooms' and 'walls' etc. The lines would have to follow the 'corridors' of the hospital.</p>

<p>Is this possible in Processing or should I be considering different Android development programs?</p>

<p>Any help/tutorials to set me on my way with the code will be much appreciated.</p>
]]></description>
   </item>
   <item>
      <title>setVisible</title>
      <link>https://forum.processing.org/two/discussion/18965/setvisible</link>
      <pubDate>Wed, 09 Nov 2016 23:44:57 +0000</pubDate>
      <dc:creator>Schievelbein</dc:creator>
      <guid isPermaLink="false">18965@/two/discussions</guid>
      <description><![CDATA[<p>I have the following program creates cubes and changes them.
I am trying to make the cubes invisible until they are activated in updatecells, but I want them part of my overall VBO that is created during setup to help performance.
I have tried putting the "setVisible( false )" code in many places, but cannot seem to get it to work.  I have tried making each side of the cubes invisible separately, and that did not work either.  Any suggestions are welcome.</p>

<pre><code>import processing.opengl.*;
import peasy.*;

PeasyCam cam;
PShape world;
float CS = .25;
int CPS = 10;
int totalcubes = CPS*CPS*CPS;
float offset = CPS/2;
color colors[]= {0x88FF0000,0x8800FF00,0x880000FF,0x88FFFF00,0x8800FFFF,0x88FF00FF};
int dice_orientations[][][]={{{1,6,2,4,5,3},{1,6,4,5,3,2},{1,6,5,3,2,4},{1,6,3,2,4,5}},
                             {{6,1,2,3,5,4},{6,1,3,5,4,2},{6,1,5,4,2,3},{1,6,4,2,3,5}},
                             {{3,4,5,6,2,1},{3,4,6,2,1,5},{3,4,2,1,5,6},{3,4,1,5,6,2}},
                             {{4,3,1,2,6,5},{4,3,2,6,5,1},{4,3,6,5,1,2},{4,3,5,1,2,6}},
                             {{2,5,4,6,3,1},{2,5,6,3,1,4},{2,5,3,1,4,6},{2,5,1,4,6,3}},
                             {{5,2,1,3,6,4},{5,2,3,6,4,1},{5,2,6,4,1,3},{5,2,4,1,3,6}}};
int rcolor; 
void setup() { 
  size(2100,2100, P3D); 
  cam = new PeasyCam(this, 150*CPS);  
  noStroke(); 

  print("Making World   ");
  world = createShape(GROUP);      
  for (int i = 0; i &lt; CPS; i++) {
    for (int j = 0; j &lt; CPS; j++) {
      for (int k = 0; k &lt; CPS; k++) {
        MyCube cube = new MyCube(i - offset, j - offset, k - offset);
        world.addChild(cube.output);
        }}print("-");}
  println("   done");} // end setup

 void draw() { 
  background(127);
  scale(95); 
  shape(world, 0, 0); 
  updatecells();
} // end draw


 void updatecells(){
  PShape cube = world.getChild(int(random(totalcubes)));
  color sidecolor;    
  int tempfront = int(random(6));
  int temptop = int(random(4));
  int tempside = 0;

  for (int side=0; side &lt; 6; side++) {
    tempside=dice_orientations[tempfront][temptop][side]; 
    sidecolor=colors[tempside-1];
    for (int V=0; V &lt; 4; V++) {
      cube.setFill(side*4+V ,sidecolor);
     } // end V
   } // end side
 } // end updatecells 



// could just be a method, returning PShape    
class MyCube {
  PShape output;

  MyCube(float x, float y, float z) { // &lt;- new arguments
    int size = 1;
    output = createShape();
    output.translate(x, y, z); // &lt;- new tanslate
    output.beginShape(QUADS);
    output.fill(colors[0]);
    output.vertex(-CS, CS, CS);output.vertex( CS, CS, CS);output.vertex( CS,-CS, CS);output.vertex(-CS,-CS, CS);
    output.fill(colors[1]);
    output.vertex( CS, CS, CS);output.vertex( CS, CS,-CS);output.vertex( CS,-CS,-CS);output.vertex( CS,-CS, CS);
    output.fill(colors[2]); 
    output.vertex( CS, CS,-CS);output.vertex(-CS, CS,-CS);output.vertex(-CS,-CS,-CS);output.vertex( CS,-CS,-CS);
    output.fill(colors[3]);
    output.vertex(-CS, CS,-CS);output.vertex(-CS, CS, CS);output.vertex(-CS,-CS, CS);output.vertex(-CS,-CS,-CS);
    output.fill(colors[4]);
    output.vertex(-CS, CS,-CS);output.vertex( CS, CS,-CS);output.vertex( CS, CS, CS);output.vertex(-CS, CS, CS);
    output.fill(colors[5]); 
    output.vertex(-CS,-CS,-CS);output.vertex( CS,-CS,-CS);output.vertex( CS,-CS, CS);output.vertex(-CS,-CS, CS);
    output.setVisible( false );
    output.endShape(CLOSE);
  } // end constructor
}// end MyCube
</code></pre>
]]></description>
   </item>
   <item>
      <title>How To Create "Game Over"</title>
      <link>https://forum.processing.org/two/discussion/19380/how-to-create-game-over</link>
      <pubDate>Tue, 29 Nov 2016 04:46:13 +0000</pubDate>
      <dc:creator>lbrez16</dc:creator>
      <guid isPermaLink="false">19380@/two/discussions</guid>
      <description><![CDATA[<p>Hello! So I am creating a game similar to a snake game but with one individual shape moving instead of getting bigger. The issue with my code that I'm having is that when the icon hits the wall I can't figure out how to get it to be a full on Game Over where you have to press a button to restart the game. Below I have posted my code so any help that can be given is greatly appreciated!!</p>

<pre><code>Logo l;
int grid = 35;
PImage BH;
PImage SC;
PImage Rink;

PVector Cup;


void setup() {

  size(800, 422);
  l = new Logo();
  frameRate(8);
  pickLocation();
  BH = loadImage("BH.png");
  SC = loadImage("SC.png");
  Rink = loadImage("Rink.jpg");

}

void pickLocation() {
  int across = width/grid;
  int down = height/grid;
  Cup = new PVector(floor(random(across)), floor(random(down)));
  Cup.mult(grid);
}

void draw() {
  background(Rink);

  if (l.capture(Cup)) {
    pickLocation();
  }
  l.death();
  l.update();
  l.show();

  image(SC,Cup.x, Cup.y, grid, grid);
}

void keyPressed() {
  if (keyCode == UP) {
    l.dir(0, -1);
  } else if (keyCode == DOWN) {
    l.dir(0, 1);
  } else if (keyCode == RIGHT) {
    l.dir(1, 0);
  } else if (keyCode == LEFT) {
    l.dir(-1, 0);
  }
}
</code></pre>

<hr />

<p>Logo.pde</p>

<pre><code>class Logo {
  float x = 0;
  float y = 0;
  float xspeed = 1;
  float yspeed = 0;
  int total = 0;
  ArrayList&lt;PVector&gt; tail = new ArrayList&lt;PVector&gt;();

  Logo() {
  }

  boolean capture(PVector pos) {
    float d = dist(x, y, pos.x, pos.y);
    if (d &lt; 1) {
      return true;
    } else {
      return false;
    }
  }

  void dir(float x, float y) {
    xspeed = x;
    yspeed = y;
  }

  void death() {
    for (int i = 0; i &lt; tail.size(); i++) {
      PVector pos = tail.get(i);
      float d = dist(x, y, pos.x, pos.y);
      if (d &lt; 1) {
        println("starting over");
        total = 0;
        tail.clear();
      }
    }
  }

  void update() {
    if (total &gt; 0) {
      if (total == tail.size() &amp;&amp; !tail.isEmpty()) {
        tail.remove(0);
      }
      tail.add(new PVector(x, y));
    }

    x = x + xspeed*grid;
    y = y + yspeed*grid;

    x = constrain(x, 0, width-grid);
    y = constrain(y, 0, height-grid);
  }

  void show() {
    fill(255);
    for (PVector v : tail) {
      rect(v.x, v.y, grid, grid);
    }
    image(BH, x, y, grid, grid);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Bug in setVisible() capability.</title>
      <link>https://forum.processing.org/two/discussion/19053/bug-in-setvisible-capability</link>
      <pubDate>Tue, 15 Nov 2016 15:11:16 +0000</pubDate>
      <dc:creator>Schievelbein</dc:creator>
      <guid isPermaLink="false">19053@/two/discussions</guid>
      <description><![CDATA[<p>I have posted this in the Libraries section but i received no solution, so I am trying it here in the open area.</p>

<p>I have the following program creates cubes and changes them. I am trying to make the cubes invisible until they are activated in updatecells, but I need them part of my overall VBO that is created during setup to help performance. I have tried putting the "setVisible( false )" code in many places, but cannot seem to get it to work. I have tried making each side of the cubes invisible separately, and that did not work either. I need to start the program not seeing any of the cubes and then see the cubes that change as they change.  I have tried starting with nothing in the VBO and adding the cube as they change, but the performance is worse that writing everything separately without a VBO.  Any suggestions are welcome.</p>

<p>Below is the MFE that I stripped my code down to in order to show how the setVisible function is not working.</p>

<pre><code>import processing.opengl.*;
import peasy.*;

PeasyCam cam;
PShape world;
int CPS = 10;
int totalcubes = CPS*CPS*CPS;
int rcolor; 
float CS = .25;
float offset = CPS/2;
color colors[]= {0x88FF0000,0x8800FF00,0x880000FF,0x88FFFF00,0x8800FFFF,0x88FF00FF};
int orientation[][][]={{{1,6,2,4,5,3},{1,6,4,5,3,2},{1,6,5,3,2,4},{1,6,3,2,4,5}},
                       {{6,1,2,3,5,4},{6,1,3,5,4,2},{6,1,5,4,2,3},{1,6,4,2,3,5}},
                       {{2,5,4,6,3,1},{2,5,6,3,1,4},{2,5,3,1,4,6},{2,5,1,4,6,3}},  
                       {{4,3,1,2,6,5},{4,3,2,6,5,1},{4,3,6,5,1,2},{4,3,5,1,2,6}},
                       {{5,2,1,3,6,4},{5,2,3,6,4,1},{5,2,6,4,1,3},{5,2,4,1,3,6}},
                       {{3,4,5,6,2,1},{3,4,6,2,1,5},{3,4,2,1,5,6},{3,4,1,5,6,2}}};

void setup() { 
  size(2100,2100, P3D); 
  cam = new PeasyCam(this, 150*CPS);  
  noStroke(); 

  print("Making World   ");
  world = createShape(GROUP);      
  for (int i = 0; i &lt; CPS; i++) {
    for (int j = 0; j &lt; CPS; j++) {
      for (int k = 0; k &lt; CPS; k++) {
        MyCube cube = new MyCube(i - offset, j - offset, k - offset);
        world.addChild(cube.output);
        }}print("-");}
  println("   done");} // end setup

 void draw() { 
  background(127);
  scale(95);
  shape(world, 0, 0);
  UpdateCubes();
  } // end draw


void UpdateCubes(){
  PShape cube = world.getChild(int(random(totalcubes)));
  color sidecolor;    
  int tempfront = int(random(6));
  int temptop = int(random(4));
  int tempside = 0;

  for (int side=0; side &lt; 6; side++) {
    tempside=orientation[tempfront][temptop][side]; 
    sidecolor=colors[tempside-1];
    for (int V=0; V &lt; 4; V++) {
      cube.setStroke(side*4+V,sidecolor);
      cube.setFill(side*4+V,sidecolor);
      cube.setVisible( true ); 
     } // end V
   } // end side
} // end updatecells 


class MyCube {
  PShape output;

  MyCube(float x, float y, float z) { 
    output = createShape();
    output.translate(x, y, z);
    output.setVisible(false);
    output.beginShape(QUADS);
    output.fill(colors[0]);
    output.vertex(-CS, CS, CS);output.vertex( CS, CS, CS);output.vertex( CS,-CS, CS);output.vertex(-CS,-CS, CS);
    output.fill(colors[1]);
    output.vertex( CS, CS, CS);output.vertex( CS, CS,-CS);output.vertex( CS,-CS,-CS);output.vertex( CS,-CS, CS);
    output.fill(colors[2]); 
    output.vertex( CS, CS,-CS);output.vertex(-CS, CS,-CS);output.vertex(-CS,-CS,-CS);output.vertex( CS,-CS,-CS);
    output.fill(colors[3]);
    output.vertex(-CS, CS,-CS);output.vertex(-CS, CS, CS);output.vertex(-CS,-CS, CS);output.vertex(-CS,-CS,-CS);
    output.fill(colors[4]);
    output.vertex(-CS, CS,-CS);output.vertex( CS, CS,-CS);output.vertex( CS, CS, CS);output.vertex(-CS, CS, CS);
    output.fill(colors[5]); 
    output.vertex(-CS,-CS,-CS);output.vertex( CS,-CS,-CS);output.vertex( CS,-CS, CS);output.vertex(-CS,-CS, CS);
    output.endShape(CLOSE);
  } // end constructor
}// end MyCube
</code></pre>
]]></description>
   </item>
   <item>
      <title>Toggle between windowed and fullscreen?</title>
      <link>https://forum.processing.org/two/discussion/18637/toggle-between-windowed-and-fullscreen</link>
      <pubDate>Thu, 20 Oct 2016 16:44:50 +0000</pubDate>
      <dc:creator>jakal</dc:creator>
      <guid isPermaLink="false">18637@/two/discussions</guid>
      <description><![CDATA[<p>Hello , I'm starting with processing and I have some difficulties with fullscreen.<br />
I already write a code to switch between windowed and fullscreen , but there is a gap at the bottom of the window :<br />
<a href="http://i.imgur.com/EOO6Ypd.png" target="_blank" rel="nofollow">http://i.imgur.com/EOO6Ypd.png</a></p>

<p>Here is the code part for fullscreen:</p>

<blockquote class="Quote">
  <p>if (key=='f') {<br />
      if (fullscreen == false) {<br />
        fullscreen = true;<br />
        surface.setSize(displayWidth, displayHeight);<br />
        surface.setLocation(-8, -31);<br />
        surface.setAlwaysOnTop(true);<br />
      } else {<br />
        fullscreen = false;<br />
        surface.setSize(1280, 720);<br />
        surface.setLocation(10, 10);<br />
        surface.setAlwaysOnTop(false);<br />
      }<br />
    }  &lt;</p>
</blockquote>

<p>Is there a solution to this?</p>
]]></description>
   </item>
   <item>
      <title>Multiple sketches</title>
      <link>https://forum.processing.org/two/discussion/10937/multiple-sketches</link>
      <pubDate>Thu, 21 May 2015 14:35:09 +0000</pubDate>
      <dc:creator>druid</dc:creator>
      <guid isPermaLink="false">10937@/two/discussions</guid>
      <description><![CDATA[<p>Howdy, i'm doing a work and I want to, by a menu with several options, click an option and a diferent sketch appears in a pop up window, i have already all the sketches done I just need to "glue" them together and i dont know how, I've tried multisketch but i don't think it lets me use more than two sketches. please help!! thanks 8)</p>
]]></description>
   </item>
   <item>
      <title>Trying to increase health bar when particle system drops hits the PImage. Not sure how to do it :/</title>
      <link>https://forum.processing.org/two/discussion/15825/trying-to-increase-health-bar-when-particle-system-drops-hits-the-pimage-not-sure-how-to-do-it</link>
      <pubDate>Sun, 03 Apr 2016 18:08:19 +0000</pubDate>
      <dc:creator>AmyM</dc:creator>
      <guid isPermaLink="false">15825@/two/discussions</guid>
      <description><![CDATA[<p>The piece of code I am trying to get working is commented out in draw().</p>

<pre><code>import processing.serial.*;

import cc.arduino.*;

import static javax.swing.JOptionPane.*;
import javax.swing.JPasswordField;


final StringDict accounts = new StringDict(
  new String[] {
  "john", "tony", "amy"
  }
  , new String[] {
    "ilikedogs", "husky", "pepsi"
  }
  );

final JPasswordField pwd = new JPasswordField();

{
  println(accounts);
} 

PImage startGameBackground;
PImage kitchen;
PImage dog;
float dogx=800, dogy=600;
HealthBar hb0 = new HealthBar();
boolean isWashed=false;

PImage achievment2;

int stage =1;
Serial port;

Fountain f = new Fountain();
//Ball b = new Ball(x,y,d,xs,ys);
ArrayList&lt;Ball&gt;ballList;

void setup() {
  size(1800, 900);
  String comPort = "COM3";

  stage =1;
  port = new Serial(this, comPort, 9600);

  f.fountainSetup(); 
  startGameBackground = loadImage("startGameBackground.png");
  kitchen = loadImage("kitchen.png");
  dog = loadImage("washDog.png");
  startGameBackground.resize(1800, 900);
  kitchen.resize(1800, 900);
  achievment2 = loadImage("achievment2.png");
}

void draw() {

  if (stage ==1) {

    background(startGameBackground);

    if (frameCount == 10)  surface.setVisible(true);


    String user = askUser();

    if (user == null)           confirmQuit();
    else if (!"".equals(user))  askPass(user);

  } else if (stage ==2) {

    background(kitchen);
    image(dog, dogx, dogy);
    hb0.draw();
    isWashed =true;

    f.fountainDraw();

    //if (hb0.value &lt;100) {
    //   //delay(1000);
    //   hb0.value += .5;
    // }

    // else if(hb0.value == hb0.max){
    //   println("Here is the achievment"); 
    //   image(achievment2, 500,100);
  }
}
}

String askUser() {
  String id = showInputDialog("Please enter user:");

  if (id == null)
    showMessageDialog(null, "You've canceled login operation!"
      , "Alert", ERROR_MESSAGE);

  else if ("".equals(id))
    showMessageDialog(null, "Empty user input!"
      , "Alert", ERROR_MESSAGE);

  else if (!accounts.hasKey(id = id.toLowerCase()))
    showMessageDialog(null, "Unknown \"" + id + "\" user!" + (id = "")
      , "Alert", ERROR_MESSAGE);

  return id;
}

boolean askPass(String id) {
  boolean isLogged = false;
  pwd.setText("");

  int action = showConfirmDialog(null, pwd
    , "Now enter password:", OK_CANCEL_OPTION);

  if (action != OK_OPTION) {
    showMessageDialog(null, "Password input canceled!"
      , "Alert", ERROR_MESSAGE);

    return false;
  }

  String phrase = pwd.getText();
  //String phrase = new String(pwd.getPassword());

  if ("".equals(phrase))
    showMessageDialog(null, "Empty password input!"
      , "Alert", ERROR_MESSAGE);

  else if (accounts.get(id).equals(phrase)) {
    showMessageDialog(null, "Welcome \"" + id + "\"!\nYou're logged in!"
      , "Info", INFORMATION_MESSAGE);

    isLogged = true;
    stage=2;
  } else
    showMessageDialog(null, "Password \"" + phrase + "\" mismatch!"
      , "Alert", ERROR_MESSAGE);

  return isLogged;
}

void confirmQuit() {
  if (showConfirmDialog(null, "Wanna quit then?", "Exit"
    , OK_CANCEL_OPTION) == OK_OPTION)  exit();
}


public class Ball {

  float x, y, xSpeed, ySpeed, diameter;
  int dropColour;
  boolean isAlive;
  int stepsAlive;
  HealthBar hb0 = new HealthBar();

  public Ball(float x, float y, float d, float xs, float ys) {
    this.x=x;
    this.y =y;
    this.diameter =d;
    xSpeed =xs;
    ySpeed =ys;
    isAlive = true;
    int stepsAlive =0 ;
  }

  public void move() {
    stepsAlive++;
    x = x + xSpeed;
    y = y + ySpeed;

    if (x &gt;=800) {

      xSpeed = -xSpeed;
    }

    if (x &lt;=950) {

      xSpeed = -xSpeed;
    }

    ySpeed = ySpeed +0.1F;

    if (y  &gt; 800) {
      ySpeed = -ySpeed;
    }
  }

  public void isDead() {

    if (stepsAlive &gt;= 400) {
      isAlive = false;
    }

    if (dist(x, y, dogx, dogy) &lt;100  ) {

      isAlive = false;
    }

    if (y  &gt; 800) {
      isAlive =false;
    }
  }
}


import ddf.minim.*;

public class Fountain {
  ArrayList&lt;Ball&gt; ballList;
  AudioPlayer player;
  Minim minim;
  HealthBar hb0 = new HealthBar();

  void fountainSetup() {
    //size(600,600); 
    ballList = new ArrayList&lt;Ball&gt;();
    //minim = new Minim(this);
  }

  public void fountainDraw() {
    //background(255,255,255);

    // if (mousePressed){
    if (mousePressed ==true) {
      float xSpeed = (float)(-3 + Math.random()*6);
      Ball b = new Ball(880, 400, 20, xSpeed, -2); 

      b.dropColour = color(204, 255, 255);

      ballList.add(b);
    }

    for (int i =0; i &lt;ballList.size(); i++) {
      Ball b2 = ballList.get(i);

      fill(b2.dropColour);
      ellipse(b2.x, b2.y, b2.diameter, b2.diameter);
      b2.move();
      //println("working");

      b2.isDead();

      if (b2.isAlive == false)
        ballList.remove(b2);

          println(dogy + ""+ "This thing is broke");
        }
      }
    }

class HealthBar {
  float value, max, x, y, w, h;
  color backing, bar;
  HealthBar(){
    value = 0;
    max = 100;
    x = 800;
    y = 60;
    w = 200;
    h = 30;
    backing = color(255,0,0);
    bar = color(0,255,0);
  }
  void draw(){
    fill(backing);
    stroke(0);
    rect(x,y,w,h);
    fill(bar);
    rect(x,y,map(value,0,max,0,w),h);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to change from default rendered to P3D?</title>
      <link>https://forum.processing.org/two/discussion/15549/how-to-change-from-default-rendered-to-p3d</link>
      <pubDate>Fri, 18 Mar 2016 00:21:26 +0000</pubDate>
      <dc:creator>gostinets</dc:creator>
      <guid isPermaLink="false">15549@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I want to change default rendered to P3D on user request. User request can be processed after setup() was run.
That is what I tried:
If I run size() outside setup() it does not work for P3D. It works for default rendered (not specified) - but size of the sketch window is small.
I get an error if user selects 3D:
<code>Caused by processing.core.PApplet$RendererChangeException</code></p>

<p>How to do this correctly?</p>
]]></description>
   </item>
   <item>
      <title>Is there any way to switch whether sketch is full screen mode or not?</title>
      <link>https://forum.processing.org/two/discussion/15227/is-there-any-way-to-switch-whether-sketch-is-full-screen-mode-or-not</link>
      <pubDate>Tue, 01 Mar 2016 14:30:07 +0000</pubDate>
      <dc:creator>combS8214808</dc:creator>
      <guid isPermaLink="false">15227@/two/discussions</guid>
      <description><![CDATA[<p>I want to switch full screen / non-full screen sketch, or decorated / undecorated frame while running using a specific key or something.
I know there's <code>fullScreen()</code> method in Processing 3, but it can be used no more than once.  Is there any official way to switch it using Processing 3?</p>
]]></description>
   </item>
   <item>
      <title>Processing 3 OpenGL in a Java app</title>
      <link>https://forum.processing.org/two/discussion/13883/processing-3-opengl-in-a-java-app</link>
      <pubDate>Thu, 10 Dec 2015 21:05:38 +0000</pubDate>
      <dc:creator>jfred1979</dc:creator>
      <guid isPermaLink="false">13883@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to figure out how to get Processing 3 to play nicely as a library in a Java app. The app might potentially have Swing and/or AWT components somewhere in its lifecycle. I don't necessarily need the Swing and AWT stuff to be on screen AT THE SAME TIME as the Processing rendered stuff, but they need to at least be in the same window or full screen display. Using the Java2D renderer I can sort of do this like so (as referenced in some other threads):</p>

<p>in my PApplet based class:</p>

<pre><code>public SmoothCanvas getCanvas() {
  PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
  PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
  return smoothCanvas;
}
</code></pre>

<p>In my main class, which extends JFrame:</p>

<pre><code>String[] args = {TestApplet.class.getName()};
ControlApplet app = new TestApplet();
TestApplet.runSketch(args, app);

JFrame pFrame = (JFrame) app.getCanvas().getFrame();
pFrame.setVisible(false);
getContentPane().add(app.getCanvas());
pFrame.dispose(); 
</code></pre>

<p>That achieves the goal, however there are two problems: it still pops up the initial Processing window for a brief second until I am able to gab the Frame and attach it to the base JFrame, and it only works in Java2D.</p>

<p>I'm trying to get my head around the hierarchy of JOGL and how I can grab ahold of a container somewhere that I might be able to attach to a "regular" Java container of some sort. Any insights on how I might do this?</p>
]]></description>
   </item>
   <item>
      <title>Multiple Windows (Multiple Applet) Resizing</title>
      <link>https://forum.processing.org/two/discussion/12383/multiple-windows-multiple-applet-resizing</link>
      <pubDate>Thu, 03 Sep 2015 17:58:53 +0000</pubDate>
      <dc:creator>FertheBana</dc:creator>
      <guid isPermaLink="false">12383@/two/discussions</guid>
      <description><![CDATA[<p>Hi, i´m trying to use this 
<code>surface.setSize(img.width, img.height);</code>
but from antother surface, how i can resize the main surface from a class created surface.
this is my code</p>

<pre><code>ControlWindow CWindow;
Button OpenImage;
Button SaveFile;
PImage img;

void settings() {
  size(320, 240);
  smooth();
  noLoop();
}

void setup() { //This is the one y wanna to resize from the Control Window
  surface.setTitle("Output");
  surface.setResizable(true);
  CWindow = new ControlWindow();
}

void draw() {
  background(250);
  if(img!=null){
    image(img, 0, 0);  
  }
}

class ControlWindow extends PApplet {

  public ControlWindow() {
    super();
    PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  }

  public void settings() {
    size(400, 400);
    OpenImage = new Button(this,150, 70,50,30,"Nuevo", GREEN, RED );
    SaveFile = new Button(this,150, 140,65,30,"Guardar", YELLOW, RED );
    //smooth();
    noLoop();
  }
  public void setup() { 
    surface.setTitle("Control Window");
    surface.setResizable(true);

  }

  public void draw() {
    background(250);
    OpenImage.SetButton();
    SaveFile.SetButton();
  }
  int bana=0;
  public void mousePressed() {
    if(OpenImage.ButtonPressed()){
      String Path = FileChooser("Imagenes", "Open File", new String[] {
    "jpg", "bmp", "png"}); 
    println(Path);
    img= loadImage(Path);
    //here is where i need to set the new size SOMETHING.setSize(img.width, img.height);        
    }
    if(SaveFile.ButtonPressed()){

    }
  }

  public void mouseDragged() {

  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Solutions to Some G4P Window Issues</title>
      <link>https://forum.processing.org/two/discussion/11489/solutions-to-some-g4p-window-issues</link>
      <pubDate>Sun, 28 Jun 2015 13:24:30 +0000</pubDate>
      <dc:creator>bobby_nicholas</dc:creator>
      <guid isPermaLink="false">11489@/two/discussions</guid>
      <description><![CDATA[<p>Hello Everyone,</p>

<p>I have been building a fairly large, multi-window program using G4P and have run into some minor issues along the way that I still have yet to find solutions to.</p>

<ol>
<li><p>Hiding the default Processing window -- All the content of my application appears within any one of many <code>GWindow</code> windows.  I want to be able to hide the default Processing window, but when I call either the <code>this.frame.hide()</code> or <code>this.frame.setVisible(false)</code> methods in the main Processing draw loop, my program behaves inappropriately in one important way.  Load file dialogues, using the G4P file selector (<code>G4P.selectInput()</code>) or the default processing <code>selectInput()</code> function, do not appear.  Is there anyway around this, either through an alternate way to hide the default window, or another function to do file selection?  As an ancillary problem, the load file dialogues (when I am not trying to hide the window) always appear in the background behind the <code>GWindow</code>s regardless of the calling window.  Is there a solution to this, as well?</p></li>
<li><p>Resizing windows to 0 height crashes the program -- If you have a <code>GWindow</code> that is set to be resizable, it is possible to resize the height of the window to 0 height, which crashes the program.  I tried using a simple function to check the size of the window and try to enforce a minimum height, but this does not seem to work.  Is there anything I can do to allow for window resizing but have a minimum size?</p></li>
</ol>

<p>Thanks so much for the help!</p>

<p>Regards,
Bobby</p>
]]></description>
   </item>
   <item>
      <title>Unintentional Closing and Wrong Size if setVisible(false) Problem of Second Window With JFrame</title>
      <link>https://forum.processing.org/two/discussion/11242/unintentional-closing-and-wrong-size-if-setvisible-false-problem-of-second-window-with-jframe</link>
      <pubDate>Tue, 09 Jun 2015 19:56:31 +0000</pubDate>
      <dc:creator>MadScience2728</dc:creator>
      <guid isPermaLink="false">11242@/two/discussions</guid>
      <description><![CDATA[<p>Hello there. 
I currently have a serial control sketch. I have a secondary window to act as the serial monitor, and I have everything working except the two problem as noted in the title which I will now explain in further detail.</p>

<p>The idea is to click the serial monitor button, and have a serial monitor of sorts popup in a separate window. 
I am using a JFrame, as well as a new PApplet to do so. (setVisible() refers to if the Serial Monitor Window is visible when when it is created (sets it to not, so that we can change it with the button later))</p>

<p>However problem a) occurs as such:</p>

<pre><code>  Correct Behaviour:
    1.   Open Program
    2.   Click Serial Monitor Button
    2b. Monitor Window Opens
    3.   Click back into main window
    3b. Everything is fine

  What really happens:
    1.   Open Program
    2.   Click Serial Monitor Button
    2b. Monitor Window Opens
    3.   Click back into main window
    4.   --&gt;Monitor window closes!&lt;--
    4b. Unless clicked into the new window


Whilst problem b) operates this way:

  Correct Behaviour:
    1.   Set setVisible() to true or false
    2.   Open Program
    3.   Click Serial Monitor Button
    3b. Monitor Window Opens
    4.   Window is at proper dimensions
    4b. Everything is fine

  What really happens:
    Part A:
      1.   Set setVisible() to true
      2.   Open Program
      3.   Click Serial Monitor Button
      3b. Monitor Window Opens
      4.   Window is at proper dimensions
      4b. Everything is fine

    Part B:
      1.   Set setVisible() to false
      2.   Open Program
      3.   Click Serial Monitor Button
      3b. Monitor Window Opens
      4.   Window is at much smaller dimensions
            (~100x100) and compressing frame
            inside to ~10x10
      4b. Problem above continues through 
            opening or closing monitor
</code></pre>

<p>Help is greatly appreciated. And I hope the formatting made the explanation of what is happening very clear. I figured it would be easiest to explain that way.</p>

<p>Commented core code of the problem is below.</p>

<p>-Mad</p>

<pre><code>import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;

SecondWindow smw; //Second window object
SecondApplet secApp; //Second PApplet object

int smwSize = 320; //Height size for second window
int s = 720; //Main window size

boolean serialMonitor = false;
boolean overSerialMonitorButton = false;

void setup()
{
  size(s, s);
  frame.setTitle("Serial Control Pad");

  secApp = new SecondApplet();
  smw = new SecondWindow(secApp, "Serial Monitor");
}

void draw()
{
  //Display a green rect with borders (for testing JFrame window placemnt and insets etc...)
  secApp.background(0);
  secApp.fill(0, 255, 0);
  secApp.stroke(0, 191, 0);
  secApp.strokeWeight(10);
  secApp.rectMode(CENTER);
  secApp.rect(secApp.width/2, secApp.height/2, secApp.width, secApp.height);
  secApp.fill(255, 127, 63);
  secApp.textAlign(RIGHT, BOTTOM);
  secApp.text(secApp.mouseX + "," + secApp.mouseY, secApp.mouseX, secApp.mouseY);
  secApp.redraw();

  //Check if over the Serial button
  float distToSerialMonitor = PVector.dist(new PVector(mouseX, mouseY), new PVector(width-150, 50));
  if (distToSerialMonitor &lt; 30) overSerialMonitorButton = true;   
  else overSerialMonitorButton = false;

  if (overSerialMonitorButton) cursor(HAND);
  else cursor(ARROW);
  smooth(); 

  //Display Button
  strokeWeight(2);
  stroke(70);
  textAlign(CENTER, CENTER);
  textSize(28);
  if (serialMonitor)
  {
    fill(0, 255, 0);
    ellipse(width - 150, 50, 60, 60);
    fill(0, 0, 255);
    text("&gt;&gt;", width - 150, 45);
  } else
  {
    fill(0, 0, 255, 63);
    ellipse(width - 150, 50, 60, 60);
    fill(0, 255, 0);
    text("&gt;&gt;", width - 150, 45);
  }
}

/////////////////////////////////////////////////////////////////////////////////

void mousePressed()
{
  //Toggle serial monitor
  if(overSerialMonitorButton &amp;&amp; mouseButton == LEFT)
  {
    serialMonitor = !serialMonitor;
    smw.setVisible(serialMonitor);
  }
}

/////////////////////////////////////////////////////////////////////////////////

//Second PApplet class
public class SecondApplet extends PApplet 
{

  public void setup() 
  {
    //Dimension size = new Dimension(smwSize, smwSize);
    //setPreferredSize(size);
    size(smwSize*2, smwSize);
    noLoop();
  }
  public void draw() 
  {
  }
}

/////////////////////////////////////////////////////////////////////////////////

//Second window Class, extends JFrame
class SecondWindow extends JFrame
{
  Dimension d;

  SecondWindow(SecondApplet sa, String title)
  {
    super(title); //Window Title
    //setDefaultCloseOperation(EXIT_ON_CLOSE);
    //setLayout(new FlowLayout());
    setLayout(new GridBagLayout()); //Layout (handles insets)


    // Set some preferred size
    d = new Dimension(smwSize*2, smwSize);
    setSize(d); //Sets the size of the window  
    //setPreferredSize(d);

    add(sa); //Adds SecondApplet to window to display (like as if it were a JPanel)
    sa.init(); //Start the applet

    setResizable(false); //Dont allow the user to change the window size

    //The mentioned setVisible dilema
    setVisible(false);
    //setVisible(true);

    // Pack the frame so that no/very little extra space is visible
    pack();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>no display window  --- noSize()???</title>
      <link>https://forum.processing.org/two/discussion/10502/no-display-window-nosize</link>
      <pubDate>Fri, 24 Apr 2015 23:21:37 +0000</pubDate>
      <dc:creator>jsfa11</dc:creator>
      <guid isPermaLink="false">10502@/two/discussions</guid>
      <description><![CDATA[<p>I started using processing and got used to a lot of the functions. While it might be easier to go to another language, I would prefer to continue using my own code and export an image file that I can access at my own convenience. Though, I do not want to see the display window, which is defaulted to size(100,100), every time I run the code.</p>

<p>Can the default display window be prevented? Can I have noWindow please??</p>
]]></description>
   </item>
   <item>
      <title>Changing render mode</title>
      <link>https://forum.processing.org/two/discussion/10184/changing-render-mode</link>
      <pubDate>Sat, 04 Apr 2015 23:17:45 +0000</pubDate>
      <dc:creator>Per</dc:creator>
      <guid isPermaLink="false">10184@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I have a sketch that needs different render modes depending on different tasks. Is there a way to change the rendermode without restarting the sketch? I did this quick test below with a bad result. I got this error:</p>

<blockquote class="Quote">
  <p>processing.corePApplet$RendererChangeException</p>
</blockquote>

<pre><code>void setup() {
  size(300, 300, P2D);
  background(233, 23, 23);
}

void draw() {
  fill(255, 0, 0);
  rect(100, 100, 100, 100);
  fill(0, 255, 0);
  rect(50, 50, 100, 100);
}

void keyPressed() {
  if (key == '1') {
    size(255, 255);
  }
  if (key == '2') {
    size(255, 255, P2D);
  }
  if (key == '3') {
    size(255, 255, P3D);
  }
}
</code></pre>

<p>Are there any other way?</p>
]]></description>
   </item>
   <item>
      <title>G4P Remove TextField</title>
      <link>https://forum.processing.org/two/discussion/9409/g4p-remove-textfield</link>
      <pubDate>Fri, 13 Feb 2015 19:27:36 +0000</pubDate>
      <dc:creator>hoihoila</dc:creator>
      <guid isPermaLink="false">9409@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
how can I remove a G4P textfield from the Screen? I just want it to be removed if I don't need it. Is that possible?</p>
]]></description>
   </item>
   <item>
      <title>How to use IntelliJ IDEA to create a working Sketch that can play a video?</title>
      <link>https://forum.processing.org/two/discussion/6132/how-to-use-intellij-idea-to-create-a-working-sketch-that-can-play-a-video</link>
      <pubDate>Thu, 03 Jul 2014 09:25:40 +0000</pubDate>
      <dc:creator>chris1779</dc:creator>
      <guid isPermaLink="false">6132@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>i am new to processing and this forum so i hope i put my question into the right section.</p>

<p>i managed to get Processing working with Intellij IDEA (Windows 7, Java8, Proceesing 2.2.1). I created a simple sketch that compiles 
and starts nicely:</p>

<pre><code>public class Simple extends PApplet
{
  /* main method of sketch */
  static public void main(String[] passedArgs)
  {

   String[] appletArgs = new String[]{"demo.Simple"};
    if (passedArgs != null)
    {
      PApplet.main(concat(appletArgs, passedArgs));
    }
    else
    {
      PApplet.main(appletArgs);
    }
  }

  /* sketch initial setup */
  public void setup()
  {
    size(300, 200);
    background(0);
  }

  /* put something on the stage */
  public void draw()
  {
    // Draw gray box

    int d = 20;
    int p1 = d;
    int p2 = p1 + d;
    int p3 = p2 + d;
    int p4 = p3 + d;

    stroke(153);
    line(p3, p3, p2, p3);
    line(p2, p3, p2, p2);
    line(p2, p2, p3, p2);
    line(p3, p2, p3, p3);
  }
}
</code></pre>

<p>the output i get:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/110/30X0KYQ28NG7.JPG" alt="proc2-output1" title="proc2-output1" /></p>

<p>So stage shows up, box gets drawn, everything fine.</p>

<p>The problem i have is: i can't get video working. I added the following files to my classpath:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/953/LEERQWD0VU7X.JPG" alt="proc2-classpath" title="proc2-classpath" /></p>

<p>(a full text list you can see here: <a rel="nofollow" href="http://pastebin.com/kTqzL1vW">pastebin.com/kTqzL1vW</a>)</p>

<p>but the Video doesn't get displayed. The code i use works fine with the Processing IDE so i guess i just forgot to add something to the classpath or to add additional VM parameters so that the native libs can be found (my guess).</p>

<p>i also tryed to add the following VM parameter to my RUN configuration:</p>

<p><code>-Djava.library.path=C:/path/to/native/libs</code></p>

<p>still, all i see is a black screen, no video playing, no exceptions or log output displayed :(</p>

<p>Here is my sample code i use for the Video sample:</p>

<pre><code>import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;
import processing.video.*;

import java.io.File;

public class Simple extends PApplet
{

public processing.video.Movie myMovie;

public void setup()
{
  size(300, 200);
  background(0);

  // load movie for first window
  final File movieFile = new File("./data/blue-HD.mp4");
  myMovie = new Movie(this, movieFile.getAbsolutePath());
  myMovie.loop();

  if (!movieFile.exists()) System.out.println("movie file NOT found.");
}

public void draw()
{
   image(myMovie, 0, 0);
}

// Called every time a new frame is available to read
void movieEvent(Movie m)
{
  m.read();
  System.out.println("read");
}

}
</code></pre>

<p>Can you help me?</p>

<p>Just to show really everything, here is my RUN Configuration:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/668/IZM5ER4KD6J8.JPG" alt="proc2-runconfig" title="proc2-runconfig" /></p>
]]></description>
   </item>
   <item>
      <title>Is it possible to write a text-only application?</title>
      <link>https://forum.processing.org/two/discussion/1967/is-it-possible-to-write-a-text-only-application</link>
      <pubDate>Mon, 09 Dec 2013 09:25:17 +0000</pubDate>
      <dc:creator>hydrodog</dc:creator>
      <guid isPermaLink="false">1967@/two/discussions</guid>
      <description><![CDATA[<p>Even without a draw method, the default program opens a 200x200 window.  Is there any way to create a sketch that only prints text?</p>
]]></description>
   </item>
   </channel>
</rss>