Jump to content

[1.12.2] How to remove all the text from a gui text field?


WaningMatrix

Recommended Posts

I just simply want to remove the words from a Gui textfield, is there some simple way to do that or I have to redraw the text field?

like say

if (!TextField.isEmpty){
  System.out.println("You have run this part!");
  if(TextField.getText == "some invalid thing"){
    TextField.clear();  // How do I clear the text already written inside this text field.
  }
  else{
    System.out.println("Do the stuff you wanted to run");  
  }
}

unknown.png

intelliJ shows this deleteWords in all the available things, but is this what I need? If yes what is p_146177_1_ int type here?

Link to comment
Share on other sites

On 3/13/2019 at 2:20 PM, diesieben07 said:

GuiTextField#setText("")

Also, you can't use == to compare strings, == does instance comparison. You need equals.

Thanks.

Yeah I know about that, I just wrote an example code there for explanation sorry for that.

Edited by WaningMatrix
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.