我有一个问题,如何通过单个按钮点击执行其他按钮的操作。以下是三个按钮的示例代码:
JButton a = new JButton("a");
a.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Action of a is Here
}
});
JButton b = new JButton("b");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Action of b is Here
}
});
那些应该一起出现,比如:
JButton c = new JButton("c");
c.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Action of c is Here
// Action of a
// Action of b
}
});
在上面的例子中,我有三个按钮
a、b、c
,每个按钮都有自己的动作;但是你可以看到,C还必须运行A和B的动作。有什么好的方法来解决这个问题?