Image JButton打开图像
我正在为我的学校设计一个程序,只需点击一个按钮就可以显示教师的日程安排。我已经弄明白了一切,但如何通过点击特定的教师姓名打开图像。这是我的一些代码,非常感谢您的帮助。谢谢Image JButton打开图像,image,button,icons,jbutton,Image,Button,Icons,Jbutton,我正在为我的学校设计一个程序,只需点击一个按钮就可以显示教师的日程安排。我已经弄明白了一切,但如何通过点击特定的教师姓名打开图像。这是我的一些代码,非常感谢您的帮助。谢谢 `JButton gabster = new JButton("Mrs. Gabster"); gabster.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent
`JButton gabster = new JButton("Mrs. Gabster");
gabster.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JPanel gabster = new JPanel();
}
});`
我需要让按钮从我的工作区打开一个新图像
public void actionPerformed(ActionEvent ae)
{
ImageIcon pic = new ImageIcon("picture.jpg");
JLabel picture = new JLabel(pic);
panel.add(picture);
}
为单击按钮时创建方法