Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I wrote a calculator similar to the windows calculator using Java. And now I want to integrate this calculator into other projects as a separate package and use results obtained with the calculator in these projects with a single click (not using copy and pasting). How can I do this. (I'm using Netbeans to code Java)

share|improve this question
Perhaps posting more info would help, what exactly do you want the program the calculator to do? –  Bugster Feb 21 '12 at 6:15
I want to transfer values obtain from calculator directly in to other projects. –  chathurawidanage Feb 21 '12 at 6:50

1 Answer 1

up vote 4 down vote accepted

You did not post any details but I'm going to suppose that:

  • you have one project that is your calculator
  • the part that computes results following GUI events is mixed with the GUI itself

Next part I'm not sure of, as these are two different problems, with two very different solutions (if I guesses correctly):

  • If you want your computation result displayed in the GUI calculator to notify another part of a GUI application... I think the best solution would be build your own notification event that a component can subscribe to and that is launched when the user clicks on "=". Using custom Observable and Observer implementations, you should be able to build a loosely coupled solution. I think you should check out this link for a tutorial on implementing a solution based on the observer pattern, it takes you by the hand, and you'll be on the right track.

  • If you just want your computing library to be available in other projects, you have to set up another project that will contain only the computing part and use it as a dependency in your Calculator GUI project and all other projects you need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.