Changeset 880 for java/SwingComponents/src/net/oni2
- Timestamp:
- Jun 3, 2013, 11:46:25 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/SwingComponents/src/net/oni2/swingcomponents/HTMLLinkLabel.java
r849 r880 15 15 import javax.swing.event.HyperlinkListener; 16 16 import javax.swing.text.DefaultCaret; 17 import javax.swing.text.html.CSS; 17 18 import javax.swing.text.html.HTMLEditorKit; 18 19 import javax.swing.text.html.StyleSheet; … … 39 40 40 41 setContentType("text/html"); 41 42 HTMLEditorKit hek = (HTMLEditorKit) getEditorKit(); 43 StyleSheet css = hek.getStyleSheet(); 44 css.removeStyle("p"); 45 42 46 43 Font font = new JLabel().getFont(); 47 44 … … 80 77 81 78 /** 79 * Add or reset a CSS attribute for styling the text 80 * 81 * @param selector 82 * CSS selector 83 * @param attribute 84 * CSS attribute 85 * @param value 86 * Value 87 */ 88 public void setCssAttribute(String selector, CSS.Attribute attribute, 89 String value) { 90 HTMLEditorKit hek = (HTMLEditorKit) getEditorKit(); 91 StyleSheet css = hek.getStyleSheet(); 92 css.addRule(String.format("%s {%s: %s}", selector, attribute.toString(), value)); 93 } 94 95 /** 82 96 * Allow or forbid to set a non-null border 83 97 * … … 99 113 @Override 100 114 public void setText(String t) { 115 if (t.startsWith("<p>")) 116 t = t.replaceFirst("<p>", "<p style=\"margin-top: 0\">"); 101 117 super.setText(prefix + t + suffix); 102 118 }
Note:
See TracChangeset
for help on using the changeset viewer.