javax.swing.text.html.CSS.Attribute Java Examples

The following examples show how to use javax.swing.text.html.CSS.Attribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwingBrowserImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * CSS with e.g. 'font-size: 75%' makes the HTML unreadable in the default JEditorPane
 * @param key
 * @param value
 * @return 
 */
private static String fixFontSize( Attribute key, String value ) {
    if( "font-size".equals( key.toString() ) && null != value && value.endsWith( "%" ) ) {
        String strPercentage = value.replace( "%", "");
        int percentage = Integer.parseInt( strPercentage );
        if( percentage < 100 ) {
            value = "100%";
        }
    }
    return value;
}
 
Example #2
Source File: SwingBrowserImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void addCSSAttribute( MutableAttributeSet attr, Attribute key, String value ) {
    value = fixFontSize( key, value );
    super.addCSSAttribute( attr, key, value );
}
 
Example #3
Source File: SwingBrowserImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean addCSSAttributeFromHTML( MutableAttributeSet attr, Attribute key, String value ) {
    value = fixFontSize( key, value );
    return super.addCSSAttributeFromHTML( attr, key, value );
}