practical 3 java

 avatar
Rohit143
java
2 years ago
1.5 kB
6
Indexable
Never
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);     
                        setVisible(true);       
                        setSize(500,500);
    }
}
public class practical3 {
    public static void main(String[] args) {
        new MyFrame();
    }
    
}