0

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);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
David
  • 39
  • 1
  • 5

1 Answers1

1

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.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433