How I can prove that the short-time Fourier transform (STFT), preserves energy density of the signal? How I can prove that the short-time Fourier transform (STFT), preserves energy density of the signal; that is:
$$\int_{-\infty}^\infty\int_{-\infty}^\infty|STFT(t,f)|^2 dtdf = \int_{-\infty}^\infty|x(t)|^2 dt = \int_{-\infty}^\infty|X(f)|^2 df = E_x$$
The STFT of a signal is: $$STFT(x) = \int_{-\infty}^\infty x(t)w(t-τ)e^{-2\Pi ift}dt$$
 A: If you consider the STFT of a continuous signal without any sampling, then by Parseval's theorem
$$X(t,f)= \int_{-\infty}^\infty w(t-\tau)x(\tau)e^{-2i \pi f \tau} d\tau $$ $$\implies \int_{-\infty}^\infty \int_{-\infty}^\infty |X(t,f)|^2df dt=\int_{-\infty}^\infty \int_{-\infty}^\infty|w(t-\tau)|^2 |x(\tau)|^2 d\tau dt = A \int_{-\infty}^\infty |x(\tau)|^2 d\tau$$
where $A = \int_{-\infty}^\infty |w(t)|^2 dt$

Now in real life you consider a sampled signal $x(n)$ and a sampled STFT :
$$X(m,f) = \sum_{n=-\infty}^\infty w(mT-n) x(n) e^{-2i \pi f n}$$
(the frequency domain is sampled too at $f = \frac{k}{K}$ with $K \ge L$ the length of the window)
By inverse discrete Fourier transform, you can recover $$w(mT-n) x(n) = \frac{1}{K}\sum_{k=0}^{K-1} X(m,k/K)e^{2i \pi k n/K}$$ 
In general, the window $w(n)$ is chosen to allow the perfect reconstruction of the signal, that is
$$\sum_{m=-\infty}^\infty w(mT-n) = C \implies x(n) = \frac{1}{C}\sum_{m=-\infty}^\infty \frac{1}{K}\sum_{k=0}^{K-1} X(m,k/K)e^{2i \pi  nk/K}$$
This is the case with the Hanning window $w(n) = (\frac{1}{2}-\cos(\pi  n/N))1_{n \in [0,N]}$, where $N/T$ is a multiple of $2 \quad $  ($N/T > 2$ means over-sampling).
Now $N/T > 2$ allows for a better time resolution of the spectrum, but not only.
An other desirable property is the conservation of the energy of the signal :
$$\sum_{m=-\infty}^\infty w(mT-n)^2  = A$$
$$\implies \sum_{n=-\infty}^\infty |x(n)|^2 = \frac{1}{A}\sum_{m=-\infty}^\infty \sum_{k=0}^{K-1} |X(m,k/K)|^2$$
Those two properties, perfect reconstruction and energy conservation are the reason why we often choose the Hanning window with $N/T \ge 4$, or the Hanning window squared, or a mix of those with the rectangular window (the Blackman and the Hamming window)
