Java给JLabel加监听器

xiaoxiao2021-02-27  360

JLabel 不像按钮,要添加鼠标事件的话 用鼠标事件监听:JLabel jl = new JLabel(); jl.addMouseListener(new MouseListener(){ public void mouseClicked(MouseEvent e) { // 处理鼠标点击 } public void mouseEntered(MouseEvent e) { // 处理鼠标移入 } public void mouseExited(MouseEvent e) { // 处理鼠标离开 } public void mousePressed(MouseEvent e) { // 处理鼠标按下 } public void mouseReleased(MouseEvent e) { // 处理鼠标释放 } });
转载请注明原文地址: https://www.6miu.com/read-3262.html

最新回复(0)