1 java class object instance parentheses
在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));
}
};
Run Code Online (Sandbox Code Playgroud)
突出显示的(之间**和**)代码有什么作用?
我发现研究这个主题非常困难,因为我不知道要使用哪些搜索术语.:○
希望有人可以提供帮助 TIA