paint.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: paint.

  1. #1
    Join Date
    Sep 2011
    Posts
    197

    paint.

    I suppose my answer lies in a better understanding of paintComponent(graphics g); But, I'll ask it here just incase someone has a direction to point me in I would much appriciate it.

    You see I have some images I want to update at different times. So I need a way of only calling to update certain images. I tried using a layeredPane and, just using another component. But, either way they seem to be called if I update the paint it looks somethign like this.

    Code:
                         bUttonLogic.need = false;
                         JComponent game = new gameEngine(gameEngine.NEW_GAME);
                         JComponent gme = new typeO();
                           gAme = game;
                             machine.add(game);
                             machine.add(gme, -1);
                             machine.pack();


    This code below some how still calls to update the overriden paintComponent in typeO class.
    Code:
    machine.gAme.repaint();
    Thanks ahead of time.


    _______UPDATE _______________

    I am now trying to use printComponent for the other images seems rather inefficeint but, I'm still toying around with how the graphics class is called. I still don't quite understand how the graphics class is called/works.

    I now realize that when I add two components one after another it jsut overrides the previous. I think.
    Last edited by kolt007; March 6th, 2012 at 02:28 AM.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: paint.

    Stop writing code and read a tutorial on how Swing handles painting components. There are many articles available if you search but the following is a pretty good one http://java.sun.com/products/jfc/tsc/articles/painting/

    It's pointless trying to solve your problem unless you understand how the system works.

    I can't offer more help as you haven't really explained what your problem is.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center