JTextArea txt = new JTextArea();
StringBuffer sb = new StringBuffer();
sb.append("Employee Information");
sb.append("\n");
sb.append("Name:");
txt.setText(sb.toString());
这里我需要将“员工信息”设置为粗体格式..如何做.. 我试过这样
sb.append("<html><b>Employee Information</b></html>");
但是它正常打印文本...如何加粗?
最佳答案
JText 区域是一个纯文本区域,对于样式化的文本区域,您需要像 JEditorPane 这样的东西或 JTextPane,看看 Documentation
关于javascript - 如何在 JTextArea 中对文本进行样式化(加粗)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8515477/