This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I need to know if i can paint/print an image on the JTextArea. There are methods like createImage(..),prepareImage(..),setPixels(..),drawImage(..) and many more. I want to know if it is possible with the above mentioned methods. I am basically trying to print the smileys onto the JTextArea in my chat program. JTextArea is placed in a JFrame.I also tried to set the JTextArea as a window by using SwingUtilities.windowForComponent(Component) method which returns a window object. But no change.
If anybody could just tell me how i can add pictures to JTextArea (like smileys in Messenger), I would be very grateful. Thanks a lot, Preethi
You should be able to draw on a JTextArea using <PRE> JTextArea myArea = new JTextArea(); myArea.getGraphics().drawImage(... </PRE> You will have to pick the appropriate drawImage for what you want to do. But I'm not sure that this will solve your problem, because I don't know how an image will behave when scrolling the JTextArea.
Joined: Dec 09, 2000
I have already tried that, i do get the image in the textarea, but it only remains for a second. The image is not retained in the JTextArea. It only blinks. Is there someway i can retain it on the JTextArea. I used update(),repaint(),paint()...but couldn't get it. Any idea, how it can be retained. Thanks, Preethi