> when I press just OK,
> s should be "",
> but if I ask in my program :
> if (s=="") ...
> the result of if statment is false.
You want to dig out a Java text book and learn about how to do proper
string comparison in Java. You are not comparing string contents in your
code, you are just comparing string references. You would have to be
lucky if these two references indeed point to the same string.
> why (s==0) doesn't work properly ?
Again, get out a text book about Java. This is basic Java syntax. A
string is not an integer, and there is no such thing as an implicit type
conversion between String and int. If you want such stuff, try C or C++.
There you can compare some integer value with a pointers to some memory
area which might or might not hold a string.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Eitan M - 04 Apr 2006 12:36 GMT
Sorry,
for my question, I have ment :
> why (s=="") doesn't work properly ?
instead of
> why (s==0) doesn't work properly ?
(s=="") returns false, even I just press OK button.
Why ?
Gregor Kovač - 04 Apr 2006 12:45 GMT
> Sorry,
> for my question, I have ment :
[quoted text clipped - 6 lines]
>
> Why ?
Maybe because == compares refereces and not values ?
Do (s.compareTo("") == 0)

Signature
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gregor.Kovac@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Luc The Perverse - 04 Apr 2006 12:48 GMT
> Sorry,
> for my question, I have ment :
[quoted text clipped - 6 lines]
>
> Why ?
I'm not sure you listened to Thomas.
But s is an object (I'm presuming of type String) and "" is an object. The
== operator will only tell you if they are the same object.
Try ("".equals(s))
--
LTP
:)
On Tue, 4 Apr 2006 10:24:21 +0200, "Eitan M"
<no_spam_please@nospam_please.com> wrote, quoted or indirectly quoted
someone who said :
>if (s=="") ...
>the result of if statment is false.
[quoted text clipped - 5 lines]
>instead of
>if (s == 0)
see http://mindprod.com/jgloss/gotchas.html#COMPARISON

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.