Follow me on Twitter RSS FEED

Java Scientific Calculator design part



පහත downlodw click කර එහි java cord 1ක notepad එකකට copy කර CreateCal.java නමින් save කර compile කර run කර බලන්න


import java.awt.*;

class Cal extends Frame{

Cal(){

setTitle("Scientific Calculator");

setSize(500,230);

setResizable(false);

setBackground(new Color(194,217,241));

` BorderLayout bl=new BorderLayout();

Panel p1=new Panel();

Panel p2=new Panel();

Panel p3=new Panel();

Panel p4=new Panel();

add(p1,bl.SOUTH);

add(p2,bl.NORTH);

add(p3,bl.WEST);

add(p4,bl.EAST);

TextField tf=new TextField(50);

p2.add(tf);

GridLayout gl1=new GridLayout(5,10,6,6);

p1.setLayout(gl1);

GridLayout gl2=new GridLayout(1,3,8,8);

p3.setLayout(gl2);

GridLayout gl3=new GridLayout(1,5,6,6);

p4.setLayout(gl3);

//CREATE cHECKBOX

Checkbox c1=new Checkbox("Degrees",false);

p3.add(c1);

Checkbox c2=new Checkbox("Radians",false);

p3.add(c2);

Checkbox c3=new Checkbox("Grads",false);

p3.add(c3);

Button b0 = new Button (null);

p1.add(b0);

Button b1 = new Button ("Inv");

p1.add(b1);

Button b2 = new Button ("In");

p1.add(b2);

Button b3 = new Button ("(");

p1.add(b3);

Button b4 = new Button (")");

p1.add(b4);

Button b5 = new Button ("<--");

p1.add(b5);

Button b6 = new Button ("CE");

p1.add(b6);

Button b7 = new Button ("C");

p1.add(b7);

Button b8 = new Button ("+/-");

p1.add(b8);

Button b9 = new Button ("v");

p1.add(b9);

Button b10 = new Button ("Int");

p1.add(b10);

Button b11 = new Button ("sinh");

p1.add(b11);

Button b12 = new Button ("sin");

p1.add(b12);

Button b13 = new Button ("X2");

p1.add(b13);

Button b14 = new Button ("n!");

p1.add(b14);

Button b15 = new Button ("7");

p1.add(b15);

Button b16 = new Button ("8");

p1.add(b16);

Button b17 = new Button ("9");

p1.add(b17);

Button b18 = new Button ("/");

p1.add(b18);

Button b19 = new Button ("%");

p1.add(b19);

Button b20 = new Button ("dms");

p1.add(b20);

Button b21 = new Button ("cosh");

p1.add(b21);

Button b22 = new Button ("cos");

p1.add(b22);

Button b23 = new Button ("xY");

p1.add(b23);

Button b24 = new Button ("y_/X");

p1.add(b24);

Button b25 = new Button ("4");

p1.add(b25);

Button b26 = new Button ("5");

p1.add(b26);

Button b27 = new Button ("6");

p1.add(b27);

Button b28 = new Button ("*");

p1.add(b28);

Button b29 = new Button ("1/x");

p1.add(b29);

Button b30 = new Button ("Pi");

p1.add(b30);

Button b31 = new Button ("tanh");

p1.add(b31);

Button b32 = new Button ("tan");

p1.add(b32);

Button b33 = new Button ("x3");

p1.add(b33);

Button b34 = new Button ("3_/x");

p1.add(b34);

Button b35 = new Button ("1");

p1.add(b35);

Button b36 = new Button ("2");

p1.add(b36);

Button b37 = new Button ("3");

p1.add(b37);

Button b38 = new Button ("-");

p1.add(b38);

Button b39 = new Button ("=");

p1.add(b39);

Button b40 = new Button ("F-E");

p1.add(b40);

Button b41 = new Button ("Exp");

p1.add(b41);

Button b42 = new Button ("Mod");

p1.add(b42);

Button b43 = new Button ("log");

p1.add(b43);

Button b44 = new Button ("10x");

p1.add(b44);

Button b45 = new Button ("");

p1.add(b45);

Button b46 = new Button ("0");

p1.add(b46);

Button b47 = new Button (".");

p1.add(b47);

Button b48 = new Button ("+");

p1.add(b48);

Button b49 = new Button ("");

p1.add(b49);

Button b50 = new Button ("MC");

p4.add(b50);

Button b51 = new Button ("MR");

p4.add(b51);

Button b52 = new Button ("MS");

p4.add(b52);

Button b53 = new Button ("M+");

p4.add(b53);

Button b54 = new Button ("M-");

p4.add(b54);

//bUTTON COLOUR

b0.setBackground(new Color(235,242,252));

b1.setBackground(new Color(235,242,252));

b1.setForeground(Color.red);

b2.setBackground(new Color(235,242,252));

b2.setForeground(Color.RED);

b3.setBackground(new Color(235,242,252));

b3.setForeground(Color.RED);

b4.setBackground(new Color(235,242,252));

b4.setForeground(Color.RED);

b5.setBackground(new Color(235,242,252));

b6.setBackground(new Color(235,242,252));

b7.setBackground(new Color(235,242,252));

b8.setBackground(new Color(235,242,252));

b9.setBackground(new Color(235,242,252));

b10.setBackground(new Color(235,242,252));

b10.setForeground(Color.RED);

b11.setBackground(new Color(235,242,252));

b11.setForeground(Color.RED);

b12.setBackground(new Color(235,242,252));

b12.setForeground(Color.RED);

b13.setBackground(new Color(235,242,252));

b13.setForeground(Color.RED);

b14.setBackground(new Color(235,242,252));

b14.setForeground(Color.RED);

b15.setBackground(new Color(235,242,252));

b16.setBackground(new Color(235,242,252));

b17.setBackground(new Color(235,242,252));

b18.setBackground(new Color(235,242,252));

b19.setBackground(new Color(235,242,252));

b20.setBackground(new Color(235,242,252));

b20.setForeground(Color.RED);

b21.setBackground(new Color(235,242,252));

b21.setForeground(Color.RED);

b22.setBackground(new Color(235,242,252));

b22.setForeground(Color.RED);

b23.setBackground(new Color(235,242,252));

b23.setForeground(Color.RED);

b24.setBackground(new Color(235,242,252));

b24.setForeground(Color.RED);

b25.setBackground(new Color(235,242,252));

b26.setBackground(new Color(235,242,252));

b27.setBackground(new Color(235,242,252));

b28.setBackground(new Color(235,242,252));

b29.setBackground(new Color(235,242,252));

b30.setBackground(new Color(235,242,252));

b30.setForeground(Color.RED);

b31.setBackground(new Color(235,242,252));

b31.setForeground(Color.RED);

b32.setBackground(new Color(235,242,252));

b32.setForeground(Color.RED);

b33.setBackground(new Color(235,242,252));

b33.setForeground(Color.RED);

b34.setBackground(new Color(235,242,252));

b34.setForeground(Color.RED);

b35.setBackground(new Color(235,242,252));

b36.setBackground(new Color(235,242,252));

b37.setBackground(new Color(235,242,252));

b38.setBackground(new Color(235,242,252));

b39.setBackground(new Color(235,242,252));

b40.setBackground(new Color(235,242,252));

b40.setForeground(Color.RED);

b41.setBackground(new Color(235,242,252));

b41.setForeground(Color.RED);

b42.setBackground(new Color(235,242,252));

b42.setForeground(Color.RED);

b43.setBackground(new Color(235,242,252));

b43.setForeground(Color.RED);

b44.setBackground(new Color(235,242,252));

b44.setForeground(Color.RED);

b45.setBackground(new Color(235,242,252));

b46.setBackground(new Color(235,242,252));

b47.setBackground(new Color(235,242,252));

b48.setBackground(new Color(235,242,252));

b49.setBackground(new Color(235,242,252));

b50.setBackground(new Color(235,242,252));

b51.setBackground(new Color(235,242,252));

b52.setBackground(new Color(235,242,252));

b53.setBackground(new Color(235,242,252));

b54.setBackground(new Color(235,242,252));

}

}

class CreateCal{

public static void main(String args[]){

Cal c=new Cal();

c.setVisible(true);

}

}




1 comments:

Anonymous said...

kollo ActionListeners liyala wada karana widihattama haduwa nam hodai neda????

Post a Comment

:a   :b   :c   :d   :e   :f   :g   :h   :i   :j   :k   :l   :m   :n   :o   :p   :q   :r   :s   :t

Related Posts with Thumbnails

ShoutMix chat widget
d