lundi 1 février 2016

Hi I am new to java. The following code is troubling me for a while now

Output:Checkbox1.java:13: error: constructor Checkbox in class Checkbox cannot be applied to given types; add(A=new Checkbox("Hai")); ^ required: no arguments found: String reason: actual and formal argument lists differ in length Checkbox1.java:14: error: cannot find symbol A.addItemListener(this); ^ symbol: method addItemListener(Checkbox1) location: variable A of type Checkbox 2 errors

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Checkbox1 extends Applet implements ItemListener {
    private TextField B;
    private Checkbox A;

    public void init() {
        add(B=new TextField(20));
        add(A=new Checkbox("Hai"));
        A.addItemListener(this);
    }

    public void itemStateChanged(ItemEvent E) {
        if(E.getItemSelectable() == A)
            B.setText("Hello");
    }
}




Aucun commentaire:

Enregistrer un commentaire