actionevent

Is it possible to write your own objects that give out ActionEvents?

只谈情不闲聊 提交于 2019-11-28 10:31:41
问题 I've looked at the java tutorials online and they all seem concerned with catching ActionEvents given out by other components that are already written. Is it possible to write your own objects that have there own set of criteria that trigger actionEvents that can then be caught by other classes that have registered as listeners? So for example: If I wanted an object that was counting sheep to send out an actionEvent when 100 sheep had been counted to all the sleeper objects that had

return a value when an JButton actionperformed event is called

谁说我不能喝 提交于 2019-11-28 09:27:48
问题 I have some problem with JButton action events, I have declared a global variable ( boolean tc1 ) and a JButton t1 . When I press the JButton I need to change the value of the boolean variable to 'true'. Can any one help me out? My code goes here. class Tracker extends JPanel { public static void main(String[] args) { new Tracker(); } public Tracker() { JButton tr=new JButton("TRACKER APPLET"); JButton rf=new JButton("REFRESH"); boolean tc1=false,tc2=false,tc3=false,tc4=false; JButton t1=new