java - Action Listener not working in a MVC application -
i have following problem: have small application simple ui. implemented action listeners work there fine. however, action listener dialog window , save button refuses print out test message.
the code rather lengthy put on hastebin convienience.
http://hastebin.com/eqokilawiv.avrasm
i suspect might have how controller handling adding optionswindow listeners.
i have tried couple of things see if work:
having seperate controller
optionswindowimplementaction listenersexactlythe samemainwindow. sadly didn't fix issue.having
maincontrolleraddingaction listenerssinglebuttonlistenerclass.having
maincontrolleraddaction listeners2 differentaction listenerclasses.
at point ran out of ideas , suspect might missing crucial understand why doesn't work. i'm pretty new when comes implementing mvc welcome feedback.
you add actionlistener button created default constructor, in actionlistener:
optionswindow = new optionswindow(mainwindow.getmainframe()); you create new optionswindow, without connection actionlistener of savebutton. enought add:
if (ev.getsource() == mainwindow.optionsbutton) { system.out.println("options pressed"); optionswindow = new optionswindow(mainwindow.getmainframe()); optionswindow.addoptionsbuttonlistener(new optionsbuttonlistener()); //<-- once again add actionlistener } and works fine code.
another solution delete default constructor, , instead of mainframe argument use method:
public void getvisibleframe(){ optionsdialog.setvisible(true); } and in actionlistener:
if (ev.getsource() == mainwindow.optionsbutton) { optionswindow.getvisibleframe(); } however don't know if compatible mvc.
Comments
Post a Comment