• 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

Select one id from JList....

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!!! everybody....

I'm paul and my eanglish is bad i hope you can unserstand my problem.

i'm creating one program with db...in this db i have one table and i have id(auto_increment), nome, mp3, testo

in this program add name of mp3 in JList selecting the table with JComoBox...this is code:

here it's ok!!!

now i want select name of mp3 in JList and i want add file .txt in JTextArea and to play song selected...this is code:


and i have class QueryResult...this is cod:


from many days i don't resolve this problem!!!

HELP ME PLEASE!!!

Ihope you can understand my problem...
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
Welcome to the Ranch!

Why did you create 5 topics for the same issue? Please create only one message for your issue. Using all caps is considered shouting, so, please avoid that. As you are new here, I would also like to point you out to a link How To Ask Questions which explains how to ask questions effectively and nicely.

For your issue:
You are adding a list of String values to the JList. These strings are of the format "1.name".
When you call list.getSelectedValue(), you will get back this String value. So, if you want to get the 'name' part from this string, you should use the String methods like indexOf() and substring() to get the value and then use it.

I would also like to point out the various issues in your code:
1) You should add a ListSelecttionListener to listen to selection changes and not MouseListener. You can read about this here

2) You are using Statement and appending the value to the where condition. This is not a good coding practice. You should use PreparedStatement.

3) You have the GUI code and the DB code in the same place. You should look to separate these into separate classes.
 
reply
    Bookmark Topic Watch Topic
  • New Topic