Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
Graphical Calculator - JAVA

Graphical Calculator - JAVA

Ratings: (0)|Views: 237|Likes:

More info:

Published by: Muhammad Rana Farhan on Feb 11, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/13/2011

pdf

text

original

 
Calculator
============================================/* ================== API's ================= */import javax.swing.*;import java.awt.*;import java.awt.event.*;/* ==============CALCULATOR CLASS ============= */class Calculator implements ActionListener{//CONSTRUCTOR public Calculator(){f=new JFrame("Calculator");f.setSize(350,350);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setResizable(false);JMenuBar menu=new JMenuBar();f.setJMenuBar(menu);JMenu edit=new JMenu("Edit");menu.add(edit);JMenuItem copy=new JMenuItem("Copy Ctrl+C");edit.add(copy);JMenuItem paste=new JMenuItem("Paste Ctrl+V");edit.add(paste);JMenu view=new JMenu("View");menu.add(view);JMenuItem std=new JMenuItem("Standard");view.add(std);JMenuItem sci=new JMenuItem("Scientific");view.add(sci);JMenuItem dg=new JMenuItem("Digit Grouping");view.add(dg);JMenu help=new JMenu("Help");menu.add(help);JMenuItem ht=new JMenuItem("Help Topics");help.add(ht);
 
JMenuItem cal=new JMenuItem("About Calculator");help.add(cal);//BORDER LAYOUTf.setLayout(new BorderLayout(5,5));p1=new JPanel();bl= new BorderLayout();p1.setLayout(bl);//GRID LAYOUT ON WESTp2=new JPanel();p2.setLayout(new GridLayout(4,1));UIManager.put("Button.background", Color.BITMASK);UIManager.put("Button.foreground", Color.red);JButton b[]=new JButton[27];b1=new JButton("MC");b2=new JButton("MR");b3=new JButton("MS");b4=new JButton("M+");p2.add(b1);p2.add(b2);p2.add(b3);p2.add(b4);f.add(p2,BorderLayout.WEST);//GRID LAYOUT ON EASTp3=new JPanel();p3.setLayout(new GridLayout(4,1));UIManager.put("Button.foreground", Color.blue);b5=new JButton("sqrt");b6=new JButton("%");b7=new JButton("1/x");UIManager.put("Button.foreground", Color.red);b8=new JButton("=");p3.add(b5);p3.add(b6);p3.add(b7);p3.add(b8);f.add(p3,BorderLayout.EAST);//GRID LAYOUT ON NORTHp4=new JPanel();
 
p4.setLayout(new GridLayout(1,3));b9=new JButton("Backspace");b10=new JButton("C");b11=new JButton("CE");tf1=new JTextField(26);tf1.setHorizontalAlignment(JTextField.RIGHT);p4.add(tf1);p4.add(b9);p4.add(b10);p4.add(b11);p1.add(p4,BorderLayout.CENTER);p1.add(tf1,BorderLayout.NORTH);f.add(p1,BorderLayout.NORTH);//GRID LAYOUT ON CENTER p5=new JPanel();p5.setLayout(new GridLayout(4,4));UIManager.put("Button.foreground", Color.blue);b12=new JButton("7");b13=new JButton("8");b14=new JButton("9");b16=new JButton("4");b17=new JButton("5");b18=new JButton("6");b20=new JButton("1");b21=new JButton("2");b22=new JButton("3");b24=new JButton("0");b25=new JButton("+/-");b26=new JButton(".");UIManager.put("Button.foreground", Color.red);b15=new JButton("/");b27=new JButton("+");b23=new JButton("-");b19=new JButton("*");p5.add(b12);p5.add(b13);p5.add(b14);p5.add(b15);p5.add(b16);p5.add(b17);p5.add(b18);p5.add(b19);

Activity (4)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Walid_Sassi_Tun liked this
zubair.arshad liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->