Thread: JPanel Problems
View Single Post
  #4 (permalink)  
Old 10-11-2007, 12:36 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
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.
Code:
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;
Reply With Quote