/ Published in: Java
                    
                                        
Note that there is limited support for _CSS_ in Swing components which render HTML text.   This example employs `padding`, `margin` and `font-size`.
The full list of supported properties (and their limitations) are in the [Javadoc][1]
[1] http://download.oracle.com/javase/6/docs/api/javax/swing/text/html/CSS.html "CSS"
                The full list of supported properties (and their limitations) are in the [Javadoc][1]
[1] http://download.oracle.com/javase/6/docs/api/javax/swing/text/html/CSS.html "CSS"
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
package org.example;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
private static final long serialVersionUID = -7106531716716468891L;
public Swing() {
super();
someJLabel = new JLabel("<html><body><p style=\"padding:10; font-size:30\">First line</p><p style=\"padding:10; font-size:20\">Second line</p></body></html>");
// someJLabel.setFont(new Font("Arial", Font.PLAIN, 16));
this.add(someJLabel);
}
frame.getContentPane().add(new Swing());
frame.setSize(30, 140);
frame.pack();
}
};
frame.addWindowListener(wndCloser);
frame.setVisible(true);
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                