1

I find myself in the sad situation of having to very quickly get used to both Window Builder (from what I can tell the easiest way to develop Swing interfaces in Java) and applying MVC to this.

I've tracked down the following question and answer, here on stackoverflow, but I've still got questions...

LINK

The code is as follows:

 myButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            myButtonActionPerformed(evt);
        }
    });

    private void myButtonActionPerformed(java.awt.event.ActionEvent evt) {
   if (myControl != null) {
      myControl.myButtonAction();
   }
}

The control class could look something like:

class MyControl {

    void myButtonAction() {
        //TODO: implement control code
    }

}

For instance, if I want to call upon a View from my controller, a Label (for example) and have it display a message when I press the button...how do I go about manipulating the Label in the myButtonAction() function from the MyControl class?

Or for populating/updating a JList...?

I've found a dozen variants so far and I'd really appreciate it if someone could point me towards a complete Window Builder + MVC example or tutorial or spare a few code fragments in the window below.

Many thanks...

Community
  • 1
  • 1
Eugen
  • 1,537
  • 7
  • 29
  • 57

0 Answers0