| Author |
communicating/affecting another class
|
Andrew Evans
Greenhorn
Joined: Jun 16, 2011
Posts: 9
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16480
|
|
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
Joined: Jan 06, 2011
Posts: 441
|
|
|
If you've developed that GUI, adding an extra button should be a piece of cake.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
|
If this is a GUI question, I shall move it to our GUIs forum.
|
 |
Andrew Evans
Greenhorn
Joined: Jun 16, 2011
Posts: 9
|
|
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
Joined: Jan 06, 2011
Posts: 441
|
|
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".
|
 |
 |
|
|
subject: communicating/affecting another class
|
|
|