luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:By the way, learn to follow the Java coding conventiona. Class names should start with an uppercase letter.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Darryl Burke wrote:Well, updating the table in a new mainWindow is hardly likely to affect an already existing mainWindow.
By the way, learn to follow the Java coding conventiona. Class names should start with an uppercase letter.
Joe Pettit wrote:Doh! Wow, I hadn't even considered that...would there be another way of doing what I'm trying to do?
Joe Pettit wrote:Currently, the addAssignment accepts an instance of mainWindow as an argument - but I would need to pass the current instance of the mainWindow class to the addAssignment class to call the updateTable method appropriately.
Paul Clapham wrote:
Joe Pettit wrote:Currently, the addAssignment accepts an instance of mainWindow as an argument - but I would need to pass the current instance of the mainWindow class to the addAssignment class to call the updateTable method appropriately.
Okay. So you need a controller to go along with your model and view components. The controller could be the code which sets up the other components, but at any rate it needs to have a reference to your MainWindow object (the current instance you referred to, although I don't see why there would be more than one instance) and a reference to the AddAssignment object (not the class, the object is going to do the work).
Then the controller would simply call the method of the AddAssignment object and pass it the reference to the MainWindow object.
Joe Pettit wrote:I've never really heard of the controller class you suggested below - is this an implementation of a class that already exists or is it just a concept of what I need to do?
Paul Clapham wrote:
Here you are creating a new "mainWindow" object which is going to be part of your GUI. Code in other classes, you say, needs to work with this object. But you aren't even keeping a reference to it, so no other objects can possibly work with it.
Creating another mainWindow object isn't going to be helpful, because that second object isn't the one you need to work with. So if you have other code which works with "mainWindow", it shouldn't create any more objects. It should just work with the one you already have.
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|