本文介绍了java gwt richtextarea更改font-family的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
java gwt的Object richtextarea有默认的font-family'times new roman'是不是有可能把这个家族变成'Arial'?
The Object richtextarea of java gwt has as default the font-family 'times new roman' is it somehow possible to change the family to 'Arial'?
推荐答案
你有几个选择。您可以创建一个CSS类并将其设置在RichTextArea内的文档的body元素上,或者可以直接在其上设置style属性。如果您希望在整个应用程序中进行这种更改,我建议您创建一个新类并添加一个InitializeHandler。
You have several options. You can create a CSS class and set it on the body element of the document inside RichTextArea, or you can set the style attribute on it directly. If you want this change to be consistent throughout your app, I recommend creating a new class and adding an InitializeHandler to it.
public class MyRichTextArea extends RichTextArea {
public MyRichTextArea() {
addInitializeHandler(new InitializeHandler() {
@Override
public void onInitialize(InitializeEvent ie) {
Document document = IFrameElement.as(getElement()).getContentDocument();
BodyElement body = document.getBody();
body.setAttribute("style", "font-family: Arial Unicode MS,Arial,sans-serif;");
});
}
}
}
这篇关于java gwt richtextarea更改font-family的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!