• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

communicating/affecting another class

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to develop a sudoku solver and have developed the GUI class and i want a seperate Button class which affects the 9x9
grid in the GUI class.
How does the communication take place is it through passing arguements via methods or some other way?

Any help would be gratefully appreciated.


GUI CLASS



BUTTON CLASS
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andrew Evans wrote:How does the communication take place is it through passing arguements via methods?



Yes, that's how it should be done.
 
Ranch Hand
Posts: 441
Scala IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you've developed that GUI, adding an extra button should be a piece of cake.
 
Marshal
Posts: 64707
226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a GUI question, I shall move it to our GUIs forum.
 
Andrew Evans
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The gui as it is does what i want it to do. My problem is trying to get the New Puzzle button to communicate with the GUI
from the ButtonControl class. Paul Clapham has said it is through arguements being passed via methods, but i'm
still not sure how it is to be done.

In the Button class do i need the public ButtonControl() part or is there another way of implementing this?

 
Luigi Plinge
Ranch Hand
Posts: 441
Scala IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your ButtonControl class supposed to be a separate JFrame from your main application? Why does it extend Gui?

Do you want it to instantiate a new Gui, or just to start a new game? If the former, you will have a reference to the Gui from when you instanitate it, so you can call methods on it directly. If you create your ButtonControl instance from a Gui instance, you can give your ButtonControl constructor a Gui argument, and pass "this" in the constructor call. Then have your ButtonControl store this instance as a private variable, so it can reference its "parent".

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!