Q:

Java Applet String overflow

Hey I have a Java applet that calculates the binomial expansion, however when the string is long the string overflows the applet and you can only see a portion of it, how can I fix this, so i have to add a scroll bar or what would be the easiest thing to do? I use : 
g.drawString(ans  ,10,100);

A:

Add a JTextField or JTextArea to the applet.  The text field will automatically allow scrolling.  The text area can be added to a JScrollPane.

If it is vital to draw the text in the Graphics, perhaps look to rendering it using a multi-line JLabel, as shown in this answer. 

