开发者

How to draw a box around the text when i've selected the text with mouse in Text area?

I ha开发者_运维问答ve used

textArea1=new TextArea();
String s=textArea1.getSelectedText();
g.drawRect(s.length(),s.length(),s.length(),s.length());

but its not working as expected.


You question is confusing. You use a Swing tag, but you also use a TextArea text which is an AWT component, not a Swing component.

I would suggest that you do use Swing and that you use a JTextArea. In this case you can add a "highlight" to the specified. Here is a custom class that allows you to use a Rectangle Painter for this highlight.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜