JAVA: How to use paint() method to update the previously drawn object?

Posted by GamDroid on Stack Overflow See other posts from Stack Overflow or by GamDroid
Published on 2010-11-09T11:22:11Z Indexed on 2010/12/25 18:54 UTC
Read the original article Hit count: 351

Filed under:
|
|

How to use paint() such that when repaint() is called the previously drawn object should not get deleted when drawing the new object. That is the drawing area must get UPDATED only and not REDRAWN.

In my code when one of many button is clicked, some aplhabet get displayed. I want to have functionality such that when other buttons are clicked the previously drawn alhabets must be present.Take is as if a string of alphabets getting created as the buttons are clicked. Im using Java Swing for coding.

Some piece of my code:

if(source == btnAlpha[i] )  
bollyDraw.repaint(); //bollydraw is an object of a JPanel extended class having implemented the paintComponent(Graphics g) method

In the paint() method:

if (word[i] == key) {
g.drawChars(word, i, 1, x, y);
}

© Stack Overflow or respective owner

Related posts about java

Related posts about swing