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
包含此類的文件中是否還有其他內容?這個問題可能來自課堂上的某些事情。你有沒有看到我說過在課程結束時你沒有右括號? –