Professional Documents
Culture Documents
Untitled
Untitled
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(l3);
b1.addActionListener(this);
setVisible(true);
setSize(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e)
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int sum=n1+n2;
l3.setText("Sum of two integers are "+sum);
}
}
SACHIN PUNDIR ROLL NO:- 29 MCA III B
b1=new JButton("ADD");
b2=new JButton("SUB");
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
add(l3);
b1.addActionListener(this);
b2.addActionListener(this);
setVisible(true);
setSize(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e)
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int res;
if(e.getSource()==b1)
{
res=n1+n2;
l3.setText("Result of two integers are "+res);
}
else
{
res=n1-n2;
l3.setText("Result of two integers are "+res);
}
SACHIN PUNDIR ROLL NO:- 29 MCA III B
}
SACHIN PUNDIR ROLL NO:- 29 MCA III B
b1=new JButton("ADD");
b2=new JButton("SUB");
b3=new JButton("MUL");
b4=new JButton("DIV");
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
add(b3);
add(b4);
add(l3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
setVisible(true);
setSize(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e)
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int res;
if(e.getSource()==b1)
{
res=n1+n2;
l3.setText("Addition of two integers are "+res);
}
SACHIN PUNDIR ROLL NO:- 29 MCA III B
else if(e.getSource()==b2)
{
res=n1-n2;
l3.setText("Subtraction of two integers are "+res);
}
else if(e.getSource()==b3)
{
res=n1*n2;
l3.setText("Multiplication of two integers are "+res);
}
else
{
res=n1/n2;
l3.setText("Divison of two integers are "+res);
}
}