Java practical 3

 avatar
Rohit143
java
3 years ago
1.2 kB
16
Indexable
import java.awt.*;
class MyFrame extends Frame{
    MyFrame(){
        TextField t;    
        Button b[]=new Button[15];
        Button b1[]=new Button[6];
        String op2[]={"+","-","*","%","=","C"};
        setLayout(new GridLayout(5,4));
        t=new TextField(20);
        setBackground(Color.black);
        setForeground(Color.white);

        int k=0;
        t.setEditable(false);
        t.setBackground(Color.white);                      
        t.setText("0");
        for(int i=0;i<10;i++)
        {
                    b[i]=new Button(""+k);
                    add(b[i]);
                    k++;
                    b[i].setBackground(Color.black);
        }
        
        for(int i=0;i<6;i++)
        {
                    b1[i]=new Button(""+op2[i]);
                    add(b1[i]);
                    b1[i].setBackground(Color.black);
        }
        add(t);     
        add(new Label("BY Rohit Nandagawali"));
        setVisible(true);       
        setSize(500,500);
    }
}
public class practical3 {
    public static void main(String[] args) {
        new MyFrame();
    }
    
}
Editor is loading...