2d Graphics problem - Help!

Discussion in 'Java' started by DBC User, Apr 21, 2006.

  1. DBC User

    DBC User Guest

    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.
     
    DBC User, Apr 21, 2006
    #1
    1. Advertising

  2. DBC User

    Vova Reznik Guest

    DBC User wrote:
    > 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?
     
    Vova Reznik, Apr 21, 2006
    #2
    1. Advertising

  3. DBC User

    DBC User Guest

    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?
     
    DBC User, Apr 21, 2006
    #3
  4. On 2006-04-21, DBC User penned:
    > 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).

    --
    monique

    Help us help you:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Apr 21, 2006
    #4
  5. DBC User

    DBC User Guest

    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.
     
    DBC User, Apr 21, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mahmoud Mousa

    Help with Dynamic Graphics in ASp.net

    Mahmoud Mousa, Nov 4, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,185
    Rajesh.V
    Nov 5, 2003
  2. Charlie Zhang
    Replies:
    2
    Views:
    564
    Hal Rosser
    Jun 9, 2004
  3. Me
    Replies:
    4
    Views:
    2,069
    Andrew Thompson
    Jun 20, 2005
  4. Bob
    Replies:
    26
    Views:
    907
  5. risshahaprma
    Replies:
    3
    Views:
    929
    Paul N
    Jan 24, 2010
Loading...

Share This Page