38 |
|
|
39 |
package javax.swing.plaf.basic; |
package javax.swing.plaf.basic; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
|
|
43 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
44 |
|
import javax.swing.JTextPane; |
45 |
|
import javax.swing.plaf.ColorUIResource; |
46 |
import javax.swing.UIDefaults; |
import javax.swing.UIDefaults; |
47 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
48 |
import javax.swing.text.Element; |
import javax.swing.text.Element; |
49 |
import javax.swing.text.PlainView; |
import javax.swing.text.PlainView; |
50 |
|
import javax.swing.text.Style; |
51 |
|
import javax.swing.text.StyleConstants; |
52 |
|
import javax.swing.text.StyleContext; |
53 |
import javax.swing.text.View; |
import javax.swing.text.View; |
54 |
|
|
55 |
public class BasicTextPaneUI extends BasicEditorPaneUI |
public class BasicTextPaneUI extends BasicEditorPaneUI |
78 |
{ |
{ |
79 |
return "TextPane"; |
return "TextPane"; |
80 |
} |
} |
81 |
|
|
82 |
|
/** |
83 |
|
* Installs this UI on the specified <code>JTextPane</code>. This calls the |
84 |
|
* super implementation and then adds a default style to the text pane. |
85 |
|
* |
86 |
|
* @param c the text pane to install the UI to |
87 |
|
*/ |
88 |
|
public void installUI(JComponent c) |
89 |
|
{ |
90 |
|
super.installUI(c); |
91 |
|
JTextPane tp = (JTextPane) c; |
92 |
|
Style defaultStyle = tp.getStyle(StyleContext.DEFAULT_STYLE); |
93 |
|
defaultStyle.addAttribute(StyleConstants.Foreground, |
94 |
|
new ColorUIResource(Color.BLACK)); |
95 |
|
defaultStyle.addAttribute(StyleConstants.FontFamily, "Serif"); |
96 |
|
defaultStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE); |
97 |
|
defaultStyle.addAttribute(StyleConstants.Bold, Boolean.FALSE); |
98 |
|
defaultStyle.addAttribute(StyleConstants.FontSize, new Integer(12)); |
99 |
|
} |
100 |
} |
} |