Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Dynamic Sketch size.

$
0
0

Hello Friends. I am trying to control the sketch size dynamically with checkBox. So, if I select the checkbox it will change size or if I un-check the checkBox then it will comeback to normal size as before. here is code.

// Need G4P library
import g4p_controls.*;


public void setup(){
  size(500, 670, JAVA2D);
  if(chkPro.isSelected()){
  size(480, 320, JAVA2D);
  }
  else{
   size(480, 600, JAVA2D);
  }


  createGUI();
  customGUI();
  // Place your setup code here

}

public void draw(){
  background(230);

}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI(){

}


public void chkProperty(GCheckbox source, GEvent event) { //_CODE_:chkPro:390305:
  println("chkPro - GCheckbox >> GEvent." + event + " @ " + millis());
}


public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  chkPro = new GCheckbox(this, 168, 150, 120, 20);
  chkPro.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  chkPro.setText("Characteristics");
  chkPro.setTextBold();
  chkPro.setOpaque(false);
  chkPro.addEventHandler(this, "chkProperty");
}

// Variable declarations
// autogenerated do not edit
GCheckbox chkPro;

Thanks in Advance


Viewing all articles
Browse latest Browse all 2896

Trending Articles