Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swing star rating

Tags:

java

swing

rating

Is there any Swing Star rating widget.. am thinking of implementing my own .. but finding one will save me so much time

Thank you

like image 992
AhmadAssaf Avatar asked Jan 06 '11 17:01

AhmadAssaf


1 Answers

What about this one:

Star Rating Panel for Java Swing

Sample code to use the StarRater (using the example from the comments):

public class Test {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        JPanel panel = new JPanel();
        StarRater starRater = new StarRater(5, 2, 1);
        starRater.addStarListener(
            new StarRater.StarListener()   {

                public void handleSelection(int selection) {
                    System.out.println(selection);
                }
            });
        panel.add(starRater);
        frame.getContentPane().add(panel);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
like image 171
MicSim Avatar answered Nov 15 '22 11:11

MicSim