swing - ActionListener not working Java -


what missing here?

 public class abc extends jframe    {  private jbutton save = new jbutton("save");   public abc() {     jpanel p = new jpanel();     save.addactionlistener(new savel());     p.add(save);     container cp = getcontentpane();     p = new jpanel();     p.setlayout(new gridlayout(2, 1));      cp.add(p, borderlayout.north);   }    }   class savel implements actionlistener {          public void actionperformed(actionevent e) {                 system.out.println("hello"); // nothing happens          } } 

why doesn't actionlistener work here

you creating jpanel, adding jbutton it, creating new jpanel , adding panel jframe. need adding original panel content pane.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -