2d Graphics problem - Help!

D

DBC User

Hi all,

I have 2 frames, one frame has panel, which displays a bar chart. I
have another frame which display the bar chart values in text in
JTextPanel. Bar chart drawing is real time with data coming from
server. So when I get the data pass it to the second frame to display
the text and then draw the graph as well.

When I do only Bar chart everything is fine, but when I start
displaying the second frame to write text message, everything in the
second frame start appearing in my bar chart panel. Does anyone know
why this is happening?

Thanks a lot.
 
V

Vova Reznik

DBC said:
Hi all,

I have 2 frames, one frame has panel, which displays a bar chart. I
have another frame which display the bar chart values in text in
JTextPanel. Bar chart drawing is real time with data coming from
server. So when I get the data pass it to the second frame to display
the text and then draw the graph as well.

When I do only Bar chart everything is fine, but when I start
displaying the second frame to write text message, everything in the
second frame start appearing in my bar chart panel. Does anyone know
why this is happening?

Thanks a lot.

Do frames share Graphics object?
 
D

DBC User

No, This is the sequence diagram if you will,

mainprogram -> create frame1 -> create panel with 2D graphics object
that get painted everytime it recives message from server.

mainprogram->create frame1->create frame2 ->create a textpanel which
updates the text in this box, everytime, it gets the message from the
server.

when the second part is not running the first one works like a charm
but when you enable the second frame, the first frame paint is painting
the frame 1 panel and underneth it paints frame 2 text box message. any
idea how to seperate them and not to paint over again and again?
 
M

Monique Y. Mudama

No, This is the sequence diagram if you will,

mainprogram -> create frame1 -> create panel with 2D graphics object
that get painted everytime it recives message from server.

mainprogram->create frame1->create frame2 ->create a textpanel which
updates the text in this box, everytime, it gets the message from
the server.

when the second part is not running the first one works like a charm
but when you enable the second frame, the first frame paint is
painting the frame 1 panel and underneth it paints frame 2 text box
message. any idea how to seperate them and not to paint over again
and again?

This sounds like a problem with forgetting to call super.paint() or
super.paintComponent() in your custom paint code (depending on whether
you're using AWT or Swing).
 
D

DBC User

Yes I wasn't doing the super.paint, the reason is, I want to retain the
old graph and update only the new data. If I do super.paint I loose all
previously drawn graph. Now that i am thinking about it.

Can I generate a image and update the image and show it in a paint,
will it work?

Thanks for the answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top