好吧,我正在点击游戏和Blah Blah Blah ...点是,我不能让JLabel更新......我很困惑......看到我已经完成了这个......这里是我的守则.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ClickingGame extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
static JFrame frame;
static JButton startbutton, clickingbutton, timerstop;
static JLabel timelabel, scorelabel;
static int time = 0;
static JTextField entertime;
static Timer clock;
static Timer countdown;
public ClickingGame() {
setLayout(new GridLayout(3, 2, 5, 5));
startbutton = new JButton("Start CountDown");
timelabel = new JLabel("Time Left = NULL", SwingConstants.CENTER);
entertime = new JTextField();
clickingbutton = new JButton("Click …Run Code Online (Sandbox Code Playgroud) File f = new File(System.getProperty("user.home/Downloads"));
Run Code Online (Sandbox Code Playgroud)
为什么这段代码会出现NPE错误?
我知道它返回null,但目录在那里......