I have a few JDialog's that I need to create which have similiar characteristics. i.e. one has: Enter ID:__________ Enter Password:__________ Re-enter Password:__________ The next one might have the exact same thing but without the reenter password. There are two others that vary a little more than these two but have some of the same items. In order to simplify the process I was going to create a BasicJDialog class with a few different constructors and methods. Like a addLabel( String s ). That way BasicJDialog is having to do all of the layout work and the calling object only has to tell it what it want's. Okay my question is this. I created this and it works fine with the exception of the method outside the constructor. It compiles fine but during runtime it doesn't add the label I'm calling for. I also took the hasID out and made it a method to call from outside and it works inside the constructor but not when being called from the method. Here's the code:
Any help would be much appreciated. Thanks, Joe
Joined: Jan 09, 2001
Hi Joe, One problem I see right away is that your method is trying to use genericPane which is only local to your constructor. If you want any other method to use a component then you need to make them class variables. I think that is your entire problem.
I am not sure about your adding the genericPane twice in the dialog. You might have two of them when you are done (i.e. one behind the other!) ... Manfred.
Joined: Jan 08, 2001
Thanks. I also forgot to add: genericPane = (JPanel) this.getContentPane; It works now and by the way whether I call genericPane.add(JLabel); once from the method or twice (once in the constructor and method) I get the same result. Although I'm sure it's much cheaper and easier to read with one call... Joe [This message has been edited by Joseph Russell (edited February 02, 2001).]