コード例 #1
0
 /**
  * Set the canvas visibility and brings canvas to the front of screen when made visible. This
  * method can also be used to bring an already visible canvas to the front of other windows.
  *
  * @param visible boolean value representing the desired visibility of the canvas (true or false)
  */
 public void setVisible(boolean visible) {
   if (graphic == null) {
     // first time: instantiate the offscreen image and fill it with
     // the background color
     Dimension size = canvas.getSize();
     canvasImage = canvas.createImage(size.width, size.height);
     graphic = (Graphics2D) canvasImage.getGraphics();
     graphic.setColor(backgroundColor);
     graphic.fillRect(0, 0, size.width, size.height);
     graphic.setColor(Color.black);
   }
   frame.setVisible(visible);
 }