(理解来源于百度知道): 

e.getSource()方法依赖于事件对象。

比如:JButton jbt = new JButton("button");中事件对象就是jbt

e.getActionCommand()方法依赖于按钮上的字符串

比如:JButton jbt = new JButton("button");中字符串button

简而言之:用e.getSource()得到的是jbt,而用e.getActionCommand()得到的是button。

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐