• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in paint() method when using ScrollPane

 
Chandhrasekar Saravanan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am having problem in using paint() method . i have an ScrollPane component, which uses paint method to write contents into it. i am calling the paint method in an different (PaneWriter) class. and i am calling PaneWriter in 2 different instances. it works fine in the first instance, but in the second instance when i call, paint() retains the value of the 1st instance and the new value is not reflected in the paint() method.
I am giving an condensed form of my code, so it would be easier to help me. for simplicity , i am testing by sending two different integer values
in the two instances. paint method retains the int value of the first instance and the int value of the second instance is not reflected.
My first instance of PaneWriter class is called whenever the program is executed, the second instance is called when i click the "open" menu in the File menubar. also i am able to get the output only when i click the "open" menu first, and whenever i click on further i dont get any response at all.

[ February 03, 2003: Message edited by: Nathan Pruett ]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating a new instance of the PaneWritter in the menu option part of your program. This is incorrect, instead you should have a setK1(int k) method (or something like it) that will allow you to change the value stored in PaneWriter. Instead you are creating a new one, which is never added to your frame (and so never painted).
Steve
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!