Hey rigth now im in the process of learning the draw functions and I would like to make it so that the screen doesnt clear itself each time I draw, Here part of my code doing the drawing and stuff.
public void keyPressed( KeyEvent e ) { }
public void keyReleased( KeyEvent e ) { }
public void keyTyped( KeyEvent e ) {
char c = e.getKeyChar();
if ( c == 127) {
//s = s - 1;
}
if ( c != KeyEvent.CHAR_UNDEFINED && c != 127 && c != 50 && c != 52 && c != 54 && c != 56) {
paintNum = 1;
s = s + c;
repaint();
e.consume();
}
if (c == 50) {
paintNum = 2;
repaint();
e.consume();
}
if (c == 52) {
paintNum = 2;
repaint();
e.consume();
}
if (c == 54) {
paintNum = 2;
repaint();
e.consume();
}
if (c == 56) {
paintNum = 2;
repaint();
e.consume();
}
}
public void paint( Graphics g ) {
if (paintNum == 1) {
g.setColor( Color.gray );
g.drawLine( x, y, x, y-10 );
g.drawLine( x, y, x+10, y );
g.setColor( Color.green );
g.drawString( s, 10, 17 );
paintNum = 0;
}
if (paintNum == 2) {
g.drawImage(logo,0,0,this);
paintNum = 0;
}
If you can help I thank you very much!


Reply With Quote


Bookmarks