Controlling child window properties.

edited April 2016 in Library Questions

In the example: Demos > Tests > MultipleWindows
I would like to create a child window which does not close the main window when closed. The purpose is to have an inspection window which will be created for a short time, then closed, and then something else is inspected. My hunch is that it's something with JFrame if I'm not confused, but I probably am because I can't find anything.

After using the G4P library, I've noticed that after about three to seven windows are created and closed in procession, my entire computer starts going very slowly, but my resource monitor shows nothing specific. So, I'm looking to build the windows from scratch to see if it's any different or if it's my computer.

Answers

  • I said I searched everywhere. Where is the reference for runScetch()? That's what I'm looking for, not some pile of kid's spaghetti.
    Performing a find text on the page GitHub:core:src:PApplet.java for runScetch doesn't find anything.

    Multiple windows is literally the most important feature of the whole desktop concept, it's why we don't use command prompts anymore...
    Why is this foundation feature for learning computer programming absent from an API designed to ease learning/using programming? This is bizarre and frustrating.

  • edited April 2016

    If you search for the wrong thing you won't find it ;) . Search for runSketch NOT runScetch if you do that you will find the comments describing the arguments between lines 9926 and 9996 in PApplet

  • HAHAHAHAH damnit :D

  • After reading it, it's not obvious to me how you got only the child window to close in the G4P library.

  • you got only the child window to close in the G4P library

    With great difficulty and it is different for JAVA2D and P2D/P3D

    To start with the arguments for runSketch do not affect how Processing deals with clicking on the window close icon (red cross).

    You have to remember that Processing is designed to create single-window sketches. So when a window is created with runSketch Processing adds a window listener to it which terminates the application when the user closes the window.

    Libraries like G4P that create multiple windows using runSketch either accept that the application terminates if any of the windows is closed or has to remove the listener added by Processing then create and add a new window listener which closes the extra window without terminating the application.

    G4P takes this one step further by allowing the user to choose what happens when the user clicks on the window close icon. It can be
    1) Ignore and keep the window open
    2) close the window
    3) terminate the application (same as Processing)

    The code to do this is fairly advanced stuff, which is why it is hidden away inside G4P so the user doesn't have to worry about it. :)

  • Hmmmm....

    Do you have any idea why after a few window create/close cycles makes my entire computer slow down? The program becomes inoperable too quickly.

  • edited April 2016

    It's pretty standard, and seems like it's what you were telling me to do in the other thread.

    void createWinHL() {
      winHeat = GWindow.getWindow(this,  "ACTION",  5,  5,  790,  790,  JAVA2D);
      winHeat.addDrawHandler(this, "drawHandlerACTION");
    }
    
    boolean drawLoopHL = true;  
    void drawHandlerACTION(PApplet windowApplet, GWinData data) {
      if(drawLoopHL) { 
        drawLoopHL = false;
        DRAWACTION(windowApplet);
      }
      windowApplet.noLoop();
    }  
    
    void DRAWACTION(PApplet a) {
      a.background(255);
      calculateHeatMapAction(); // bunch of math to make heatHL.
      a.image(heatHL, 10, 0);
      drawOverlay(a, "action");
    }
    
    void drawOverlay(PApplet a, String type) { // used by more than one window.
      // Draw overlay.
      int winH = a.height;
      a.stroke(0);
      a.line(10, 0, 10, winH);
      a.line(0, winH-11, a.width, winH-11);
      for(int y=1; y<5; y++) {
        int inc = (156*y)-1;
        a.line(0, inc, a.width, inc);
      }
    
      // Time Index (Linear) 1 : 95 minutes
      a.stroke(0, 32);
      for(int x=1; x<index; x++) {
        int inc = 10+(4*x);
        a.line(inc, 0, inc, winH-11);
      }
    
      // Graph Value (Log10) 1 : 10,000,000
      for(int band=0; band<5; band++) {
        for(int i=1; i<11; i++) {
          float y = 156.0-(log10(i)*156.0);
          y = y+156.0*band;
          a.line(0, y, a.width, y);
        }
      } // end band
    
      DATAOBJECT date = alDataList.get(0); // array of dataobjects storing float arrays.
      String file = type + " " + date.iMonth + " " + date.iDay + " " + minute() + ".png";
      a.save(file); 
    }
    
  • Do you have any idea why after a few window create/close cycles makes my entire computer slow down?

    Have you tried doing this with the Mandelbrot example that comes with G4P

    It could be that the resources are not being released properly. Generally I don't close a window if I want to open it again (or reuse it) later I simply make it invisible.

  • The mandlebrot example does make some serious slowdown after ~6 windows into it. However, mine is slowing down much greater after the first windows. The specific function that is slowing down is selectFolder(). I'm loading data, processing the data, then visualizing it. After the images are saved, a new folder is selected. After a couple of these cycles, the selectFolder window begins lagging out really, really badly, the Windows min/max/close buttons and Window Pane movement is also slow.

    Sometimes (not always under same procedure) G4P throws: "Exception while removing reference."
    The only data that isn't temporary is located in the main sketch, being the ArrayList alDataList and PImage heatHL.

    I'll try the invisible setting to see if anything improves.

  • Answer ✓

    The mandlebrot example does make some serious slowdown after ~6 windows

    Interesting because on my computer I can have over 20 windows open without any noticeable slowdown. :)

    the specific function that is slowing down is selectFolder()

    The select??? methods in G4P and Processing use the standard Java dialog boxes so I don't see why the should slow down. Can you post a simple sketch that demonstrates the problem?

  • ding graphics card driver problems. Looks like I'm buying a new card then. This one wasn't designed for Windows7 compatibility and has a few MB of memory. That's why it didn't show up on the resource monitor. Well, at least I'm comfortable with this as it has nothing to do with either the API or my programming.

    I am very grateful for your support quark. Thank you very much. :)

Sign In or Register to comment.