0
public void buildButtonPanel()
{
buttonPanel = new JPanel();
calcButton = new JButton("Calculate Charges");
exitButton = new JButton("Exit");
calcButton.addActionListener(new CalcButtonListener());
exitButton.addActionListener(new ExitButtonListener());
buttonPanel.add(calcButton);
buttonPanel.add(exitButton);
private class CalcButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
total = routine.getRoutineCost() +
nonRoutine.getNonRoutineCost();
DecimalFormat dollar = new DecimalFormat("0.00");
JOptionPane.showMessageDialog(null, "Total: $" + dollar.format(total));
}
private class ExitButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
System.exit(0);
}
错误时预期:类,接口,或枚举预期错误:类,接口,或枚举编译
在每行同样的错误。
我假设它是一个大括号的错误,但我已经重做了我的大括号3次,而且我仍然在同一部分发生同样的错误。
在整个buildButtonPanel类的末尾没有闭合大括号。错误出现在哪里? –
它从public void buildButtonPanel开始。如果有帮助,错误的指标在第一行的void下,然后继续在calcButton = new JButton(“Calculate Charges”); – LizzySmit
包含此类的文件中是否还有其他内容?这个问题可能来自课堂上的某些事情。你有没有看到我说过在课程结束时你没有右括号? –