Article View: borland.public.jbuilder.java.language
Article #14880Why one action listener works and the other doesn't.
From: New Horizons Software
Date: Sun, 25 Jul 1999 00:00
Date: Sun, 25 Jul 1999 00:00
25 lines
1313 bytes
1313 bytes
This code doesn't work (compiles fine).
for(BtnCnt=0;BtnCnt<1;BtnCnt++) {
myButton[BtnCnt].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
os.ChangeStates(myButton,BtnCnt,Color.yellow,mBlue);
setTitle(myTitle[BtnCnt]);
}
});
}
But this does:
BtnCnt=0;
myButton[BtnCnt].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
os.ChangeStates(myButton,BtnCnt,Color.yellow,mBlue);
setTitle(myTitle[BtnCnt]);
}
});
Any ideas as to why? The only difference is one is in a loop. I'm
trying to set it up for an array of buttons.
Technical Details
Message-ID:
<379a6ae8.89951014@news.iu.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,b4ce53d10f28b48f,start X-Google-Attributes: gidf74b3,public From: cstrick@iu.net.cut_this (New Horizons Software) Subject: Why one action listener works and the other doesn't. Date: 1999/07/25 Message-ID: <379a6ae8.89951014@news.iu.net> X-Deja-AN: 504914669 X-Complaints-To: newsabuse@remarQ.com X-Trace: 932866689.801.44 .X8MLPGJIB898CC75C qube-01.us-ca.remarq.com Organization: New Horizons Software NNTP-Posting-Date: Sun, 25 Jul 1999 01:38:09 GMT Newsgroups: borland.public.jbuilder.java.language