-2
我試圖將錯誤消息彈出說異常的空白文本框
Error: Amount is required
當他們在盒子還沒有添加量破例。以下是我有:
String output = "Gas Amount: $" + gasAmount +
"\nCar Wash: " + price;
try {
throw new AmountException();
JOptionPane.showMessageDialog(null, output);
}
catch (AmountException ae) {
JOptionPane.showMessageDialog(null, ae.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
我也補充一點,我的代碼,但現在我的錯誤信息不會彈出。 –
你確定你的'gasAmount'等於null嗎?它是一個Number類或原始類型的實例嗎?也許它等於0 ... –