• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get image from JTable to set into JTextField

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.. i'm doing my final year project using java eclipse and sqlite as database. the problem is i cannot retrived image from database (blob) and displayed in my GUI. please help me.
when i click the song title in the JTable, only png. appear instead of image.





 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not familiar with what you are trying to do with this command:

but you are trying to read from a blob--Binary Large Object--and you are trying to read a String format--of which an Image is not--then you are headed for some problems any way you look at it.
 
Hadijah Mohamad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm new with this coding. and i try so many thing. this is one of the code that i try. please help me how to convert string to blob for this case. thanks in advance!
 
Les Morgan
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite often people try to do too many things at one time. You are trying to add an Image to a JTextField, but no where do you have an Image. Read the Image first, then worry about adding it to something to view it.

Hadijah Mohamad wrote:i'm new with this coding. and i try so many thing. this is one of the code that i try. please help me how to convert string to blob for this case. thanks in advance!

 
Hadijah Mohamad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir. i want to fetch the image from JTable to set into JTextField. and the image is stored in sqlite database.
the code is one of the trial code. clear? and i cannot change the image into blob. i hope you really really help me, not judge.




Les Morgan wrote:Quite often people try to do too many things at one time. You are trying to add an Image to a JTextField, but no where do you have an Image. Read the Image first, then worry about adding it to something to view it.

 
Bartender
Posts: 732
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't put an image in a JTextField - the only thing you can put in a JTextField is a single line of text.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That last big picture you posted looks like a JTable. It's possible to display images in JTable cells, but I don't think that's what you wanted to do so I'm not going to go into that. It isn't especially simple to do.

If I understand correctly, you want that when you select a table row, the image belonging to that row gets displayed in some other component somewhere. At least that's what one of your earlier pictures suggested. Is that correct?

If so, then I suggest you put all of your existing code aside for now and just write a small piece of code which reads a single picture from a single database row and displays it in a single component in a JFrame. That way you don't need to worry about all of the complications involved with whatever you have so far and you can more easily learn how to display images. When you have that working, then you can take your image-displaying code and work it in to your existing code with JTables and so on.

I'd also suggest not using a column of the JTable for the images if you aren't actually planning for them to appear there.
 
Les Morgan
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to point out a path for you to take, but you take it as me judging you, so have fun... for I cannot help you, I can only judge.

Hadijah Mohamad wrote:
... i hope you really really help me, not judge.

reply
    Bookmark Topic Watch Topic
  • New Topic