Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JtextField returning empty!

1 view
Skip to first unread message

tamasu

unread,
Nov 8, 2009, 3:57:48 PM11/8/09
to
Hi,

I am trying to read text from a simple Jtextfield using the syntax

String StrRound = txtRoundName.getText();
if (StrRound.equals("")) ... etc

I am also using the method dispose() to close the window. Since when
the window is re launched the previous contents inserted in the
txtRoundName is displayed, I had to clear the fields using
txtRoundName.setText(""); in a separate method.

I found out that when enabling the setText(""), the condition if
(StrRound.equals("")) is returning that the string StrRound is empty
(actually the user keys in some data). Whilst, when I remove the
statement txtRoundName.setText("") everything works fine.

The window is instantiated through a separate class.

Could you highlight why this is occurring?

Thanks

Knute Johnson

unread,
Nov 8, 2009, 9:13:49 PM11/8/09
to
tamasu wrote:
> Hi,
>
> I am trying to read text from a simple Jtextfield using the syntax
>
> String StrRound = txtRoundName.getText();
> if (StrRound.equals("")) ... etc

Nothing wrong with that.

> I am also using the method dispose() to close the window. Since when
> the window is re launched the previous contents inserted in the
> txtRoundName is displayed, I had to clear the fields using
> txtRoundName.setText(""); in a separate method.

I don't think dispose() will do anything to the value entered into your
JTextField.

> I found out that when enabling the setText(""), the condition if
> (StrRound.equals("")) is returning that the string StrRound is empty
> (actually the user keys in some data). Whilst, when I remove the
> statement txtRoundName.setText("") everything works fine.

It's not really clear what you are doing.

> The window is instantiated through a separate class.
>
> Could you highlight why this is occurring?

Not without some code and preferably an SSCCE.

--

Knute Johnson
email s/nospam/knute2009/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Lew

unread,
Nov 8, 2009, 10:01:48 PM11/8/09
to
tamasu wrote:
>> I am trying to read text from a simple Jtextfield using the syntax
>>
>> String StrRound = txtRoundName.getText();
>> if (StrRound.equals("")) ... etc

Knute Johnson wrote:
> Nothing wrong with that.

Well, one slight deviation from the Java coding conventions - variable names
are supposed to start with a lower-case letter conventionally.

Knute Johnson wrote:
> It's not really clear what you are doing.

tamasu wrote:
>> The window is instantiated through a separate class.
>>
>> Could you highlight why this is occurring?

Knute Johnson wrote:
> Not without some code and preferably an SSCCE.

+1

<http://sscce.org/>

--
Lew

0 new messages