Hi to all,
Hope you all will be fine. Actually i am making a cricket game. The problem is that i want to display ball and runs in a rectangle staring at (0.0) or you can say i want to draw something on the screen right now. The problem is that i used layer manager and now when i use code like this

Java Code:
g.drawString(..);
g.drawline(..)
it appears and then suddenly disappear from the screen. I want to ask what i am doing wrong and how can i do what i want. Here is my code

Java Code:
public class DemoGameCanvas extends GameCanvas implements Runnable {

    ...
    private int ballXFP = MathFP.toFP(140);     //  x position (as a MathFP)
    private int ballYFP = MathFP.toFP(100);     //  y position (as a MathFP)
    //private int direction = MathFP.toFP("270");              //  current direction in degrees
    private int direction = 270;
    ....

     public DemoGameCanvas() {


        super(true);
        try {

            //setFullScreenMode(true);
            init();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    private void init() throws IOException {

        
        timer = new Timer();
        gameDesign = new GameDesign();

        //Background image
        cricketGround = gameDesign.getCrik();

        //For all sprites positions
        lm = new LayerManager();
        gameDesign.updateLayerManagerForMatchGround(lm);

        ballImage = gameDesign.getBall5px();
        ballSprite = gameDesign.getWhiteBall();
        ballSprite.defineReferencePixel(3, 3);  
        .......

    }

    private void adjustViewPoint(int x, int y) {

        //adjust the viewport
        this.lm.setViewWindow(viewPortX, viewPortY, getWidth(), getHeight());

    }

     public void run() {

        Graphics g = getGraphics();
        
        while (!interrupted) {

           updateScreen(g);

            try {
                Thread.sleep(5);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }


        } // while (!interrupted)

    } //run()

     private void updateScreen(Graphics g) {

        createBackGround(g);

        for (int i=0; i<320; i+=10) {             // This work as screen appear and then immediately disappear. 
            g.setColor(255, 0, 0);
            g.drawLine(0, i, getWidth(),i );

        }
        
        moveBall();

        ballSprite.setRefPixelPosition(MathFP.toInt(ballXFP), MathFP.toInt(ballYFP));

        playShots();
    }
    
    private void createBackGround(Graphics g) {

        lm.paint(g, 0, 0);
        flushGraphics(0, 0, getWidth(), getHeight());
    }

    private void moveBall() {
    
    .......

    }
}

Please tell me what i am doing wrong.

Thanks