How can I dynamically change font attributes, for instance, rendering a string in successively larger font sizes?
Ans : Strictly speaking, you can’t. A Font object is created once and for all with fixed attributes, as specified in its constructor: public Font(String name, int style, int size) To get the effect of dynamically changing a font’s size or style, you need to create a new Font object with the desired values. For example, the following paint method draws up to twenty characters from a string in successively larger sizes: public void paint(Graphics g) { g.setColor(Color.blue); int maxLength = Math.min(20, inputString.length()); for (int i = 0; i < maxLength; ++i) { g.setFont(new Font("Courier", Font.ITALIC, 12 + i)); g.drawString(inputString.substring(i, i+1), 20 + 8*i + (int)(.