You are not changing the size of the text from your JSlider. You just try to redraw the text. Try changing the size of the font as follows:
Font font = g2.getFont().deriveFont(<modified-font-size-changed-by-jslider>);
instead of:
Font font = g2.getFont().deriveFont(20f);
You can just have a mapping between JSlider position and font size. Based on the position of JSlider, you can assign a new font size. It should work in that case.