Posts

Showing posts from June 15, 2014

Calculator in java swing applet

import java.io.*;
import java.lang.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import calculate.calc;
public class cal implements ActionListener
{
JFrame jf;
JToolBar jtb;
JButton jbadd,jbsub,jbmul,jbdiv,jbclear,jbequal;
JTextField jtf;
calc ca2=new calc();
int val;

int flag=0;
cal()
{
frame();
toolbar();
textfield();
button();

jf.setVisible(true);


}
void frame()
{

jf=new JFrame("calculator");
jf.setSize(500,500);
jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);

}
void toolbar()
{
jtb=new JToolBar();
jf.add(jtb,BorderLayout.NORTH);
}
void textfield()
{
jtf=new JTextField();
jtb.add(jtf);

jtf.addMouseListener(new MouseAdapter(){
                 public void mouseClicked(MouseEvent e){
                jtf.setText("");
            }
        });



}
void button()
{
jbadd=new JButton("+");
jbsub=new JButton("-");
jbmul=new JButton("*");
jbdiv=new JButton("/");
jbclear=new JButton(&…