I have created a button in InDesign and now exported it as a PDF. Now I would like to program the field to change color when I click on it and to show the default color when I click again. Is there a Java code that I can use?
PDF fields can only be rectangular. If you want to have a non-rectangular form then you need to use an image, preferably as a part of a layer. You can (partially) overlay a field on top of that area that will cause it to toggle on or off.
I've developed similar solutions for my clients in the past, and while it's not a simple task, it is doable. If you're interested in hiring someone to do it for you feel free to contact me privately via [try6767 at gmail.com].