Not if you are using GUI Builder.
Creating a secondary window with a slider on it
- Start Processing
- Create a new empty sketch
- Start GUI Builder
Using GUI Bulder
- clcik on the new window button
- add a draw handler called
win_draw
- click on the slider button to add a slider to the new window
If you follow the above instruction you will get a sketch with 2 windows and a slider in the secndary one and the code will look like
// Need G4P library
import g4p_controls.*;
// You can remove the PeasyCam import if you are not using
// the GViewPeasyCam control or the PeasyCam library.
import peasy.*;
public void setup() {
size(480, 320, 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() {
}
and in the second tab
/* =========================================================
* ==== WARNING ===
* =========================================================
* The code in this tab has been generated from the GUI form
* designer and care should be taken when editing this file.
* Only add/edit code inside the event handlers i.e. only
* use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
} //_CODE_:button1:12356:
* Do not rename this tab!
* =========================================================
*/
synchronized public void win_draw1(PApplet appc, GWinData data) { //_CODE_:window1:452479:
appc.background(230);
} //_CODE_:window1:452479:
public void slider1_change1(GSlider source, GEvent event) { //_CODE_:slider1:581575:
println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
} //_CODE_:slider1:581575:
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI(){
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setMouseOverEnabled(false);
surface.setTitle("Sketch Window");
window1 = GWindow.getWindow(this, "Window title", 0, 0, 240, 120, JAVA2D);
window1.noLoop();
window1.setActionOnClose(G4P.KEEP_OPEN);
window1.addDrawHandler(this, "win_draw1");
slider1 = new GSlider(window1, 70, 40, 100, 40, 10.0);
slider1.setLimits(0.5, 0.0, 1.0);
slider1.setNumberFormat(G4P.DECIMAL, 2);
slider1.setOpaque(false);
slider1.addEventHandler(this, "slider1_change1");
window1.loop();
}
// Variable declarations
// autogenerated do not edit
GWindow window1;
GSlider slider1;