java - actionlistener(this) not working -


import java.io.*; import java.awt.event.*; import java.awt.*; import javax.swing.*;  class casestudy extends jframe implements actionlistener {//making facebook program     jbutton login,register;     jlabel lbl1, lbl2;     jtextfield txtemail;     jpasswordfield txtpassword;      public casestudy()      { //setting labels button etc         super ("casestudy2.0");         setlayout(new flowlayout());         lbl1 = new jlabel (" username ");         lbl2 = new jlabel (" password ");         txtemail = new jtextfield(10);         login = new jbutton("login");         register= new jbutton("register");         //this          login.addactionlistener(this);//adding listener          register.addactionlistener(this);         register.setbounds(2,250,100,20);      }      public void actionperformed(actionevent e){          //my code supposedly im working im checkin frame , apppars not work frame no buttons     }      public static void main (string  args []){         casestudy use= new casestudy();//frame size         use.setsize(250,280);         use.setvisible(true);         use.setdefaultcloseoperation(exit_on_close);     } }  

supposedly want run program , check frame before working on not displaying buttons or whatsoever please i'm in pinch :( in other words want frame have buttons first before start actual program.

you forgot add button jframe:

public experimentapplication()      { //setting labels button etc      super ("casestudy2.0");      setlayout(new flowlayout());      lbl1 = new jlabel (" username ");      lbl2 = new jlabel (" password ");      txtemail = new jtextfield(10);      login = new jbutton("login");      register= new jbutton("register");      //this       login.addactionlistener(this);//adding listener       register.addactionlistener(this);      register.setbounds(2,250,100,20);       // add button frame      this.add(register);      } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -