import java.text.DecimalFormat; import javax.swing.*; import javax.swing.border.Border; import java.awt.event.*; import java.awt.*; /* * Written By : Ahmad Jawed ZAFAR *Date : 20/02/2009 * */ public class JavaScientificCalculator extends JFrame { private JTextField text1, text2, textSc; private JPanel panel, panel2, panelScButtons, panelScVal, panelResult; private String BNames[] = {"+","-","*","÷","%","Power"}; private String BNames2[] = {"Sin","Cos","Tan","Log10","Loge","To Rad","To Deg","Root","!"}; private JButton buttons[], buttons2[]; private JLabel label1, labelSc, labelN1, labelN2, labelResult; public JavaScientificCalculator() // constructor { super("Java Scientific Calculator"); Container container = getContentPane(); container.setBackground(Color.ORANGE); container.setLayout(new FlowLayout()); Action handler = new Action(); text1 = new JTextField(14); text2 = new JTextField(14); labelResult = new JLabel("Result : "); labelResult.setForeground(Color.blue); labelN1 = new JLabel("Value 1 : "); labelN2 = new JLabel("Value 2 : "); labelSc = new JLabel("Value For Scintific Calculations : "); textSc = new JTextField(20); panelScVal = new JPanel(); panelResult = new JPanel(); panelResult.setBackground(Color.yellow); panelResult.add(labelResult); panel = new JPanel(); panel.setLayout(new GridLayout(1, BNames.length)); panel2 = new JPanel(); panel2.setLayout(new GridLayout(1, 6)); panelScButtons = new JPanel(); panelScButtons.setLayout(new GridLayout(1, BNames2.length)); buttons = new JButton[6]; buttons2 = new JButton[11]; panel.setBackground(Color.blue); for (int i=0; i=1; i--) { result = result * i; } labelResult.setText("Result Is : " + result); } } catch (NumberFormatException n) { JOptionPane.showMessageDialog(null, "You Must Enter Integers", "Error", JOptionPane.ERROR_MESSAGE); } } } }