Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: need help on this. Date: Tue, 30 Apr 2013 10:01:22 -0400 Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <1ea6b46f-380f-4839-b4dc-74d72a10b5e6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 30 Apr 2013 13:57:25 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6b9e92482af47766954d85fb77d372f5"; logging-data="5087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EazV+T4XiZQyWgGpdOg/W4JIUXdMP8wk=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130121 Icedove/10.0.12 In-Reply-To: Cancel-Lock: sha1:+8wuxxpPLgvuQSytVLiXIX08+IU= Xref: csiph.com comp.lang.java.programmer:23731 On 04/30/2013 09:50 AM, Jeff Higgins wrote: > On 04/30/2013 09:18 AM, wee wrote: >> i have this code: >> >> public class ArrayUI extends JFrame { >> public JPanel pane = new JPanel(); >> public JTextField[] item = new JTextField[20]; >> >> public ArrayUI() { >> super("title"); >> FlowLayout fl = new FlowLayout(); >> setLayout(fl); >> Handler handle = new Handler(); >> >> for (int i = 0; i< item.length; i++) { >> item[i] = new JTextField(("Text here " + i), 10); >> item[i].addMouseListener(handle); >> pane.add(item[i]); >> } >> add(pane); >> pack(); >> } >> >> private class Handler extends MouseAdapter { >> public void mouseClicked(MouseEvent e){ >> >> } >> // i want to get the index of the array (item[]) of the JTextField >> // object that received the mouseClicked action. >> // any idea how i can do that? >> // using the getSource() method returns the object itself, >> // not the index of the array. help please.. > // Arrays.binarySearch()? for ( JTextField f : item ) >> } >> } >> >