• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

communicating/affecting another class

 
Andrew Evans
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
 
Paul Clapham
Sheriff
Pie
Posts: 20748
30
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.
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala 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.
 
Campbell Ritchie
Sheriff
Posts: 48386
56
  • 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
IntelliJ IDE Scala 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