393 */ 394 public int getID() { 395 return id; 396 } 397 398 /** 399 * Returns a String representation of this object. 400 */ 401 public String toString() { 402 String srcName = null; 403 if (source instanceof Component) { 404 srcName = ((Component)source).getName(); 405 } else if (source instanceof MenuComponent) { 406 srcName = ((MenuComponent)source).getName(); 407 } 408 return getClass().getName() + "[" + paramString() + "] on " + 409 (srcName != null? srcName : source); 410 } 411 412 /** 413 * Returns a string representing the state of this <code>Event</code>. 414 * This method is intended to be used only for debugging purposes, and the 415 * content and format of the returned string may vary between 416 * implementations. The returned string may be empty but may not be 417 * <code>null</code>. 418 * 419 * @return a string representation of this event 420 */ 421 public String paramString() { 422 return ""; 423 } 424 425 /** 426 * Consumes this event, if this event can be consumed. Only low-level, 427 * system events can be consumed 428 */ 429 protected void consume() { 430 switch(id) { 431 case KeyEvent.KEY_PRESSED: 432 case KeyEvent.KEY_RELEASED: 433 case MouseEvent.MOUSE_PRESSED: 434 case MouseEvent.MOUSE_RELEASED: 435 case MouseEvent.MOUSE_MOVED: 436 case MouseEvent.MOUSE_DRAGGED: 437 case MouseEvent.MOUSE_ENTERED: | 393 */ 394 public int getID() { 395 return id; 396 } 397 398 /** 399 * Returns a String representation of this object. 400 */ 401 public String toString() { 402 String srcName = null; 403 if (source instanceof Component) { 404 srcName = ((Component)source).getName(); 405 } else if (source instanceof MenuComponent) { 406 srcName = ((MenuComponent)source).getName(); 407 } 408 return getClass().getName() + "[" + paramString() + "] on " + 409 (srcName != null? srcName : source); 410 } 411 412 /** 413 * Returns a string representing the state of this {@code Event}. 414 * This method is intended to be used only for debugging purposes, and the 415 * content and format of the returned string may vary between 416 * implementations. The returned string may be empty but may not be 417 * {@code null}. 418 * 419 * @return a string representation of this event 420 */ 421 public String paramString() { 422 return ""; 423 } 424 425 /** 426 * Consumes this event, if this event can be consumed. Only low-level, 427 * system events can be consumed 428 */ 429 protected void consume() { 430 switch(id) { 431 case KeyEvent.KEY_PRESSED: 432 case KeyEvent.KEY_RELEASED: 433 case MouseEvent.MOUSE_PRESSED: 434 case MouseEvent.MOUSE_RELEASED: 435 case MouseEvent.MOUSE_MOVED: 436 case MouseEvent.MOUSE_DRAGGED: 437 case MouseEvent.MOUSE_ENTERED: |