[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gzz] fourth PEG cursors--humppake: Changing mouse cursor
From: |
Tuomas Lukka |
Subject: |
Re: [Gzz] fourth PEG cursors--humppake: Changing mouse cursor |
Date: |
Mon, 12 May 2003 17:09:44 +0300 |
User-agent: |
Mutt/1.4.1i |
On Mon, May 12, 2003 at 04:57:05PM +0300, Asko Soukka wrote:
> Mon, 12 May 2003, Tuomas Lukka kirjoitti:
> > > * "WAIT_CURSOR" The wait cursor type.
> > > */
> >
> > ISSUE: Do we *really* want all arguments to this method have the _CURSOR
> > suffix?
>
> I would prefer it, since then they'll be similar to constants
> in awt.Cursor. If that's not a good reason enough, then we may drop the
> suffix.
They're similar without the suffix as well, especially if you mention
that. In awt.Cursor there's a *reason* to have the suffix: they are
data members of the class and it makes sense to separate the namespace.
Here, that doesn't make sense.
> Benja?
>
> > > if (cursorName == "CROSSHAIR_CURSOR")
> > > cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
> > > else if (cursorName == "DEFAULT_CURSOR")
> > > cursor = new Cursor(Cursor.DEFAULT_CURSOR);
> ...
> > > else throw new IllegalArgumentException("Unknown cursor:
> > > "+cursorName);
> > > canvas.setCursor(cursor);
> > > }
> > Using reflection is also possible.
>
> Reflection? Please, explain.
In Java, you can get the field of the Cursor class through
Cursor.class.getField(name+"_CURSOR").
> > > cursorName == "SW_RESIZE_CURSOR" ||
> > > cursorName == "TEXT_CURSOR" ||
> > > cursorName == "W_RESIZE_CURSOR" ||
> > > cursorName == "WAIT_CURSOR")
> >
> > That code won't work. Can't compare strings using ==.
>
> Of course :/ -> String.equals().
>
> Mudyc told that std::strings in C++ can be compared
> using '=='. Is that correct? So, the difference is that
> operators can't be overloaded in Java.
Yes, that's right.
But to confuse things further, in Java, there *is* a special case where
you *can* compare strings with == : if you *know* that both strings
have been interned.
String a, b;
if(a == b) {} # true if both point to same instance of string,
# which can vary
a = a.intern();
b = b.intern();
if(a == b) { } # true if originally a.equals(b).
This is handy for us, we use interned strings as keys in our RDF swamps.
Tuomas