Soldiers33 Posted December 12, 2009 Share Posted December 12, 2009 For coursework I have to create a media player which allows you to rate . What I need to know is it possible to have the ratings appear as stars like on wmp. I currently have a drop down list going from 1 to 5, but it looks a bit of a mess. Link to comment Share on other sites More sharing options...
0 JamesCherrill Posted December 12, 2009 Share Posted December 12, 2009 "*****".substring(0, ratingOneToFive) Link to comment Share on other sites More sharing options...
0 Soldiers33 Posted December 12, 2009 Author Share Posted December 12, 2009 "*****".substring(0, ratingOneToFive) care to explain it a bit, as im a noob in java. Also its an application not for the web. Link to comment Share on other sites More sharing options...
0 JamesCherrill Posted December 12, 2009 Share Posted December 12, 2009 Its a string of 5 asterisks. The substring method selects the first 1-5 of those stars, depending on the value of the int ratingOneToFive. Ie, input 1 into it, it gives "*", put 5 into it, it gives "*****". You can this display this anyway you want - probably a JLabel. Link to comment Share on other sites More sharing options...
0 Argote Posted December 13, 2009 Share Posted December 13, 2009 From what I read it seems that the problem is the GUI, the actual storing of the value should be fairly trivial (just get an int from 0 to 5, 0 being unrated). if you're using images with a JLabel then just add a switch for the imagepath given a value. Post screenshots, BTW. Link to comment Share on other sites More sharing options...
0 Xilo Posted December 15, 2009 Share Posted December 15, 2009 (edited) Add mouse click events (and mouse hover events if you want to get fancy) to a series of images. Clicking one will set the rating and light up the rest. ☆☆☆☆☆ Clicking the third star would result in: ★★★☆☆ For the code you would do something like sub onclick image for 1 to 5 reset every star to blank store rating based off image number for 1 to image number swap star image to filled For initial loading, you could do this. sub onload if rating = 0 return else for 1 to rating load filled star for rating+1 to 5 load empty star I don't know a bit of Java GUI or how your program is structured, but you would do something vaguely similar. An even easier way would just be using labels with a string using the unicode stars that I printed. You would just be updating the string. Edited December 15, 2009 by Xilo Link to comment Share on other sites More sharing options...
Question
Soldiers33
For coursework I have to create a media player which allows you to rate . What I need to know is it possible to have the ratings appear as stars like on wmp. I currently have a drop down list going from 1 to 5, but it looks a bit of a mess.
Link to comment
Share on other sites
5 answers to this question
Recommended Posts