将数据作为列表放入JLabel

时间:2016-05-01 23:26:00

标签: java swing jlabel

我试图在JPanel中制作一个高分系统。但是,我希望我得到的数据在垂直列表中。 This is how it looks like now

public class Highscore extends JPanel {

    Mainpanel mp = new Mainpanel(10);

    HighscoreManager manage = new HighscoreManager();

    public Highscore() {

        setBounds(0, 0, 800, 600);
        setLayout(null);

        JButton btnNewButton = new JButton("New button");
        btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                mp = new Mainpanel();

                mp.setVisible(true);

            }
        });

        JLabel lblNewLabel = new JLabel("New label");
        lblNewLabel.setIcon(new ImageIcon("BackgroundHighscore.jpg"));
        lblNewLabel.setBounds(0, 0, 800, 600);
        add(lblNewLabel);

        manage.addScore("Bart",240);
        manage.addScore("Marge",300);
        manage.addScore("Maggie",220);
        manage.addScore("Homer",100);
        manage.addScore("Lisa",270);


        JLabel highscore = new JLabel("HIGHSCORE");
        highscore.setBounds(200,200,400,300);
        highscore.setText(manage.getHighscoreString());
        lblNewLabel.add(highscore);
    }

}

任何帮助将不胜感激!

0 个答案:

没有答案