Hello,
I use the new GP4 for Processing 3 and I see you're talking about "setActionOnClose" that gives me some problems when I close a GWindow.
If I close using the "x" window buton, An error occurs sometimes and java says:
Component must have a valid peer
if I close the same window with a closing buton I created with GP4. I have an error (sometimes) and java says:
Buffers have not been created
There is a problem with this closing function, maybe linked to the problem u try to solve.
Thank you and congratulations for your good work on this very helpfull GUI
@GLG I have split this off from the previous discussion because it is not related to the issue raised in it and I think it is worth its own discussion. :)
An error occurs sometimes and java says: Component must have a valid peer
I have an error (sometimes) and java says: Buffers have not been created
When someone tells you they have a problem with your code the last word you want to hear is sometimes. Errors that appear then disappear then reappear are a nightmare to solve. OK so having said that lets see if we can narrow it down.
The GWindow supports JAVA2D, P2D and P3D redererers, the last two are OpenGL based and since PS3 G4P has to treat these as different window types. In fact if you look at the GWindow reference you will see that GWindow is an abstract class with 2 child classes, GWindowAWT is for JAVA2D renderer and GWindowNEWT for P2D/P3D renderers.
So some questions for you
1) what type of renderer was being used?
2) can you post a minimal sketch that demonstrates the problem (even it it is only happens sometimes)?
3) What is your OS?
I think that is enough to get me started on the problem.
Hello, sorry, I didn't see your answer.
I use java2D in the setup and in all the G4P new windows made on ubuntu.
Yes, I saw these 2 kinds of child class but I don't know how to use them. I just kept the former version made automatically by G4P builder on Processing2.1.
I will check the GWindowAWT tomorrow on your reference if there is any answer
I will try to reproduce the problem on a shorter code
Thank u
hello, here a simple window test I made this morning on processing 2.2.1 and transfered to processing 3.
I just used G4P Builder in processing2 to make the test. I just changed the place of the code to be able to open and close the 2 new window.
And I have the same error when I use the button to close:
"Component must have a valid peer"
this error happens after clicking on open and close a few times...strange...
But I didn't get any error on the "x" buton at the top of the window.!
/* =========================================================
* ==== 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:
I just kept the former version made automatically by G4P builder on Processing2.1
You seem to be mixing versions of Processing, G4P and GUI Builder
Note that PS2 and PS3 are very different beasts and you have to use the correct versions for
PS2 use G4P 3.5.4 and GUI Builder 2.6
PS3 use G4P 4.0 and GUI Builder 4.0
Rather than post the entire sketch code here I will send to you a PM with my email address. Archive the sketch (Tools > Archive) and attach it to an email stating what version you have used DO NOT MIX AND MATCH
Hi everyone GLG and I have been looking into this problem and the errors occur in ubuntu but not OS X. We would like Linux and Windows users to test the sketch below.
To do that you need PS3 and to install G4P 4.0 through the PDE. Run the sketch open and close the windows a few times and tell us how you got on. Let us know OS, success/failure and a copy of any error messages.
Ok, did it on Linuxmint 17.1, 64bit.
tried opening and closing both windows without touching anything else. worked ok. after touching one time a droplist had that 'valid peer' error:
Setting 'Run Sketches on Display' preference to display 1
Use surface.setTitle() instead of frame.setTitle in Processing 3
===================================================
G4P V4.0 created by Peter Lager
===================================================
button1 - GButton >> GEvent.CLICKED @ 70163
buttonclose - GButton >> GEvent.CLICKED @ 75731
button3 - GButton >> GEvent.CLICKED @ 78808
button2 - GButton >> GEvent.CLICKED @ 80859
button1 - GButton >> GEvent.CLICKED @ 82659
button3 - GButton >> GEvent.CLICKED @ 87581
button1 - GButton >> GEvent.CLICKED @ 92667
dropList2 - GDropList >> GEvent.SELECTED @ 97318
buttonclose - GButton >> GEvent.CLICKED @ 98717
java.lang.IllegalStateException: Component must have a valid peer
at java.awt.Component$FlipBufferStrategy.flip(Component.java:4084)
at java.awt.Component$FlipBufferStrategy.show(Component.java:4205)
at processing.awt.PSurfaceAWT.render(PSurfaceAWT.java:303)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1524)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
@spiderdab thanks for taking the time to do that, GLG reported the error on ubuntu but I could not reproduce it on OS X. This confirms that there is a problem with G4P closing windows. The error message is consistant and gives me clues towards a solution.
Answers
Hello, I use the new GP4 for Processing 3 and I see you're talking about "setActionOnClose" that gives me some problems when I close a GWindow. If I close using the "x" window buton, An error occurs sometimes and java says: Component must have a valid peer
if I close the same window with a closing buton I created with GP4. I have an error (sometimes) and java says: Buffers have not been created
There is a problem with this closing function, maybe linked to the problem u try to solve. Thank you and congratulations for your good work on this very helpfull GUI
@GLG I have split this off from the previous discussion because it is not related to the issue raised in it and I think it is worth its own discussion. :)
When someone tells you they have a problem with your code the last word you want to hear is sometimes. Errors that appear then disappear then reappear are a nightmare to solve. OK so having said that lets see if we can narrow it down.
The GWindow supports JAVA2D, P2D and P3D redererers, the last two are OpenGL based and since PS3 G4P has to treat these as different window types. In fact if you look at the GWindow reference you will see that GWindow is an abstract class with 2 child classes, GWindowAWT is for JAVA2D renderer and GWindowNEWT for P2D/P3D renderers.
So some questions for you
1) what type of renderer was being used?
2) can you post a minimal sketch that demonstrates the problem (even it it is only happens sometimes)?
3) What is your OS?
I think that is enough to get me started on the problem.
Hello, sorry, I didn't see your answer. I use java2D in the setup and in all the G4P new windows made on ubuntu. Yes, I saw these 2 kinds of child class but I don't know how to use them. I just kept the former version made automatically by G4P builder on Processing2.1. I will check the GWindowAWT tomorrow on your reference if there is any answer I will try to reproduce the problem on a shorter code Thank u
hello, here a simple window test I made this morning on processing 2.2.1 and transfered to processing 3. I just used G4P Builder in processing2 to make the test. I just changed the place of the code to be able to open and close the 2 new window. And I have the same error when I use the button to close: "Component must have a valid peer" this error happens after clicking on open and close a few times...strange... But I didn't get any error on the "x" buton at the top of the window.!
//here is the first tab // Need G4P library import g4p_controls.*;
String[] List1 = {"Maison","Jardin"}; String[] List2 = {"Auto","Vélo"};
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(){
}
//Here is 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:
public void dropList1_click1(GDropList source, GEvent event) { //CODE:dropList1:617524: println("dropList1 - GDropList >> GEvent." + event + " @ " + millis()); } //CODE:dropList1:617524:
public void slider2d1_change1(GSlider2D source, GEvent event) { //CODE:slider2d1:375237: println("slider2d1 - GSlider2D >> GEvent." + event + " @ " + millis()); } //CODE:slider2d1:375237:
public void buttonOpen1_click1(GButton source, GEvent event) { //CODE:buttonOpen1:323283: println("button1 - GButton >> GEvent." + event + " @ " + millis()); window1 = GWindow.getWindow(this, "Window N°1", 0, 0, 400, 300, JAVA2D); window1.setActionOnClose(G4P.CLOSE_WINDOW); window1.addDrawHandler(this, "win_draw1"); label2 = new GLabel(window1, 10, 10, 80, 20); label2.setText("My label"); label2.setOpaque(false); textfield1 = new GTextField(window1, 110, 10, 160, 30, G4P.SCROLLBARS_NONE); textfield1.setOpaque(true); textfield1.addEventHandler(this, "textfield1_change1"); textarea1 = new GTextArea(window1, 110, 60, 160, 80, G4P.SCROLLBARS_NONE); textarea1.setOpaque(true); textarea1.addEventHandler(this, "textarea1_change1"); dropList2 = new GDropList(window1, 110, 160, 90, 80, 3); dropList2.setItems(List2, 0); dropList2.addEventHandler(this, "dropList2_click1"); buttonclose1 = new GButton(window1, 280, 240, 100, 30); buttonclose1.setText("CloseWindow1"); buttonclose1.addEventHandler(this, "buttonclose1_click1"); } //CODE:buttonOpen1:323283:
public void buttonOpen2_click1(GButton source, GEvent event) { //CODE:buttonOpen2:781089: println("button3 - GButton >> GEvent." + event + " @ " + millis()); window2 = GWindow.getWindow(this, "Window N°2", 0, 0, 300, 300, JAVA2D); window2.setActionOnClose(G4P.CLOSE_WINDOW); window2.addDrawHandler(this, "win_draw2"); label3 = new GLabel(window2, 20, 20, 80, 20); label3.setText("My label"); label3.setOpaque(false); textfield2 = new GTextField(window2, 120, 20, 160, 30, G4P.SCROLLBARS_NONE); textfield2.setOpaque(true); textfield2.addEventHandler(this, "textfield2_change1"); buttonClose2 = new GButton(window2, 190, 170, 100, 30); buttonClose2.setText("CloseWindow2"); buttonClose2.addEventHandler(this, "buttonClose2_click1"); } //CODE:buttonOpen2:781089:
synchronized public void win_draw1(PApplet appc, GWinData data) { //CODE:window1:995540: appc.background(230); } //CODE:window1:995540:
public void textfield1_change1(GTextField source, GEvent event) { //CODE:textfield1:897802: println("textfield1 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:textfield1:897802:
public void textarea1_change1(GTextArea source, GEvent event) { //CODE:textarea1:408274: println("textarea1 - GTextArea >> GEvent." + event + " @ " + millis()); } //CODE:textarea1:408274:
public void dropList2_click1(GDropList source, GEvent event) { //CODE:dropList2:531428: println("dropList2 - GDropList >> GEvent." + event + " @ " + millis()); } //CODE:dropList2:531428:
public void buttonclose1_click1(GButton source, GEvent event) { //CODE:buttonclose1:839570: println("buttonclose - GButton >> GEvent." + event + " @ " + millis()); window1.close(); } //CODE:buttonclose1:839570:
synchronized public void win_draw2(PApplet appc, GWinData data) { //CODE:window2:774241: appc.background(230); } //CODE:window2:774241:
public void textfield2_change1(GTextField source, GEvent event) { //CODE:textfield2:808973: println("textfield2 - GTextField >> GEvent." + event + " @ " + millis()); } //CODE:textfield2:808973:
public void buttonClose2_click1(GButton source, GEvent event) { //CODE:buttonClose2:541936: println("button2 - GButton >> GEvent." + event + " @ " + millis()); window2.close(); } //CODE:buttonClose2:541936:
// Create all the GUI controls. // autogenerated do not edit public void createGUI(){ G4P.messagesEnabled(false); G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); G4P.setCursor(ARROW); if(frame != null) frame.setTitle("Sketch Window"); dropList1 = new GDropList(this, 10, 20, 90, 80, 3); dropList1.setItems(List1, 0); dropList1.addEventHandler(this, "dropList1_click1"); label1 = new GLabel(this, 20, 60, 80, 20); label1.setText("My label"); label1.setOpaque(false); slider2d1 = new GSlider2D(this, 170, 20, 140, 50); slider2d1.setLimitsX(0.5, 0.0, 1.0); slider2d1.setLimitsY(0.5, 0.0, 1.0); slider2d1.setNumberFormat(G4P.DECIMAL, 2); slider2d1.setOpaque(true); slider2d1.addEventHandler(this, "slider2d1_change1"); buttonOpen1 = new GButton(this, 20, 130, 100, 30); buttonOpen1.setText("OpenWindow1"); buttonOpen1.addEventHandler(this, "buttonOpen1_click1"); buttonOpen2 = new GButton(this, 360, 130, 100, 30); buttonOpen2.setText("OpenWindow2"); buttonOpen2.addEventHandler(this, "buttonOpen2_click1");
}
// Variable declarations // autogenerated do not edit GDropList dropList1; GLabel label1; GSlider2D slider2d1; GButton buttonOpen1; GButton buttonOpen2; GWindow window1; GLabel label2; GTextField textfield1; GTextArea textarea1; GDropList dropList2; GButton buttonclose1; GWindow window2; GLabel label3; GTextField textfield2; GButton buttonClose2;
Sorry, I don't see where to send the whole file on this website I hope it will help anyway
You seem to be mixing versions of Processing, G4P and GUI Builder
Note that PS2 and PS3 are very different beasts and you have to use the correct versions for
PS2 use G4P 3.5.4 and GUI Builder 2.6
PS3 use G4P 4.0 and GUI Builder 4.0
Rather than post the entire sketch code here I will send to you a PM with my email address. Archive the sketch (Tools > Archive) and attach it to an email stating what version you have used DO NOT MIX AND MATCH
Hi everyone GLG and I have been looking into this problem and the errors occur in ubuntu but not OS X. We would like Linux and Windows users to test the sketch below.
To do that you need PS3 and to install G4P 4.0 through the PDE. Run the sketch open and close the windows a few times and tell us how you got on. Let us know OS, success/failure and a copy of any error messages.
Thanks for your help in advance.
Ok, did it on Linuxmint 17.1, 64bit. tried opening and closing both windows without touching anything else. worked ok. after touching one time a droplist had that 'valid peer' error:
..and second time happened after more playing around, so nothing helpful:
@spiderdab thanks for taking the time to do that, GLG reported the error on ubuntu but I could not reproduce it on OS X. This confirms that there is a problem with G4P closing windows. The error message is consistant and gives me clues towards a solution.