@s_nd | ||
what does it really do, and how is it used? |
||
3
Replies
16013
Views
1 Bookmarks
|
@yamta | 25 February 07 | |
e.consume(); is used to eliminate a keypad(keyboard) operation after a certain opereation. try this u may find out what i'm talking about; here we go import java.applet.*; import java.awt.*; import java.awt.event.*; public class Keyboard1 extends Applet implements KeyListener, MouseListener { int width, height; int x, y; String s = ''; public void init() { width = getSize().width; height = getSize().height; setBackground( Color.black ); x = width/2; y = height/2; addKeyListener( this ); addMouseListener( this ); } public void keyPressed( KeyEvent e ) { } public void keyReleased( KeyEvent e ) { } public void keyTyped( KeyEvent e ) { char c = e.getKeyChar(); if ( c != KeyEvent.CHAR_UNDEFINED ) { s = s + c; repaint(); e.consume(); } } public void mouseEntered( MouseEvent e ) { } public void mouseExited( MouseEvent e ) { } public void mousePressed( MouseEvent e ) { } public void mouseReleased( MouseEvent e ) { } public void mouseClicked( MouseEvent e ) { x = e.getX(); y = e.getY(); s = ''; repaint(); e.consume(); } public void paint( Graphics g ) { g.setColor( Color.gray ); g.drawLine( x, y, x, y-10 ); g.drawLine( x, y, x+10, y ); g.setColor( Color.green ); g.drawString(
|
||
@sroc | 17 August 07 | |
Wow u hv coded here.. Gr8 work bro.. :)
|
||
@s_nd | 30 December 07 | |
yamta clear off! lol.
|
||
Java Forum
Bookmarks
Java