Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how to run other java program with Jbuttons

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have 2 java program the first java program is main menu of my program. the 2nd is Calculator.

#1 Program: Main Menu

#2 program: Calculator

in the main menu there is a Jbuttons. is there a way to run the #2 program: Calculator when the 1st Jbutton(Calculator button) clicked ?
Posts: 3323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you create an instance of Calculator and call it's launchFrame method. BTW why is your first program Swing based and the second AWT, it's generally not a good idea to mix the two together.
Another thing is I'd rewrite the Calculator class so that it extends JPanel and doesn't create a frame in the constructor. Then whoever constructs the class has the choice of whether to display the Calculator in a frame, a dialog or embed it in their own GUI.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic