Good to see you again here. Thanks for the previous help with the legs,
I will try that. Sounds hard.
But before that, a simpler question:
Can I start / stop the applet after the main sketch is up?
In setup there is the line that starts it
child = new ChildApplet();
But I can’t cancel that after the sketch started. Or can I ? I have a toggle button to do it,.
Quark
Thanks a lot, I did make a second window with your example.
But I was hoping to be able to open GUI Builder from tools and see the new window.
Then make features, like buttons and sliders.
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;
Thanks a lot, That works for me. I was not aware I can do that.
Also for the first time I made a decimal output slider.
The depiction of the slider shows fine, 2 digit decimals but the output is an integer and a zero.
I am using the GUI builder and here is the code it generated:
Internally all sliders store their value as a float and you have used this float IMU_Bias = source.getValueI();
to retrieve the value which is the problem. You are asking the slider to return the value as an integer and then store in in a float so it will always have a zero after the decimal point.
Instead use this float IMU_Bias = source.getValueF();
which will return the slider value as a float.
This simply controls how decimal numbers appear on the slider e.g. limits and current value it has no effect on the value stored internally which happens to be a float with 7-8 significant figures
This retrieves the value stored internally as a float so it can be used in calculations or whaever.
If you want to display the number as a string with the specified decimal places then use String IMU_BiasS = source.getValueS();
Thanks , I made a little process and trimmed to 2 decimals.
IMU_Bias = source.getValueF()*100;
int R = round (IMU_Bias);
IMU_Bias = R/100.00;
println (IMU_Bias);