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 optionswindow implement action listeners exactlythe same mainwindow. sadly didn't fix issue.

  • having maincontroller adding action listeners single buttonlistener class.

  • having maincontroller add action listeners 2 different action listener classes.

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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -