• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

problem in paint() method when using ScrollPane

Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
Posts: 4179
IntelliJ IDE Python Java
  • 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).
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!