java - How to detect when a JButton is pressed (swing)? -


in java's swing package, wondering how detect when jbutton pressed. there function called when button pressed? thanks

yes, when deal button pressing, want add known action listener. first, must

import java.awt.event.actionlistener; 

then can following

button.addactionlistener(new actionlistener() {        public void actionperformed(actionevent e) {              // makes sure button pressing button variable              if(e.getsource() == button) {                 // action necessary code                }        }  }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -