• Post Reply Bookmark Topic Watch Topic
  • New Topic

using context of a control

 
Mohamad Norouzi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thank u so much for wasting ur time to solving my problem.
ok I explain everything.

I create a class with name CDrawFunction. this class implement some method like draw(Graphics g) and also parse a formula to draw its chart.

for example first I set the formula like "x*sin(x)+2*x"
then that class parse it to check if any syntax error exists in it or not.
then I must the method "draw(Graphics g)" draw that formula. so it must be on a context and CDrawFormula extend another abstract class so it cant extend another class like JPanel to using its "paint(Graphic g)".
so I decide that user first create the JPanel and pass its graphic to my class and I draw the chart of that formula on it.

I welcome for any suggestion about my program.

thanks so much.

best regards
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just do something like this:



Now CDrawFormula.paint() gets invoked only as needed, when it's needed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!