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

The following examples show how to use javax.swing.text.html.CSS.Attribute. These examples are extracted from open source projects. 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 Project: netbeans   Source File: SwingBrowserImpl.java    License: 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 Project: netbeans   Source File: SwingBrowserImpl.java    License: 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 Project: netbeans   Source File: SwingBrowserImpl.java    License: 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 );
}