编译期间的语法错误

时间:2014-03-05 00:14:21

标签: java checkbox

我做了一些研究,我认为我有这个嵌套错误或者init()标题可能不正确?我一直在研究同样的问题两天,但似乎无法弄清楚我做错了什么。这个任务是昨天到期的,但我无法调试它来发送。

我一直收到这个错误:     ShippingCostCalcApplet.java:35:错误:预期       Checkbox hiddenBox = new Checkbox(“”),true,codeGroup);                                              ^     ShippingCostCalcApplet.java:35:错误:非法开始表达       Checkbox hiddenBox = new Checkbox(“”),true,codeGroup);                                                  ^     ShippingCostCalcApplet.java:35:错误:';'预期       Checkbox hiddenBox = new Checkbox(“”),true,codeGroup);                                                            ^ 3个错误

以下是代码:

public class ShippingCostCalcApplet extends Applet implements ItemListener
{
   double price, shippingCost;
   int code;
   Color purple = new Color (72, 61, 139);

   public void init()
   { 
   Label promptLabel = new Label("Enter the total order price (do not use punctuation or dollar signs).");
      TextField priceField = new TextField(20);

   Label codeLabel = new Label("Select your method of shipping:");

   CheckboxGroup codeGroup = new CheckboxGroup();
      Checkbox overnightBox = new Checkbox("Priorityovernight shipping",false,codeGroup);
      Checkbox expressBox = new Checkbox("Express shipping 2 business days",false,codeGroup);
      Checkbox standardBox = new Checkbox("Standard shipping 3-7 business days",false,codeGroup);
      Checkbox hiddenBox = new Checkbox(" "),true,codeGroup);

   Label outputLabel = new Label("Select your shipping rate.");


         setBackground(purple);
         setForeground(Color.white);
         add(promptLabel);
         add(priceField);
         priceField.requestFocus();
         priceField.setForeground(Color.black);
         add(codeLabel);
         add(overnightBox);
         overnightBox.addItemListener(this);
         add(expressBox);
         expressBox.addItemListener(this);
         add(standardBox);
         standardBox.addItemListener(this);
         add(outputLabel);
      }

1 个答案:

答案 0 :(得分:2)

摆脱额外的支架。

Checkbox hiddenBox = new Checkbox(" "),true,codeGroup);

Checkbox hiddenBox = new Checkbox(" ",true,codeGroup);