Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Help with image display on JTextArea

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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....

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help with image display on JTextArea

    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?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default 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 )

Similar Threads

  1. Image Doesn't Display with Qualified Image Path????
    By swaginator in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 31st, 2012, 12:29 AM
  2. Can't display an image...
    By barebackingtiger in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 25th, 2012, 07:21 PM
  3. Trying to display text from file in JTextArea. Please Help.
    By rjdelight in forum Java Theory & Questions
    Replies: 7
    Last Post: June 29th, 2011, 05:10 AM
  4. Trouble getting an image to display.
    By Skyhigh32 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 23rd, 2011, 07:52 AM
  5. Display Image (png)
    By vimalaranjan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2011, 06:44 PM