scott beveridge

Greenhorn
+ Follow
since Mar 03, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by scott beveridge

Thanks for the suggestions, I had declared the ArrayList with a value of "null" at the start of the class. Removing this declaration works fine. I can only assume this was a really bad thing to do, but don't really know why.
FYI the (stringToObject()) was in response to the first thing I tried not working, which was as Vijay suggested. I was trying to guess where I made my error.
You can probably tell I'm making this up as I go, and I should warn you to be prepared for more silly beginners questions.

Anyway, it didn't work till I asked for help so I'll credit you guys for fixing it and slink sheepishly back to (blindly) hacking out more mistakes.
Thanks,

Scott
19 years ago
I'm using a string tokienizer to seperate a string then storing the tokens in an arraylist. I also want to add my own string before each token and I can't just use an array because of later operations.

This code gets a NPE when it runs, and my IDE doesnt like the "stringToObject()"- would someone mind pointing out my mistake.

Thamks guys.

Scott
19 years ago
Thanks for the replys gentlemen, they were a great help. I now have something which does what it is supposed to, so its on to stage 2.

The first time I heard of a callback was when Stan mentioned it in his post. After much research and experimentation I can move on. All those books about java apparently teach you only how to write code, not programs.

So thanks again, and expect more questions.

BTW, Stan I looked into your sig line- very cool stuff.

Scott
19 years ago
Oh sorry, the dependency exists between more than two classes.
What I want to do is farely simple: take an input and pass it to an object, perform an operation on it and pass it on. Eventually it is passed back along the chain in the reverse order. Surely there is an easy way to do this?
19 years ago
Hi,

I'm trying to get a few classes to call each other's methods. It's been driving me nuts for a while and eventually I read that this was a cyclic dependency, which I understand is bad and symptomatic of poor design, probably true in this case.

My qustion is what code do I need to add to allow B's methods to call A's and vice versa?

Thanks.

Scott
19 years ago
Hi,

Inside an event handler I want to send text to a seperate object. If I create the object inside the handler it works, but if the object is created by a different class it doesn't, even though the other class is coderanch. How do I connect the method inside the handler to the object outside?

So I want to do this and it doesn't work,


But this works,


Thanks guys, this is tough at first but I'm slowly getting it.

Scott
19 years ago
Yeah I've tried both TextArea and JTextArea, usually not at the same time (that doesn't work either).

I think the problem is a mistake in scope somewhere.
I'll keep trying and thanks for your input.

scott
19 years ago
Thanks for the reply. This still does not work.

I originally had this but changed it because:
When I try this now I get a compile error of

"cannot resolve symbol:
auditJTextArea = new JTextArea();"

and of course everywhere that references it.

I've retyped "new JTextArea()" a thousand times but still no joy.

Scott
19 years ago
Hi,

I get an NullPointerException when I try and call a append() or setText() method for a JTextArea but not a JTextField when everything else remains the same. Here is the revelant code.



Then from another class file.


As I said setting the JTextField works fine, but I get an NPE pointing at both references to the JTextArea, please someone tell me what I've done wrong. I'm using JCreator and XP.

Thanks,

Scott

[ June 11, 2005: Message edited by: scott beveridge ]
[ June 11, 2005: Message edited by: scott beveridge ]
19 years ago
Thank you Ernest,

And yes it does help very much. Next on the learning curve is hashmaps. The objects all have the same base class so I may adjust things to make it easier. Its just a matter of working out exactly what has to happen.

I was intending to use a database for something else, but after re-reading your post a few times you gave me an idea.
Can multiple maps be used to store a reference to code that will be chosen from at run-time? Like maybe handed to a new thread while the main one is halted to wait for the return? Even if the reference was just to a file location containing the code.
With something like that I could avoid using (learning about) a database entirely and store everything in a seperate file.

Then again the size could run to a few hundred entries, is that an acceptable overhead for the map?

My turn to think out loud.

Scott
20 years ago
Howdy pardners,

Can someone please tell me how to reference objects through the type or value of their variables, rather than the actual reference.

This is a program idea I had that prompted me to start learning, so I don't have any code yet, but essentially I want to say this in Javanese:

PERFORM {operation} ON (object with variable of type X)
or/and
PERFORM {operation} ON (object with X as the value for any variable).

My thinking at the moment is to put everything in an array then loop through it and use exceptions. Or design the classes in some fiendish manner which currently eludes me.

Please tell me the easy answer or point me to where I can find it.

Thanks, you guys have helped me a lot already.

Scott
20 years ago