I'm learning GUI programming in java AWT and am a bit stuck. I can't add a couple of check-boxes in a frame the code i'm trying is-
package awt2;
import java.awt.*;
import java.awt.event.*;
public class Checkbox {
public static void main(String args[]) {
Frame mainFrame= new Frame("Checkbox test");
Checkbox checkBox1= new Checkbox();
Checkbox checkBox2= new Checkbox();
checkBox1.setBounds(100,100,50,50);
checkBox2.setBounds(150,120,50,50);
mainFrame.add(checkBox1);
mainFrame.add(checkBox2);
mainFrame.setVisible(true);
}
}
The error reckons this on checkBox1.setBounds() and checkBox2.setBounds()-
The method setBounds(int, int, int, int) is undefined for the type Checkbox
And on mainFrame.add()-
The method add(Component) in the type Container is not applicable for the arguments (Checkbox)
Can someone explain what these errors are all about and how can i fix them? Also i'm using eclipse IDE and javac version 1.8.0_144
Aucun commentaire:
Enregistrer un commentaire