@Override public Object getDisplayValue(TypesafeEnum value, Locale locale) { String typesafeEnumString = null; if (value != null) { typesafeEnumString = value.getDisplayString(locale); } return typesafeEnumString; } }
@Override public Object getDisplayValue(TypesafeEnum value, Locale locale) { String typesafeEnumString = null; if (value != null) { typesafeEnumString = value.getDisplayString(locale); } return typesafeEnumString; } }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String typesafeEnumString = null; if (value != null){ if (! (value instanceof TypesafeEnum)){ throw new IllegalArgumentException("value must be an instance of TypesafeEnum"); } typesafeEnumString = ((TypesafeEnum) value).getDisplayString(getLocale()); } return super.getListCellRendererComponent(list, typesafeEnumString, index, isSelected, cellHasFocus); }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String typesafeEnumString = null; if (value != null){ if (! (value instanceof TypesafeEnum)){ throw new IllegalArgumentException("value must be an instance of TypesafeEnum"); } typesafeEnumString = ((TypesafeEnum) value).getDisplayString(getLocale()); } return super.getListCellRendererComponent(list, typesafeEnumString, index, isSelected, cellHasFocus); }
/** * {@inheritDoc } * */ @Override protected void setValue(Object value) { super.setValue(((TypesafeEnum) value).getDisplayString(getLocale())); }
/** Sets the <code>String</code> object for the cell being rendered to * <code>value</code>. * * @param value the string value for this cell; if value is * <code>null</code> it sets the text value to an empty string * @see JLabel#setText * * */ @Override protected void setValue(Object value) { super.setValue(((TypesafeEnum) value).getDisplayString(getLocale())); }
/** Returns a string representation of the object. In general, the * <code>toString</code> method returns a string that * "textually represents" this object. The result should * be a concise but informative representation that is easy for a * person to read. * It is recommended that all subclasses override this method. * <p> * The <code>toString</code> method for class <code>Object</code> * returns a string consisting of the name of the class of which the * object is an instance, the at-sign character `<code>@</code>', and * the unsigned hexadecimal representation of the hash code of the * object. In other words, this method returns a string equal to the * value of: * <blockquote> * <pre> * getClass().getName() + '@' + Integer.toHexString(hashCode()) * </pre></blockquote> * * @return a string representation of the object. * */ @Override public String toString() { //System.out.println("toString start"); return getTypesafeEnum().getDisplayString(getLocale()); }