G4P text size

edited November 2015 in Library Questions

I just learning about G4P, plus, a neophyte programmer. Is there a way to change the text size withing a control, specifically, the "Textfield" control. Thank You

Answers

  • Apparently, I am also just learning to type. Sorry for the misspellings.

  • Apparently, I am also just learning to type. Sorry for the misspellings.

    You can edit your post to correct mistakes.

    If you have a GTextField control called textfield then you can change the font with

    textfield.setFont( new Font("Arial", Font.PLAIN, 20) );

    The first parameter is the name of a font on your system, the next is the style (can use Font.BOLD or Font.ITALIC instead), the last parameter is the size. When creating the GTextField make sure it is tall enough for the font size you want to use.

    you would also need to add this statement at the beginning of your sketch

    import java.awt.Font;

  • edited November 2015

    Did not work for me. I was able to compile/run using the following;

    // Use this method to add additional statements
    
    // to customise the GUI controls
    public void customGUI(){
    
    textfield1.setFont (new Font("Arial", Font.PLAIN, 32) );
    
    }
    

    I tried placing the same statement in other parts of the sketch, to no avail.

    And yes, I did include the additional "import java.awt.Font;" at the beginning of the sketch. Thank you for your assistance. It is much appreciated. The people in the open software arena are terrific.

  • Answer ✓

    Sorry about that it should have worked but it appears to be a bug in G4P :\">

    I had to make many changes to make G4P compatible for Processing 3 and some bugs slipped in.

    I will fix this bug and release a new version of G4P very soon. :)

  • Thank you. :) That is the trouble of creating something like this, G4P. It ends up being a never ending process of updates and chasing bugs. I look forward to the correction. I am doing this as part of my hobby, so there is no great urgency on my part. Rick Harms

  • Hi Rick

    G4P was first released in March 2009 and the real challenges were when PS went V1>V2 and V2>V3 because of the significant changes to Processing's event handling and rendering methods. Even so there have been over 50 releases of G4P since then and I do have 10 other libraries and tools to keep updated. ;)

    Anyway the updated version (4.0.2) has been released, so head on over to the contributions manager and update G4P. (You may have to delete the existing version first)

  • YES!!!!! Thank you. One hurdle crossed, now many more. However, these are "learning Processing" hurdles. That was an unbelievable fast response.
    Rick Harms

Sign In or Register to comment.