• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Parent and Child JDialogs

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 26697
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 26697
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic