What is the importance of frames per second in JSlider and what values to choose?

StackOverflow https://stackoverflow.com/questions/15737080

  •  31-03-2022
  •  | 
  •  

Domanda

I am learning how to use the JSlider from oracle tutorials. I want to use it to change the value of a variable in my code and not to change the speed/fps of animations. I notice this "frames per second" which I see in computer games and read about here. I saw different JSlider examples and they all use different values for the FPS constants. How do I decide which values to use for the JSlider FPS constants ? Also, why do we make them constants and not variables ? Should I just copy paste these values into all my code that uses JSlider ?

static final int FPS_MIN = 0;
static final int FPS_MAX = 30;
static final int FPS_INIT = 15;    //initial frames per second
. . .
JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,
                                  FPS_MIN, FPS_MAX, FPS_INIT);
framesPerSecond.addChangeListener(this);
È stato utile?

Soluzione

How do I decide which values to use for the JSlider FPS constants ?

It depends on your requirements. Too slow and the animation looks bad. Too fast and the computer can't keep up. Also monitors only refresh at a given frequency anyway. I think I saw in another posting 60 would be a good max.

Should I just copy paste these values into all my code that uses JSlider ?

Sliders can be used to something other than a FPS function. So the values you choose depend on your requirements.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top