Fred Hosch

Author
+ Follow
since Apr 16, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fred Hosch

there's probably an easier way, but take a look at getLocalHost
java.net.InetAddress. you can then use getHostName.
22 years ago
no, java doesn't have a macro preprocessor. but maybe gcc with
a -E switch... ;-)
22 years ago
Thanks to everyone. Most of my questions got answered ;-)

------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
yes, JFrame is-a AWT Frame -- a heavyweight component that has
a "peer" in the native windowing system, with all the overhead
that implies.
JFrames have lots of structure, of which the content pane is
only one piece. A classic case of paying the price of complexity
for flexibility.
(Remember this is a "2nd generation" design; lot's of the
"why'd they do that?" questions are answered "because the AWT
was already there, and they couldn't start with a virgin
sheet of paper.")
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
In my experience, this is almost always a CLASSPATH problem.
Are you sure the process you're running has the same CLASSPATH
as the one you're looking at? Does it find other classes in
the same package as the lost one?
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
Mike: yes, you're right. My error.

------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
Actually, this.limit should work just fine as long as KeyAdapter
doesn't also define limit.
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
by "static" i mean "compile time type." (whoops! "static" has a
special syntactic meaning in java doesn't it?) that is, bc is
declared to be BaseClass; the compiler types each occurance of
the identified "bc" as "BaseClass." the fact that at run-time bc
actually refers to a DerivedClass instance matters only when
an overriden method is being invoked.
so as far as the compiler is concerned, you're trying to
invoke a protected method of a BaseClass from inside the
definition of DerivedClass. that's not allowed, unless
BaseClass and DerivedClass are in the same package.
the other way around is ok. if bc was declared to be
DerivedClass, and the invocation bc.protectedMethod() occured
in the definition of BaseClass, all would be fine.
"lrm" is "language reference manual" -- i.e., "The Java
Language Specification 2nd Edition."
sorry about the confusion :-0
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
not sure if this is what you're looking for, but java.io for
instance has many examples. BufferedReader wraps (and extends)
Reader, InputStreamreader wraps InputStream, etc.
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
well, in the unix world there's a magic number at the start of
the file that you can check. (man magic). god only knows
what things look like in the devil's workshop.
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
anybody have any problems with KeyEvent.VK_BACK_SPACE in 1.3?
i have a key binding to VK_BACK_SPACE in a JTextWindow that
is generating two action events for each key stroke. when i
change the binding to '\b', i get one event! (the code worked
fine in 1.2.2).
(yeah, i know i should check sun site.)
22 years ago
Didn't i post this reply already?
there is no overriding going on here, so the fact that bc references a DerivedClass at run-time is a red herring. it is
completely irrelevent. the static type of bc is BaseClass.
now the lrm states that a protected member may be accessed from outside the package only by code "responsible for the implementation of the object." that means that the invocation
dc.protectedMethod() (where dc has static type DerivedClass)
can appear in the definition of BaseClass or inthe definition
of DerivedClass. But bc.protectedMethod() cannot appear in
the definiiton of DerivedClass, UNLESS DerivedClass and
BaseClass are in the same package.
a major KLUDGE? 'tis.

------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
First of all, since there is no overriding going on here, the
fact that bc refers to a DerivedClass instance at run time is a
red herring. it has no relevance at all. the static type of bc
is BaseClass.
Second, the lrm state that a protected member may be accessed from outside the package only by code "responsible for the implementation of the object." That means that dc.protectedMember() can appear in the definition of BaseClass
or of DerivedClass (where dc is declared to be of type DerivedClass), but bc.protectedMember() cannot appear in DerivedClass, UNLESS DerivedClass and BaseClass are in the same package.
is this a major KLUDGE? imho, yes it is.
22 years ago
Just a matter of precedence. ++ has higher precedence than =.
java guarantees that every operand "appears to be fully
evaluated " before any part of the operation is performed.
the postfix increment assigns 11 to i, but delivers 10 as
its value. this is tehn assigned to i.
interestingly, this statemetn is not permitted in ansi C.
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago
or could be a CLASSPATH problem -- what's your environment?
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java
22 years ago