Jim Henessey

Ranch Hand
+ Follow
since Sep 13, 2003
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 Jim Henessey

Thanks for the help on this. I'm using a BorderLayout manager inside a GridLayout. Gridlayout is being because most of it consists of two columns - a label with an input field next to it. The BorderLayout is used for a list of input fields for placing in song and artist information - I want the first box right-aligned and the second left-aligned.

One possibility is to use a simpler layout here - list a series of panels using BoxLayout, and then distribute the input fields with a simple FlowLayout, making sure there's not too much space between them by keeping the width of the individual panels narrow.

I've listed a small code sample below. Whether or not this gives you anything else to respond to, thanks for the help so far.

17 years ago

I'm having major issues with my JTextFields blowing up in size, to fill an entire panel (or sometimes exceeding the width of the panel). I set the length of the field to a reasonable number, and set the preferredSize and maximumSize of both the field and the containing panel. Yet I still have problems with the JTextField either being too small (I put in a very small number, say 5, in as the textfield length) or blowing up to an unreasonable size (any field length that would be needed for form input, 20-40 characters).

What am I doing wrong that the textfield size is so out-of-control?

17 years ago
Thanks for all the help on this one I really appreciate it.

Mike - I should have used a different term than "caching", which I'm misusing in this sense. I supposed a better definition of what I was looking for was objects with a persistent lifespan which immitate those objects declared outside of any class in a weaker OO language.

David - I was considering object references / static fields in a separate class. I'll look into the thread option as well.

Stan - I can appreciate the strengths of this approach. By limiting access to data, the programmer needs to look at only a small number of places where data might have been corrupted. I just found that I was passing around certain data parameters all over the place and was wondering if there was something I was missing here - I like to know if there's an easier approach to something early on when learning a language, rather doing things the wrong way for a few years.
17 years ago

I have an app which pulls data from an XML file, places it in arrays and then does heavy sorting/re-distribution of the data given various specs. My question is:

Is there anything out there in java I can use to store my array data, so I can avoid having to pass the array data around from object to object? The alternative to this would be to keep pulling the data from the XML file and doing the re-distribution each time, which is just too damn expensive.

If the above explanation of the problem isn't sufficiently clear, let me know and I'll try for greater precision.

Thanks for the help - java ranch has been invaluable for learning and improving my java skills.
17 years ago
Everyone, thanks for the help on this one. Pascal - thanks for focussing my mind on the ultimate problem. The list wasn't empty, but it was always containing only one item (calling line was in the wrong loop) - when list contains only one item, compare isn't even called.
17 years ago
I'm working on a simple app to keep track of my cds. Development has been going well, but I'm running into problems with an arraylist sort - it sorts the cds alphabetically that fall under a specific letter. The problem - my sorting methods, whether I implement them in a Comparator.compare or compareTo don't seem to be called.

Here's my Comparator compare method:

Method is called by the line: Collections.sort(letterSequence,new LetterCompare());

letterSequence is an arraylist - based on a check in another part of the program, all objects added to arraylist have a non-null album title field.
All other parts of the program are working properly.

I've tried putting similar code in a compareTo method in the AlbumData class, as well an inner class in the Collections input - it just never seems to be called. When I change the return to a straight "return 0", "return -1", "return 1" - the order is unaffected.

As a last measure I've tried putting System.out.println(...) in the compare method to check if it is even being called, but nothing is printed - whether that's the nature of the method or another sign that the method isn't called, I'm not sure.

This seems to be a very basic sort, close to all the examples I've seen - what am I doing wrong?
17 years ago
You're completely right - this was a "duh" moment for me. For some reason, I always thought that Gracenote/FreeDB was called in only if the information couldn't be found on the cd itself.

For those who come across this thread for whatever reason, a useful class for determining the discid (necessary for retrieving the information from an on-line database) can be found at:


With the accompanying c library for windows at:

17 years ago

I'm writing a program for myself to keep track of the cds in my cd collection. In order to avoid the tedious task of having to type in the title/artist info for each track on the cd, I would like to have an interface allowing me to read the info off of the cd in my cd-rom drive.

My question: how do I do this? I've had a rough time searching for this on google - I know the javax.sound library is used for ripping the music off of the cd, but I'm unable to find out how I pull the title/artist info - I have no interest in pulling the songs off of the cd for this app.

If anyone can help me with this, I appreciate it. I searched for threads dealing with this subject in this forum but found none - if I missed it, and this has been previously answered, a link to the previous answer would be more than enough.
17 years ago

I'm wondering if there's an alternative, more efficient way of doing something
I'm trying to do:

I have a class which generates a frame, which in turn contains two panels. The panel on the right contains a combobox which, when selected, changes the image in the left panel.

Right now for things to work properly, I have to pass the left panel object to the class which creates the right panel, which in turn passes the left panel object to the combo box's action listener.

Is there any way of getting around this? Is it possible to reference an object created outside of a specific class, without it being passed (either as a parameter or through methods) to that class?

If the information is out there, pointing me in the right direction is sufficient - I just haven't managed to find the answer to this so far.

Thanks in advance.
17 years ago

Both File 1 and File 2 above will be valid according to the schema.
That said, I fail to understand why you need to make sure that the attribute index and the attribute name need to be fixed. Maybe I am missing something.

Thanks for the rapid reply on this - I really appreciate it. I don't necessarily have a need that the name/value always be in the same position - the combination of laziness/curiousity which compelled me to be a programmer made me wonder whether I needed to always iterate through the attributes, or whether I could save a step by assuming that an attribute could always be found at the nth position. Secondly, if a manager or developer unfamiliar with java ever asked about this, I wanted to give a definite "no, that's not possible", rather than "i'm not sure, i don't think so".

Thanks again.

(edited because tags got a little wonky)
[ November 30, 2004: Message edited by: Jim Henessey ]
I need to go through several nodes, always checking for the value of the same attribute. For each node, I currently have:

Just curious: do I always have to iterate through the attributes, or can I assume that attrs.item(n), say, will always be a specific attribute name/value set for each node? In other words, for a series of elements of the format <day id="(id number)" month="(month name)">, can I assume that attrs.item(0), is always the id attribute? Are there ever circumstances where I can do this, or is the order always random?


Edit Comment:
Attempt to format the post so that its more readable. Not sure this will work.
[ November 30, 2004: Message edited by: Madhav Lakkapragada ]

Originally posted by Madhav Lakkapragada:
psssstttt......you left out a key peice of info in that link that you
posted. From the DocumentTraversal section of the XML API link that you
posted -

So, I would change the code and invoke the hasFrature("Traversal", "2.0")
API and then see what type of results you get.

Please do let us know what you find.

- m

Oh wow - thanks for catching that. That is the source of the problem - when I do a test, I get back that the feature doesn't exist. I'll look for options around this.

Thanks again for your help.

I am getting a ClassCastException with the code listed below.
The problem is with the line: "DocumentTraversal traversal=(DocumentTraversal) doc", where I get a java.lang.ClassCastException error.

A similar problem was brought up at Previous JavaRanch Topic - what am I doing wrong?and answered by someone with considerable authourity - however, as far as
I can tell Document to DocumentTraversal casting is permitted:

XML APIs Quick Reference
(under the DocumentTraversal section)

Also, most of this code (including the casting) is from the relatively authouritative ibm site:
Using a DOM NodeFilter

Code follows below:

Edit Comment: Added [ code ] [ / code ] tags, without the space.
[ November 02, 2004: Message edited by: Madhav Lakkapragada ]
My bad.

I was getting this error because the project I created wasn't a Java Project.
Moderators, feel free to delete this topic.

I'm just going through "The Java Developer's Guide to Eclipse" and trying out the various feature tests. Things have been going fine so far - however, when I try and use content assist/code assist, I'm told "This compilation unit is not in the build path of a java project". They don't mention this error in the book - any idea what I'm doing wrong? Thanks in advance.