Results 1 to 3 of 3
  1. #1
    m00n is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Red face image display in JPanel

    Hi!
    I was wondering if I could get some help to display an image along with its name in Jpanel.

    I have an image in mysql database stored as blob and found it and stored it to

    Java Code:
    Blob blob = rs.getBlob("image");
    and
    Java Code:
    String name = rs.getString("name");
    I have no idea how to display it though.
    all i've managed to do is display the name using JLabel namel = new Jlabel(name); and added it to the panel...

    thanks in advance!

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: image display in JPanel

    Hi,
    first you need to get an image from your blob. You call getBytes to get the bytes, create a stream on it and them create the image from the stream with ImageIO.
    Then you can display the image as background picture or you can write code that paints it in the paintComponent method.

    For the text you could use a JLabel or if you used the paintComponent before you could use drawString of the Graphics object.

    If you need more information: either ask or search on google.

    Konrad

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: image display in JPanel

    Just use a JLabel. You can display an ImageIcon along with text.

Similar Threads

  1. Replies: 4
    Last Post: 05-20-2012, 07:15 AM
  2. image correctly loaded, but JPanel wont display
    By apchar in forum AWT / Swing
    Replies: 3
    Last Post: 04-13-2011, 04:15 AM
  3. Cannot display in JPanel
    By atch in forum New To Java
    Replies: 2
    Last Post: 02-05-2010, 03:21 PM
  4. can't get anything to display on my JPanel
    By v1nsai in forum AWT / Swing
    Replies: 9
    Last Post: 08-25-2009, 09:25 AM
  5. How to display image from byte array in JPANEL
    By waqasdaar in forum AWT / Swing
    Replies: 0
    Last Post: 03-22-2009, 01:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •