0

I'm designing a program in Java using an MVC layout. I need the view to initialize the buttons to run functions that the control defines. How can my view define an actionlistener that can run a function from a given class?

0

1 Answer 1

1

In Java, different view frameworks such as AWT,Swing or SWT, works on listeners. You need to add listener to a control(button in your case) and can call a method of a different class in your listener implementation.

In more generic terms, you can always make use of Observer pattern also to implement callbacks in any language.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.