Need help on a line of code. Java!

So im trying to get our solenoid to run like our compressor. Our compressor is set to run as long as the code is running. we have a tray like thing (excuse my awesome technical terms) with a piston attached to it. The piston needs to constantly be out but I cant seem to program that. So far I can program it to come out when I push button 3 but I want it instead to be constantly out and the air pressure to cease and the piston to retract when I press button 3. You see my dillema?

You could do this with a simple hardware fix, I think. Try swapping which tube on the cylinder goes to which port on the solenoid. Assuming that the current configuration is for the cylinder to be in except when the button is pressed, that should change it to out except when the button is pressed.

You can program the solenoid valve to actuate when you press button 3. But instead of plumbing the cylinder to be retracted right away, just reverse the plumbing of the cylinder so that it will be extended right away, then when button three is pushed, it will retract. Sorry I don’t have any code examples.