• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrong output and exception problem

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
need help in identifying what is wrong with my code especially the hypergeomeyric method which when ever i execute it,it display an understandable exception in command prompt.also the poisson method only display the correct result when r=0 but result when r=1 to n.thanks for ever listening hears.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

please describe what exceptions you get with which parameters! It would be much easier to help like that.

Anyway, I have run your code, and I got the following exception when trying the Hypergeometric Distribution:

A short inspection told me that NField (and the others as well: nField, rField, etc) are null. Please have a look at the GUI building code. NField is declared as:

It is redefined locally, so no wonder that the NField member in the class is null. Compare this with the field initialization for the Poisson tab:

These errors can be very annoying, but should not be hard to find. The exception above is very clear about what the problem is: a null reference in the actionPerformed method. So you should just find which reference is null. Using an IDE with a debugging option (nearly all of them) can help much, as it can show you which one is the culprit just by moving your mouse over them.
[ November 17, 2006: Message edited by: David Nemeskey ]
 
David Nemeskey
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, one other suggestion:
in the main method, you should call f.setVisible() as the last instruction.

Why?

You may remember, that according to the Swing threading model, all modifications to an already visible GUI must be run in the event dispatch thread. This applies to your program from the moment you call f.setVisible(). When I first ran your program, it just displayed an empty frame, as the c.add(cm) "did not make it" to my screen.

Please have a look at the Swing tutorial at Sun.
[ November 17, 2006: Message edited by: David Nemeskey ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
reply
    Bookmark Topic Watch Topic
  • New Topic