Link to home
Start Free TrialLog in
Avatar of RdeLange
RdeLange

asked on

Problem with JFrames

I made an application. In this application I have an Jframe that shows all customers in a table. When the users double clicks an customer the program opens a new JFrame with the customer details.

My problem is that the first JFrame stays accessible. How to solve????

Avatar of bobbit31
bobbit31
Flag of United States of America image

make the frame with the customer details a modal JDialog:

from your initial form:
CustomerInfoDialog cid = new CustomerInfoDialog(this, "Customer Info", true);
cid.show();


public class CustomerInfoDialog extends JDialog {
   public CustomerInfoDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);

        // add your components
   }
}

}

Avatar of RdeLange
RdeLange

ASKER

Why using a dialog? Isn't a JFrame better? Because the user has to fill in a lots of fields.

you can put whatever components you want on a JDialog.
another thing you might want to try is:

when opening second frame call
parentFrame.disable();

when closing second frame:
parentFrame.enable();
oops, make that:
parentFrame.setEnabled(false);
and
parentFrame.setEnabled(true);
Yes, thats seems logic to me. I tried this but I see that my data on the first screen doesn't contain the updated data from the second screen.

How can I update that data?
ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial