aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Parent and Child JDialogs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Parent and Child JDialogs" Watch "Parent and Child JDialogs" New topic
Author

Parent and Child JDialogs

Olakunle Oladipo Oni
Greenhorn

Joined: Aug 28, 2008
Posts: 18
Of recent I've been undergoing some program design in the area of swing to acquaint myself with java's GUI capabilities. What I'm working at is with the basic intent of practicing to lead to competence and consequently create a basic application. The idea behind the application is a simple one: the components of this application are three. They include, a JFrame and two JDialogs. All three compiled without problems but one of the JDialog that serves as a child to the first did not show up as a result of the event that should have generated it from the first. The application is to make a basic calculation (addition) of a parameter like say 'salaries' from the first JDialog and on clicking the JButton 'ADD', a string displaying an aggregation of the result is expected to be appended to another JDialog emanating from the first. I'll be pasting the source code of both Dialogs on this page. I'll appreciate if someone can help me to figure out the problem and provide the clue. The JDialog that should give the final result didn't show ...I discover that to the appraise the problem better all the code should be pasted here. JFrame code is simply an authenticating code. I had no problems with that... I'll appreciate explanations is need be...



olakunle oladipo oni
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

Hi Olakunle,

I've added code tags for you to make your code easier to read. Please use them yourself from now on when posting code. I've also moved your post into our GUI forum where the real experts on Swing can take a look at it. Finally, if you can reduce code to the smallest working example that demonstrates your problem, you're much more likely to have people read your question and respond. Thanks!

Greg
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

As Greg implied, that's far too much code for anybody to read. However I just happened to look at the end of it, and noticed line 367. Are you sure you want to do that when the user clicks the "OK" button?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Also, from the design point of view, pop-up dialogs are often annoying and intrusive, so you should try and avoid them if possible. That means that "parent and child" dialogs are especially not a good design choice.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1083
    
  10

You have almost 30-40 lines of commented in code there...you could have removed that and reduced the size, thus helping us to help you.

As for your problem, in the class CalcDialog, you create a button 'bu', but where are you registering the action listener?
In short, there should be a call 'bu.addActionListener(this)' for your second dialog to appear.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parent and Child JDialogs