I have a question on how to get the index of a selected object. I'll briefly explain my project to help get a better understand of what I'm doing.
I have created a simple object (named InfoObject) which is made up of 2 jTextfields and 1 jComboBox. I have added focusListeners to the textfields. When a jTextField is clicked/focused it sets the background to a specified color (making it obvious that the object of information has been selected) Also, when the object is focused it sets a boolean to true, when it is no longer focused, the boolean is returned to false.
I then have a separate class containing my jPanel that adds an InfoObject to the panel upon reading a file and upon a users input. I also add each object to an arraylist. (ArrayList<InfoObject>)
Is there a way to get the index of the InfoObject when it is focused/clicked? My goal is that when the object is focused, I'll have the opportunity to click a button which removes the object from the jPanel and the ArrayList so that when I save the information it doens't have any old information in it.
I can provide source or extra details if need be. Looking forward to replies. Thanks to anyone and everyone who offer advice on the matter