public void mouseEntered(MouseEvent e)
{
if(e.getSource() == "빨강")
{
source.setBackground(new Color(255,0,0));
}
if(e.getSource() == "녹색")
{
source.setBackground(new Color(0,255,0));
}
if(e.getSource() == "파랑")
{
source.setBackground(new Color(0,0,255));
}
}
여기서 "빨강" "녹색" 이런건 label에 들어있는 text내용인데 라벨인식이 안되 문제해결도움!
{
if(e.getSource() == "빨강")
{
source.setBackground(new Color(255,0,0));
}
if(e.getSource() == "녹색")
{
source.setBackground(new Color(0,255,0));
}
if(e.getSource() == "파랑")
{
source.setBackground(new Color(0,0,255));
}
}
여기서 "빨강" "녹색" 이런건 label에 들어있는 text내용인데 라벨인식이 안되 문제해결도움!
문자열을 왜 ==로 비교하냐
=로 비교하면 에러떠
기본도 안돼있는놈
한참 배우는중이라
if(e.getSource().equals(l1)) 로 바꿧는데 내생각엔 라벨을 getSource로 읽는거가 아닌거같아..
getText()
getText로 사용하면 symbol을 찾을수 없다고 떠..
JLabel label=(JLabel)e.getSource();
label.getText().equals(\"빨강\")
ㅁㄴㅇㄹ형 미안 아직 Jlabel을 안배워서 잘 몰라.. 통째로 올릴께 한번만 봐줘
라벨 ㅋㅋ 그냥 라면이라고 부르지
danger 단거 수준의 콩글이다