1 7 8 package org.jdesktop.swing.event; 9 10 import java.util.EventObject ; 11 12 import java.util.logging.Level ; 13 14 26 public class MessageEvent extends EventObject { 27 28 private Object value; 29 private long when; 30 private Level level = Level.INFO; 31 32 public MessageEvent(Object source) { 35 super(source); 36 } 37 38 41 public MessageEvent(Object source, Object message) { 42 this(source, message, Level.INFO); 43 } 44 45 46 public MessageEvent(Object source, Object value, Level level) { 47 this(source, value, level, 0L); 48 } 49 50 58 public MessageEvent(Object source, Object value, Level level, long when) { 59 super(source); 60 this.value = value; 61 this.level = level; 62 this.when = when; 63 } 64 65 71 public String getMessage() { 72 if (value != null) { 73 Throwable t = getThrowable(); 74 if (t != null) { 75 return t.getMessage(); 76 } else { 77 return value.toString(); 78 } 79 } else { 80 return ""; 81 } 82 } 83 84 89 public Throwable getThrowable() { 90 if (value != null && value instanceof Throwable ) { 91 return (Throwable )value; 92 } 93 return null; 94 } 95 96 100 public Object getValue() { 101 return value; 102 } 103 104 107 public long getWhen() { 108 return when; 109 } 110 111 117 public Level getLevel() { 118 if (level == null) { 119 level = Level.INFO; 120 } 121 return level; 122 } 123 124 public String toString() { 125 String message = "value=" + getMessage(); 126 message += ", level=" + getLevel(); 127 message += ", when=" + getWhen(); 128 129 return message; 130 } 131 } 132 | Popular Tags |