Methods Summary |
---|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)Creates a UI for the JTextPane.
return new SynthTextPaneUI();
|
protected java.lang.String | getPropertyPrefix()Fetches the name used as a key to lookup properties through the
UIManager. This is used as a prefix to all the standard
text properties.
return "TextPane";
|
public void | installUI(javax.swing.JComponent c)
super.installUI(c);
updateForeground(c.getForeground());
updateFont(c.getFont());
|
void | paintBackground(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, javax.swing.JComponent c)
context.getPainter().paintTextPaneBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
|
public void | paintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)
context.getPainter().paintTextPaneBorder(context, g, x, y, w, h);
|
protected void | propertyChange(java.beans.PropertyChangeEvent evt)This method gets called when a bound property is changed
on the associated JTextComponent. This is a hook
which UI implementations may change to reflect how the
UI displays bound properties of JTextComponent subclasses.
If the font, foreground or document has changed, the
the appropriate property is set in the default style of
the document.
super.propertyChange(evt);
String name = evt.getPropertyName();
if (name.equals("foreground")) {
updateForeground((Color)evt.getNewValue());
} else if (name.equals("font")) {
updateFont((Font)evt.getNewValue());
} else if (name.equals("document")) {
JComponent comp = getComponent();
updateForeground(comp.getForeground());
updateFont(comp.getFont());
}
|
private void | updateFont(java.awt.Font font)Update the font in the default style of the document.
StyledDocument doc = (StyledDocument)getComponent().getDocument();
Style style = doc.getStyle(StyleContext.DEFAULT_STYLE);
if (style == null) {
return;
}
if (font == null) {
style.removeAttribute(StyleConstants.FontFamily);
style.removeAttribute(StyleConstants.FontSize);
style.removeAttribute(StyleConstants.Bold);
style.removeAttribute(StyleConstants.Italic);
} else {
StyleConstants.setFontFamily(style, font.getName());
StyleConstants.setFontSize(style, font.getSize());
StyleConstants.setBold(style, font.isBold());
StyleConstants.setItalic(style, font.isItalic());
}
|
private void | updateForeground(java.awt.Color color)Update the color in the default style of the document.
StyledDocument doc = (StyledDocument)getComponent().getDocument();
Style style = doc.getStyle(StyleContext.DEFAULT_STYLE);
if (style == null) {
return;
}
if (color == null) {
style.removeAttribute(StyleConstants.Foreground);
} else {
StyleConstants.setForeground(style, color);
}
|