JTextArea font change is slow

I have a curious problem with the JTextArea control: When I bring up my `JTextArea` everything is fine and whatever I type shows up without delay. However as soon as I send a `FontSizeAction` to my `EditorKit` (RTFEditorKit in this case, but it does not seem to matter which I use), a delay, from 1 - several seconds, happens. Interestingly the delay only happens after you type something, that is a font change followed by doing nothing and then typing, makes no difference from just typing immediately. The delay is the same. I can see that right after typing the first letter after a FontSizeAction, allocation increases with a couple of megs. I have used a profiler on the application and there's nothing in my own app that seems to be the problem. **My code:** private void updateFont(MainModelManager model) { (new RTFEditorKit.FontSizeAction("font-size-" + model.getFontSize(), model.getFontSize())).actionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) ); (new RTFEditorKit.FontFamilyAction("font-family-" + model.getFontFamily(), model.getFontFamily())).actionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, model.getFontFamily()) ); } This is part of the declaration of the main model container: public class MainModelManager extends Observable { DefaultStyledDocument doc; int fontSize = 12; String fontType = "Helvetica"; StyleContext sc; Caret editorCaret; boolean editorFrameIsResizable; //... } **UPDATE:** I think I have narrowed to problem down to the FontFamilyAction because, if I comment it out the delay disappears and I can still change the font size without a problem. Maybe this has something to do with loading fonts?
can you post some relevant code?

以上就是JTextArea font change is slow的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏