使用分数宽度绘制可编辑的 JTextComponents?
我正在使用 JEditorPane,(当然)当我使用抗锯齿和分数宽度绘制组件时,文本看起来好多了。换句话说:
JEditorPane pane = new JEditorPane() {
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
super.paint(g);
}
}
如果我用静态的、不可选择的文本来执行此操作,它会绘制得很漂亮。然而,一旦我开始在其上拖动选区,我就会在帧和伪像之间出现一些奇怪的抖动。有什么方法可以用分数度量来绘制并避免这种奇怪的情况吗?我也尝试在插入符上设置属性,但没有成功。
I'm working with a JEditorPane, and (of course) the text looks so much nicer when I paint the component using antialiasing and fractional widths. In other words:
JEditorPane pane = new JEditorPane() {
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
super.paint(g);
}
}
If I do this with static, non-selectable text, it paints beautifully. However, as soon as I start dragging a selection over it, I get some weird jiggling between frames, and artifacts. Is there any way to paint with the fractional metrics and avoid that weirdness? I tried setting the attribute on the Caret as well with no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题似乎很久以前就被作者和 StanislavL 在评论中回答了:
This question seems to be answered long ago by the author and StanislavL in the comments: