JButton bkButton = new JButton(new ImageIcon("src/Images/smallBArrow.bmp"));
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(bkButton);
使用动作侦听器,我需要能够单击并执行操作(返回、前进或刷新)
JButton bkButton = new JButton(new ImageIcon("src/Images/smallBArrow.bmp"));
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(bkButton);
使用动作侦听器,我需要能够单击并执行操作(返回、前进或刷新)
这通常是通过匿名内部类完成的......
bkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
backButtonPressed();
}
});
看到这个答案