Dan Kempten

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

Recent posts by Dan Kempten

This is my hopper which hops in 1 second intervals. I can call 5 1 second hops with fiveHops() and it will
function fine the first time.

However the second time I call fiveHops() it has an java.lang.IllegalThreadStateException

for timing reasons I don't want to call hopper = new Hopper() each time I call fiveHops()

How can the hopper object be reset in sufficient manner to stop calling this exception??

is a Thread object meant to always be used once and then discarded??

Thanks Campbell, this setFocusable(...) was new to me.

I added this in the ctor and now it runs just fine.

10 years ago
Xy xyOne;
Xy xyTwo;
Xy xyThree;

This problem has been resolved but I am not sure how.
10 years ago
Arrays are awful

After dealing with arrays like this : XyArray myXyArray = new XyArray[20];

and all that kind of stuff I've stepped up into : List<Xy> myXyArray = new ArrayList();

Still I find that when my List<Xy> array has three objects, with name attributes "One", "Two", "Three"
and I delete the object "Two", then the List<Xy> array *still* thinks that it's size is 3

Example : I do this :

and it thinks that when i = 0 the object is "One"
when i = 1 the object is "Three"
when i = 2 !!! hey !!! why is size() still 3 ???

Question : must I extend List / ArrayList to add the concept of reducing size after removing???
Or is there an Array class with this included already in existence???

Thanks for any tips.
10 years ago
Thank you Steve.

That is one of the clearest, most informative answers I've ever read here. I don't think you used the word 'implement' a single time.

P.S. Don't you think these examples from Oracle.com are unhelpful? I wanted an example of a listbox component and they swamp me with all this exotic code.

I ask for a steak in a restaurant and they trample me with a herd of 50 steers.

If I ask to see an example of a shower curtain, they hand me a 20-floor Hilton Hotel as an example. It always takes a while to find the bathrooms.
11 years ago
I'm looking at an example from the Java Tutorial on page


It shows how to use the Swing JList listBox , or rather professes to show...

Basically ListDialogRunner builds a frame and holds the main() and calls ListDialog (with a frame) which holds the focus until it is closed.

In the ..Runner static class (which contains the main()) it calls a static function in ListDialog class, a normal non-static class.
This static function then calls the private (!!!) constructor of ListDialog and the second window pops up.

Only when the second window is closed and returns a string does the code in ..Runner continue to march.

Seems to me a very strange way.

What do you think of ..Runner calling up the second window the normal way, using
a public constructor in ListDialog and then upon closing, sending the string value back to ..Runner to be displayed in the ..Runner frame?

1. This way, if ..Runner gives birth to this new frame/class (with a public new) is a second seperate thread formed for ListDialog and
is ..Runner still able to react to buttons pushed on its frame with its own thread.


2. is giving birth to a new class from ..Runner actually handing the one and only thread in the world to the new frame/class and leaving ..Runner in a state of suspended animation?

11 years ago

that's heartening to hear. I kept thinking, 'there must be an easier way, this is nuts.'

I'll try out your suggestions as soon as possible.

Thanks muchly.
12 years ago
I just tried it out in Eclipse Europa.
Same 10/20 result.
And I tried the @Override annotation and got a good little message when it didn't compile :

This method isn't overriding the superclass method because :

the superclass method is private to a different package

So the method is not really overridden and polymorphism doesn't apply.

Very interesting. Thanks to Steve Luke and the others.
14 years ago
Hello all,

I didn't realise this would unleash such a fury. But thank you all for your input.

FYI I have been using Java 1.6 and Netbeans to create the whole spiel.

I find this all very fascinating because I will be taking my SCJP in about 6 days.

In about 12 hours I'll get back to this thread and give it a try on Eclipse.
14 years ago

This is one for the theorists :

Very simple :

I have two classes, Top and Bottom
Bottom is a subclass of Top
Bottom overrides the method int foo()

BUT ! in the parent, int foo() has default access (package)
in the subclass I have it public int foo() with public access

now..I have the class Goof :

Goof is in the same package as Top,

now the overridden function foo() is defined not by the
class of the reference variable, but from the class Bottom in
this case.


So I should see top 20 the Bottom class definition of foo()
and bottom 20 the Bottom class definition of foo()

Right? That's what polymorphism says.

however with Goof.class in the same package /top
I get :

top 10
bottom 20

default access of the int foo() in Top class makes
polymorphism no longer valid.

14 years ago

is CheckPU the name of your jdbc database?
One thing is obvious.
In one part of your code you put @EJB above class xyz.

I've been working with this for a couple weeks and this is not how I use the EJB annotation.

You should put the @EJB above an instance variable that represents the Bean you wish to inject.
And keep it inside the class.

I use it in a web app or a client app to replace this code :

with this code :

I'm no expert but could you show the contents of persistence.xml in your project?
check out whether you create tables or create and drop tables.
Here's mine.

And persistence context type?

Bear Bibeault wrote:Why not just grab Tomcat and focus on Servlets and JSP until you have a working knowledge of those?

You can skip all the EJB stuff until (if ever) you need it.

I agree with that.

Doing J2EE you sometimes have a component in JSP and it is worth your while to understand that well before attacking the Land of Beans (EJB).
I began with the 2nd one, Glassfish EE. It has the Derby database aboard and that's enough to start with.
If you don't have JDK already installed in your system then the 3rd one is what you need.

At least Java 5.

I've been through a bit with J2EE EJBs, in my entry an hour ago I wrote about using Netbeans as an IDE and
making session and entity beans work. That might help.

And get a good book and learn the words, persistence, mapped, clean, deploy, and such.

Good luck.