Can't tell much by what you posted. The call to
setPreferredSize is enough for a
parent scrollPane to work properly. If the text height and/or width is variable you could
override the
getPreferredSize method and return a calculated (in
paintComponent as
you go) size as the prefSize. This should allow you to skip the Scrollable implementation.
The other suggestion is to remove the member variable "g2" and keep it local inside
paintComponent.
Post some code that shows the trouble if you like.
public class sequenceDisplayPanel extends JPanel implements Scrollable
{
private JFrame mainWin;
// Eliminate this member variable.
// private Graphics2D g2;
...
public void paintComponent(Graphics g)
{
super.paintComponent(g);
// Keep the graphics context reference local.
Graphics2D g2 = (Graphics2D)g;