【发布时间】:2010-11-20 19:22:19
【问题描述】:
我正在尝试使用 JTextPane 制作文本编辑器,但在设置所选文本颜色时遇到问题。这是最好的方法(但显然不起作用):
JMenuItem button = new JMenuItem("Set Color");
toolbar.add(button);
button.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e) {
Color c = JColorChooser.showDialog(frame,"Choose a color", getBackground());
textPane.getSelectedText().StyledEditorKit.ForegroundAction("color",c);
}
});
关于如何让它发挥作用的任何建议?还是有更好的方法?
谢谢
【问题讨论】: