• Post Reply Bookmark Topic Watch Topic
  • New Topic

Select one id from JList....  RSS feed

paul beppe
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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!!!


Ihope you can understand my problem...
Ranganathan Kaliyur Mannar
Posts: 1103
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!