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

G4P Buffers have not been created

$
0
0

@quark

Sorry to bother once again. I'd used a GButton to create a GWindow every time it is clicked. Inside, there is a GTextArea that displays some text. Strangely, half the time it is working well (after adding spaces to \n), half the time, it returns a Buffers have not been created error on closing the window:

===================================================
   G4P V4.1.1 created by Peter Lager
===================================================
java.lang.IllegalStateException: Buffers have not been created
    at sun.awt.windows.WComponentPeer.getBackBuffer(WComponentPeer.java:1018)
    at java.awt.Component$FlipBufferStrategy.getBackBuffer(Component.java:4065)
    at java.awt.Component$FlipBufferStrategy.updateInternalBuffers(Component.java:4050)
    at java.awt.Component$FlipBufferStrategy.revalidate(Component.java:4165)
    at java.awt.Component$FlipBufferStrategy.revalidate(Component.java:4147)
    at java.awt.Component$FlipBufferStrategy.getDrawGraphics(Component.java:4139)
    at processing.awt.PSurfaceAWT.render(PSurfaceAWT.java:296)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1541)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

Sometimes, I get another error while trying to open the window, I am not sure of the errors are related:

===================================================
   G4P V4.1.1 created by Peter Lager
===================================================
################  EXCEPTION IN EVENT HANDLER  ################
An error occured during execution of the eventhandler:
CLASS: Defense_Spread_Calculator_0_11_0   METHOD: btn_details_click
    Caused by java.lang.NullPointerException
    g4p_controls.StyledString.getLines(Unknown Source)
    g4p_controls.GTextArea.setStyledText(Unknown Source)
    g4p_controls.GTextArea.setTextImpl(Unknown Source)
    g4p_controls.GTextArea.setText(Unknown Source)
    Defense_Spread_Calculator_0_11_0.createDetailsWindow(Defense_Spread_Calculator_0_11_0.java:1835)
    Defense_Spread_Calculator_0_11_0.btn_details_click(Defense_Spread_Calculator_0_11_0.java:2110)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    g4p_controls.GAbstractControl.fireEvent(Unknown Source)
    g4p_controls.GButton.mouseEvent(Unknown Source)
    g4p_controls.GWindowImpl.mouseEvent(Unknown Source)
    sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1408)
    processing.core.PApplet.handleMethods(PApplet.java:1603)
    processing.core.PApplet.handleMouseEvent(PApplet.java:2695)
    processing.core.PApplet.dequeueEvents(PApplet.java:2618)
    processing.core.PApplet.handleDraw(PApplet.java:2429)
    processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1540)
    processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
##############################################################

Here is a portion of my code:

void createDetailsWindow(){
  int winX=windowX()+width+20, winY=windowY();
  int winW=400, winH=height;
  PImage icon = loadImage(iconFn);

  win_details = GWindow.getWindow(this, "Details", winX, winY, winW, winH, JAVA2D);
  win_details.addDrawHandler(this, "win_details_draw");
  win_details.setActionOnClose(G4P.CLOSE_WINDOW);
  win_details.addOnCloseHandler(this, "win_details_close");

  //Set windows Icon
  JFrame frame = (JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) win_details.getSurface().getNative()).getFrame();
  frame.setIconImage((java.awt.Image) loadImage(iconFn).getNative());

  txt_details = new GTextArea(win_details, 20, 20, winW-40, winH-40-30, G4P.SCROLLBARS_VERTICAL_ONLY);
  txt_details.setPromptText("No Results.");
  txt_details.addEventHandler(this, "txt_details_change");

  btn_detailsCopy = new GButton(win_details, winW-20-90, winH-20-20, 90, 20);
  btn_detailsCopy.setText("Copy");
  btn_detailsCopy.addEventHandler(this, "btn_detailsCopy_click");

  txt_details.setText(generateFullResults());

  win_aboutOpen=true;

}

The function is called on clicking one of the GButton:

public void btn_details_click(GButton source, GEvent event) { //_CODE_:btn_details:922113:
  createDetailsWindow();
  source.setEnabled(false);
} //_CODE_:btn_details:922113:

Once again, I thank you for helping out.


Viewing all articles
Browse latest Browse all 2896

Trending Articles