按钮监听事件-如何按下按钮弹出来一个自制图片
下面是我的代码,能够用JOptionPane来弹出来文本,那么图片该用什么命令来弹出呢?JButton button1 = new JButton("Pause");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"Aller. " +
"C'est la pause ! On prend un café ! ");
}
});
下面是我的代码,能够用JOptionPane来弹出来文本,那么图片该用什么命令来弹出呢?JButton button1 = new JButton("Pause");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"Aller. " +
"C'est la pause ! On prend un café ! ");
}
});
重写paint(Graphics g){}这个函数
在这里添加图片。
在把这个panel添加都窗体上。