Timestretching is a whole 'nother can of worms. There are two basic methods: slice and dice; and DSP.
The first method slices up an audio stream into sections (usually 20 to 40 per second) and then either overlaps the sections (time compression) or repeats them (time expansion). The results are not very good, although the best algorithms usually do some sort of smoothing to supress the artifacts. The latency however is very low.
The second method, DSP, most commonly converts the frequency domain into a time domain and then changes the representation of the sample to equal a time stretch or time compression, then converts back to the frequency domain (not the clearest explanation, I know). The result is very smooth with few artifacts, but is VERY processor intensive. It also requires extensive DSP skills of the programmer and can have very high latency (100s of milliseconds).
Since JUCE doesn’t provide either method in its library, you’ll have to write your own code. A good place to start is the Soundtouch Library which you can try to adapt to JUCE. It uses DSP techniques and has a latency of around 100ms. Also visit the Linux Sounds Archive. There’s lots of code to explore and you may find some quick hack you can use. The best place to go for more information is Stephan Bernsee’s webpage which will give you all the information on the topic you could ever want.