Axel Leucht

+ Follow
since Jan 19, 2009
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 Axel Leucht

I have just got email from oracle and I've passed SCJD

Thanks go to:
Roberto Perillo and Roel De Nijs for their help and encouragement.
The entire JavaRanch forum for helpful discussions and I wonder whether I'd have made it without.
Monkhouse & co for their SCJD book.
Oracle's OCP team for their friendliness.

8 years ago
I'm scratching my head with a problem I have.

My Data class is a singleton class. This seems natural to me as only one object should be instantiated for one database file and the single object is responsible for all file locking issues.

But this leads to difficulties with my junit test cases. In some of them I want to be able to connect to different database files. Definitely not a singleton. I can change the implementation to have a singleton object per database file, but I wonder if this is worth the effort as the application can only connect/operate on one database file.

I wonder how you solved the problem. I currently worked around it with a constructor which bypasses the already instamtiated object and creates a new one instead. Though this works, the implementation doesn't smell right to me, does it?

I'd appreciate if someone can share his/her ideas with me.
I'm currently in the finishing stage of my URLyBird assignment and do check my generated javadoc with the doccheck tool from SUN.

What concerns my is that the tool complains about one file mentioning it is missing tags for a particular method.

The class (A) implements an interface (B) and do /** {@inheritDoc}. */ for the three interface methods. I don't understand why it doesn't complain about the other methods but just one.

The generated javadoc html looks good. Some minor points I wonder are that method-1 gets "Specified by" sentence inside but method gets "Description copied from interface" and the third method (the one where dochceck complains about) looks good like method-1.

My assumption was that the dochceck tool should generate no warnings with the inheritDoc annotation when the javadoc of the superclass/interface are ok and should generate "Description copied from..." in the HTML file.

Does anyone of you have any hints as to how to handle this situation?

Thanks in advance.
Hi Roel,

thanks for you're input.

Do I understand you correctly that once you booked a room you can't book it again (and it stay booked forever) as it is now booked?

I reread my assignment and indeed the unbooking method isn't required, but this seems to be weird to me, isn't it?
I'm curious on my assignment (URLyBird 1.2.2) on the way how yoy guys handle the booking/unbooking of rooms.

I wonder which input do you request from the user when booking a room besides the 8 digit customer id. Do you for example ask the user to input the number of accommodations for the room?

And if you do, I wonder how you handle tihe unbooking of a room? When a room is booked lets say for 5 days, when do you let the user unbook the room? The booking period might be shorter, longer than requested. How do cope with it?

Thanks for helping.
I'm doing also the combo box approach. I also thought about refreshing the boxes as they might not reflect the database state. I come to the conclusion not to bother with it as a client might never be sure to see the latest state of the database anyway! That's why I have my combo boxes made editable, so even when the entry is not displayed the user can still type in what he liked to search for. I populate them once when the application starts and has to perform a search for all records anyway.

You're second problem with having dupes in the combo boxes, I also think this to be weird for the user experience. So I'm using a java.util.TreeMap and add all found entries to it and return a String-array from my helper method. The combo box are then filled with the contents of the array. This avoid the dupes and gives the additional advantage of the combo box being sorted.

Hope that helps.
I do have a problem with the GUI-Layout.

Problem is: Initially everything looks ok. But whenever I resize the panel to a very small size, the JTextfields "jump" to their minimum size. which looks very bad.

Here is some code to demonstrate what I mean and I would appreciate any help on this issue.

10 years ago
I don't let the user proceed without specifying the database location.

I'm disabling the Ok button in my JOptionPane and enable it only when the file exists, is readable and writable and has the proper magic cookie in its header.
I do searching for rooms (I'm doing the UrlyBird assignment) with two combo boxes for location and name respectively.

I might happen that the combo boxes don't display the current state in the database. This might happen e.g. when another client created a room in a new location. The new location isn't among the model for the location combo box. That's why I made the combo box editable. I load the combo boxes initially at application startup and as id is only possible for the client to search and book/release a room I didn't thought about it very much.

But I do wonder if an editable combo box is sufficient and I like to ask on how you do cope with this situation?
I do both:

Yucca Nel wrote:
You need to use a comparator for the record value object. Then what I did was substring whatever is after the currency symbol and cast it into a Double. Then use the compareTo(). This needs to be done for the rate field. The size field (if you have one also needs to have a comparator).

I know how to do it with a comparator.

Problem are with currencies more than one character long. For example the Denmark Kroner is abbreviated as 'kr', (two character) and the Switzerland Francis 'CHF' (three character).

But I will write a comparator for the size Attribute, which I forgot. I'll look into whether I can parse the currency with a regex-pattern.
I want to add that I check that the file exists and is writeable as well.
Sounds reasonable to me
I do sort the table.

Only problem is the rate field (I'm doing the URLyBird assignement) which has the curreny symbol included. Sorting on that column gives the lexical sorting and not the expected (numerical) sorting order. But I don't bother with this problem as I find that user expect the table to be sorted by clicking on the header. I can't think of an appripriate way to extract the currency information from the string field. Nowhere it is mentioned that the currencyl smybol is ISO 4217-compliant. So I stick with lexical sorting.

I only had to make sure that any selectred row stays selected after performing a search as the selected row might change and I have to find it again after the search operation and reselect it.
Indeed, my post might be unclear, so I'm trying to make myself a little clearer.

I'm opening a JOptionPane-based input dialog from within my actionPerformed method of my button's action class. The button's action can be invoked from the keyboard successfully only one time. The second time I type the mnemonic, nothing happens. It should, again, display the JOptionPane, right?

I wonder if some other component has the focus, because when I insert the call the have the mainwindow request the focus, I can successfully display the JOptionPane multiple times by typing the mnemonic. And I wonder why this happens only under Solaris and works ok in Windows.

I hope that my problem is now better described.