I am working on an method to draw a slider which the user can use to set a certain value, but I have run into a problem I cant figure out.
the problem is: the bar you move inside the slider with your mouse has to start at the beginning of the program so it has to be set there once when the program starts that's where the runOnce comes in. This is where the problem starts, processing thinks that the local variable barX the value that sets the X position of the bar inside the slider may not have been initialized even though it is in the beginning in the runOnce if. I also cant declare it outside of the method becouse that would cause trouble by making it global. Does anyone know a solution to this, I have been trying to solve this for hours.
the code is below:
the barX,Y int is the XY position of the bar you move inside the slider to set the value
slidername is the name of the value being set by the slider adjustable in the argument section
the room is 400 wide and the slider has to be 300 so that's where (width-300)/2 comes from
boolean runOnce = true;
float slider( int sliderY,String slidername){ int barX; int barY;