문제

public class Square extends JButton {   
    ... 
}

What's the best way for a JButton to handle a MouseClick that changes the background color of itself? Do I want to add/overwrite an ActionListener/MouseListener/etc?

도움이 되었습니까?

해결책

Yes, you will need to add an ActionListener and do your mumbo-jumbo in actionPerformed(). Use the setBackground() to change the background color. :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top