Hey All!

I'm working on a database access project and have most things working pretty well, with one glaring exception.

I've got a JInternalFrame form with 13 data fields to act as a front-end for a table in my database. Most of these data fields are JTextFields, some two are JRadioButtons, one is a JCheckbox and the last one is a JCombobox.

To prevent accidental data editing, I lock the text fields down by setting JTextField.setEditable(false) and disable the other controls. I have the following method in my form:

    // Locks the form from allowing accidental edits.
    private void unlockForm( boolean unlock ) {
        this.isModifying = unlock;
        // Set up the toolbar.
    } // End of unlockForm() function.

If I call this method from a toolbar button ActionPerformed() event and supply `true' as the parameter, it should set the editability of the text fields to true and also enable the other widgets. This seems to work pretty much as expected, except with my txtCity field, for some reason.

When I click on my edit or add toolbar buttons, they call the unlockForm() method with the parameter set to `true'. However, when I attempt to change the data in the txtCity field, it acts as though it is still not editable. So, in an attempt to figure out what is going on here, I placed the following code in the FocusGained() event for the txtCity textbox:

        // DEBUGGING CODE:  Remove before release build!
        // The following MessageBox is being displayed because I can not find
        // the reason for the city field to not unlock and, yet, it will not
        // unlock for editing.  I need to figure this out!
        MessageBox mb = new MessageBox();
        String msg = "The following are the settings of the city text field:";
        msg += "\n-----------------------------------------------------\n";  
        msg += "txtCity.getName() = " + this.txtCity.getName();              
        msg += "txtCity.getText() = " + this.txtCity.getText();              
        msg += "txtCity.isEditable() = " + this.txtCity.isEditable();      
        msg += "txtCity.isEnabled() = " + this.txtCity.isEnabled();   
        mb.codeRequired(msg, this);                           

Now, when I click on the txtCity text field, I get this message box as expected, with one glaring problem. I get it more than once. Then, when I click on another control, I somehow go into an infinite loop of this message box being displayed and cannot get out of it.

Does anyone have any ideas as to what is going on? Maybe you could point me to a web site or book that actually has this problem and shows how to resolve it. I am at a complete loss as to what's happening, especially since I don't have any code in my FocusLost() event that points to my FocusGained() event. Any help that you can provide will be greatly appreciated.

If it would help to see what the form looks like, you can view it here:


Thank you for any and all help you may provide.


Sean C.
PekinSOFT Systems