Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Do certain events make calls to repaint redundant?  RSS feed

 
Colm Dickson
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.


In an application where a scroll bar changes the size of a shape on the JPanel on which it is drawn, I would have thought that the AdjustValueChanged method would have required a call to repaint(); in order to reflect the change to the shape drawn on the panel but it seems to do this automatically. Why is this?

Thanks,

Colm
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> changes the size of a shape on the JPanel

We have no idea what you code is like to implement that change, so its hard to guess.

If you are doing custom painting to draw the shape in the Graphics method, then you should need to invoke repaint on the panel to reflect the change.

If you are changing a "shape icon" on a JLabel, then the label should repaint itself automatically.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
Colm Dickson
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again...


Sorry...,my mistake...I had my classes all separated into frames and panels and missed a call to repaint() hidden in my method!!!

SO..it had a call to repaint() all along..

Thanks.
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Colm Dickson wrote:Hi again...


Sorry...,my mistake...I had my classes all separated into frames and panels and missed a call to repaint() hidden in my method!!!

SO..it had a call to repaint() all along..

Thanks.


Which is why a SSCCE should always be posted with the question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!