我有这个程序,它几乎是一个计算器但是每次点击标签时都会有一个移动的JLabel,它应该会改变颜色,但是我在代码的最底部有3个错误,我用注释标记了.这三个都是:错误:不兼容的类型:从long到int的可能有损转换
public class TestCalculator {
private ResultPane resultPane;
public static void main(String[] args) {
new TestCalculator();
}
public TestCalculator() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
resultPane = new ResultPane();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
}
JFrame frame = new JFrame("Testing");
frame.setGlassPane(resultPane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new CalculatorPane(resultPane));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setBounds(200,200,500,400);
}
});
}
public class ResultPane extends JPanel {
private JLabel result;
private Timer timer;
private int xDelta …Run Code Online (Sandbox Code Playgroud)