Component[] items = 父控件.getComponents(); 获取父控件里的控件,返回Component类的数组。如panel中的许多button
e.getSource() 获取发生Event的对象。
//强制转换为抽象按钮:AbstractButton是JButton、JCheckBox、JRadioButton的父类
//由于不知道谁会被选中,所以使用它们的父类
AbstractButton btn=(AbstractButton)e.getSource();//发生Event的源头

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-05-25
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2021-07-21
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2021-11-19
  • 2021-10-16
相关资源
相似解决方案