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.
精彩评论