Java:创建对象实例时用括号括起的类名

问题描述

| 在Java代码中:
// Define ActionListener

ActionListener actionListener = new ActionListener() {

public void actionPerformed(ActionEvent actionEvent) {

        JButton button = **(JButton)actionEvent.getSource();**
        int red = random.nextInt(255);
        int green = random.nextInt(255);
        int blue = random.nextInt(255);
        button.setBackground(new Color(red,green,blue));

    }
};
加亮显示(在
**
**
之间)的代码有什么作用? 我发现很难对此主题进行研究,因为我不知道要使用哪些搜索词。 :o 希望任何人都能提供帮助。 TIA     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)