Creating a GUI

edited March 2018 in Library Questions

In G4P GUI builder, how do I display the contents of Dropbox on the textarea?Suppose if I select one of the contents of Dropbox how do I display it on the textarea?

Answers

  • You can get the selected option from the GDropList with

    droplist.getSelectedIndex()  // returns an int
    droplist.getSelectedText()  // returns a String
    

    You can add test to a GTextArea with

    textarea.appendText(String s);  // adds to end of existing text
    textarea.setText(String s)  // replaces current text
    

    You should also look at the online reference for G4P.

    BTW if you want to get my attention in a discussion just include @quark in the message (this works for any member). Please do not duplicate the question on my wall. Thanks.

  • Thanks. If I want to display default statements on text area what command should I use?

  • If I want to display default statements on text area

    Not sure what you mean?

    You can have prompt text with

    textarea.setPromptText(String s)
    

    Prompt text appears only when the textarea is empty but is never returned with getText(). This is used to indicate what information is expected to be entered.

  • INitially you can just use textarea.setText(String s) in setup ()

Sign In or Register to comment.