Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:35:40+00:00 2026-06-13T06:35:40+00:00

I am currently coding a gui and want to verify that the user fills

  • 0

I am currently coding a gui and want to verify that the user fills in the textbox a String. I tried that:

String name = textBoxes.get(0).getText();
if(name.isEmpty()) {
    showError("Pls insert a name!"); 
} else{
    name = textBoxes.get(0).getText();
}

But that really does not work? It seems to be that there is sth. “inside” the textbox, even if I do not fill sth. in.(I tried sysout and got that:

'                            '

So my question is, how to verify if a textbox is empty or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:35:41+00:00Added an answer on June 13, 2026 at 6:35 am

    It sounds like your textBox is returning a string full of space characters. Try using name.trim().isEmpty() instead of just name.isEmpty() to remove those extra spaces before you do anything with it.

    trim() removes leading and trailing white spaces.
    See: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#trim%28%29

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently coding setup.py using setuptools. And I want to copy the static
I am currently coding some chat program and now want to play music via
I'm currently coding a little download manager and I get a funny output when
I am currently coding an application that involves navigating between pivot control. There will
I'm currently coding a simple search script in PHP that requires three variables from
I am currently coding a HTML website into wordpress. The problem that i'm having
I have been coding an application which renders tiles and GUI and all that.
I am currently coding a web page that allows users to change local settings
I'm currently coding a site and I want to know the best alternative. Should
I'm currently coding a MEX file that needs to run as quickly as possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.