Solutions to Some G4P Window Issues

Hello Everyone,

I have been building a fairly large, multi-window program using G4P and have run into some minor issues along the way that I still have yet to find solutions to.

  1. Hiding the default Processing window -- All the content of my application appears within any one of many GWindow windows. I want to be able to hide the default Processing window, but when I call either the this.frame.hide() or this.frame.setVisible(false) methods in the main Processing draw loop, my program behaves inappropriately in one important way. Load file dialogues, using the G4P file selector (G4P.selectInput()) or the default processing selectInput() function, do not appear. Is there anyway around this, either through an alternate way to hide the default window, or another function to do file selection? As an ancillary problem, the load file dialogues (when I am not trying to hide the window) always appear in the background behind the GWindows regardless of the calling window. Is there a solution to this, as well?

  2. Resizing windows to 0 height crashes the program -- If you have a GWindow that is set to be resizable, it is possible to resize the height of the window to 0 height, which crashes the program. I tried using a simple function to check the size of the window and try to enforce a minimum height, but this does not seem to work. Is there anything I can do to allow for window resizing but have a minimum size?

Thanks so much for the help!

Regards, Bobby

Answers

  • edited June 2015 Answer ✓

    All the G4P dialog boxes are linked to the main PS window to make them appear centred. This behaviour seemed good to me especially if there are multiple applications running on a high res display. Also PS was not designed to operate in headless mode so I always assumed the main display window would be visible and in use.

    You could always make the main window visible only when you call selectInput and then hide it afterwards. You could also use PS's selectInput method but this provides asynchronous input rather than the synchronous access provided by G4P. This means that these PS and G4P dialog boxes are NOT interchangeable without significant code changes.

    By default new GWindows are 'set on top' so will always appear over other windows. You can change this with gwin.setOnTop (false)

    GWindow extends Frame so you can use the methods setMinimumSize, setPreferedSize and setMaximumSize with the GWindow directly.

  • Thank you so much for the quick response and for making such a useful library! Very much appreciated, Peter! The setOnTop() function works nicely, but the setMinimumSize() function doesn't seem to be having an effect; I can still resize the window's height to 0. I tried calling it on the GWindow itself, as well as the papplet of the GWindow and neither way worked. All of my windows are classes that inherit from an abstract class which calls the following function in its constructor.

    private void build(PApplet a, String wt, int posX, int posY, int defWidth, int defHeight, boolean resize, int background){ app = a; windowTitle = wt; window = new GWindow(app, windowTitle, posX, posY, defWidth, defHeight, false, JAVA2D); window.setActionOnClose(GWindow.CLOSE_WINDOW); window.setResizable(resize); window.setMinimumSize(new Dimension(50,50)); // this isn't working window.papplet.setMinimumSize(new Dimension(50,50));// this isn't working, either window.setOnTop(false); //works great! ..... }

    Is there something wrong with the way I am going about this?

  • Never mind, I figured it out! Thanks!

  • edited June 2015 Answer ✓

    It would be useful for others (including me :) ) to know what you managed to figure out, please post your solution.

  • Hey, sorry for the late reply!

    It seems that when you call window.setMinimumSize(new Dimension(x,y)) the y component needs to be above a certain threshold for it to prevent the window height from going to 0. For my Windows 8 machine, that threshold is at 57. At 56 the size goes to 0, but at 57 it does not. I haven't had time to test whether it would be different on mac, or if the threshold is dependent on screen resolution.

    Cheers!

Sign In or Register to comment.