Java 重新加载JFrame或JLabel

Java 重新加载JFrame或JLabel,java,swing,jframe,Java,Swing,Jframe,我正在开发一个小“点击器”,但是,如果我按下按钮,我应该得到1+分,它就不起作用了!有没有办法重新加载或其他什么? 这是我的代码:(点击事件) } 这是我的JFrame: public class game extends JFrame { public static JButton buttonStart; JButton buttonCredits; JButton buttonBack; JButton buttonLeave; public static JFrame panel =

我正在开发一个小“点击器”,但是,如果我按下按钮,我应该得到1+分,它就不起作用了!有没有办法重新加载或其他什么? 这是我的代码:(点击事件)

}

这是我的JFrame:

public class game extends JFrame
{
public static JButton buttonStart;
JButton buttonCredits;
JButton buttonBack;
JButton buttonLeave;

public static JFrame panel = new game();

public static ArrayList<Integer> timesClicked = new ArrayList<Integer>();

public static JLabel label1;
public static JLabel points;
public static String seePoints = "Deine Knöpfe: " + timesClicked.size();
public game()
{

    setLayout(null);
    label1 = new JLabel("ButtonClicker");
    points = new JLabel(seePoints);

    points.setFont(new Font("Tahoma", Font.BOLD, 15));
    points.setBounds(0, 0, 200, 200);

    label1.setFont(new Font("Tahoma", Font.BOLD, 50));
    label1.setBounds(315, 50, 500, 200);

    event e1 = new event();

    JButton b = new JButton("KNOPF");
    b.setBackground(new Color(96, 140, 247));
    b.setForeground(Color.WHITE);
    b.setFocusPainted(false);
    b.setFont(new Font("Tahoma", Font.BOLD, 15));
    b.setBounds( 402, 380, 180, 50 );


    b.addActionListener(e1);

    add(b);
    add(label1);
    add(points);

}
}
公共类游戏扩展JFrame
{
公共静态按钮按钮启动;
按钮编辑;
钮扣背;
JButton按钮leave;
公共静态JFrame面板=新游戏();
公共静态ArrayList timesClicked=新建ArrayList();
公共静态JLabel标签1;
公共静态JLabel点;
公共静态字符串seePoints=“Deine Knöpfe:+timescacked.size();
公共游戏()
{
setLayout(空);
标签1=新的JLabel(“按钮标签”);
点=新的JLabel(点);
points.setFont(新字体(“Tahoma”,Font.BOLD,15));
点.立根(0,0,200,200);
标签1.setFont(新字体(“Tahoma”,Font.BOLD,50));
标签1.立根(315,50,500,200);
事件e1=新事件();
JButton b=新JButton(“KNOPF”);
b、 挫折背景(新颜色(96140247));
b、 设置前景(颜色:白色);
b、 setFocusPainted(假);
b、 setFont(新字体(“Tahoma”,Font.BOLD,15));
b、 立根(402380 180 50);
b、 addActionListener(e1);
添加(b);
添加(标签1);
增加(点数);
}
}
(对不起,我的英语不好)

这只在程序开始时调用一次。当您添加到单击的
时间时,它不会重新计算
seePoints


每次单击时,您都需要将此变量设置为正确的值。

我应该注意,
public static
各地的变量通常都是糟糕的编程实践。有关更多信息,请查阅“封装”。
public class game extends JFrame
{
public static JButton buttonStart;
JButton buttonCredits;
JButton buttonBack;
JButton buttonLeave;

public static JFrame panel = new game();

public static ArrayList<Integer> timesClicked = new ArrayList<Integer>();

public static JLabel label1;
public static JLabel points;
public static String seePoints = "Deine Knöpfe: " + timesClicked.size();
public game()
{

    setLayout(null);
    label1 = new JLabel("ButtonClicker");
    points = new JLabel(seePoints);

    points.setFont(new Font("Tahoma", Font.BOLD, 15));
    points.setBounds(0, 0, 200, 200);

    label1.setFont(new Font("Tahoma", Font.BOLD, 50));
    label1.setBounds(315, 50, 500, 200);

    event e1 = new event();

    JButton b = new JButton("KNOPF");
    b.setBackground(new Color(96, 140, 247));
    b.setForeground(Color.WHITE);
    b.setFocusPainted(false);
    b.setFont(new Font("Tahoma", Font.BOLD, 15));
    b.setBounds( 402, 380, 180, 50 );


    b.addActionListener(e1);

    add(b);
    add(label1);
    add(points);

}
}
public static String seePoints = "Deine Knöpfe: " + timesClicked.size();