Help with image display on JTextArea
Hi!
I am a newbie!
This topic or similar ones are floating around but some of them are already closed and yet my query wasn't answered completely and hence posting this thread. Sorry for any repetitive topic.
I want to select a file from the File Open Dialog and display this selected image file into JTextArea on the window. My window contains just JTextArea and a file selection button. I have made the file selection part work very well with the .txt files that are selected through file open dialog box. Now i wish to repeat it for selecting an image file and displaying it in the JTextArea. Can somebody please guide me with the logic and the steps to achieve what I want to achieve?
Thank you in advance!
Regards,
Mozart66
Re: Help with image display on JTextArea
Displaying an image in a textarea sounds different. Normally you display text in a textarea.
Can you describe what you are trying to do?
Re: Help with image display on JTextArea
I know that textarea is meant for displaying text only mostly but i am trying to use the same area for displaying an image after selecting it through file open dialog. i know it sounds kinda weird but if a JButton can show an image, then why can't jtextarea show an image? hope this info helps....
Re: Help with image display on JTextArea
Quote:
if a JButton can show an image, then why can't jtextarea show an image
Not sure I follow the logic. If birds can fly why can't pigs fly?
The JButton class has a setIcon() method. Does the JTextArea have that method?
Re: Help with image display on JTextArea
If you want images in a TextComponent, use a JEditorPane (see Java Tip 109: Display images using JEditorPane - JavaWorld )