getSource() Returns: The object on which the Event initially occurred. 依赖于事件对象 getActionCommand() Returns the command name of the action event fired by this button. If the command name is null (default) then this method returns the label of the button. 依赖于按钮上的字符串 getSource得到的组件的名称,而getActionCommand得到的是标签。 如:Button bt=new Button("buttons"); 用getSource得到的是bt 而用getActionCommand得到的是:buttons
getSourse() 与getActionCommand 区别
最新推荐文章于 2021-08-06 10:51:26 发布