///Md. Alamgir Hossain
////Dept. of Computer Science & Engineering
///Jessore University of Scoence & Technology
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;
import javax.swing.border.BevelBorder;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URL;
public class Main_Frame extends JFrame {
private JPanel contentPane;
private JTextField txtdisplay;
/**
* Launch the application.
*/
double firstnum;
double secondnum;
double res;
String operation;
String ans;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Main_Frame frame = new Main_Frame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Main_Frame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
setLocationRelativeTo(null);
setBounds(100, 100, 231, 282);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
txtdisplay = new JTextField();
txtdisplay.setFont(new Font("Monotype Corsiva", Font.PLAIN, 15));
txtdisplay.setHorizontalAlignment(SwingConstants.RIGHT);
txtdisplay.setBounds(10, 11, 210, 29);
contentPane.add(txtdisplay);
txtdisplay.setColumns(10);
JButton btnNewButton = new JButton("C");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtdisplay.setText("");
}
});
btnNewButton.setBounds(10, 62, 45, 23);
contentPane.add(btnNewButton);
final JButton btn7 = new JButton("7");
btn7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String your_enter_num = txtdisplay.getText() + btn7.getText();
txtdisplay.setText(your_enter_num);
}
});
btn7.setBounds(10, 94, 45, 23);
contentPane.add(btn7);
final JButton btn8 = new JButton("8");
btn8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String your_enter_num = txtdisplay.getText() + btn8.getText();
txtdisplay.setText(your_enter_num);
}
});
btn8.setBounds(65, 94, 45, 23);
contentPane.add(btn8);
final JButton btn9 = new JButton("9");
btn9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn9.getText();
txtdisplay.setText(your_enter_num);
}
});
btn9.setBounds(120, 94, 45, 23);
contentPane.add(btn9);
JButton button_3 = new JButton("*");
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(txtdisplay.getText());
txtdisplay.setText("");
operation = "*";
}
});
button_3.setBounds(175, 94, 45, 23);
contentPane.add(button_3);
final JButton btn4 = new JButton("4");
btn4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn4.getText();
txtdisplay.setText(your_enter_num);
}
});
btn4.setBounds(10, 128, 45, 23);
contentPane.add(btn4);
final JButton btn5 = new JButton("5");
btn5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn5.getText();
txtdisplay.setText(your_enter_num);
}
});
btn5.setBounds(65, 128, 45, 23);
contentPane.add(btn5);
final JButton btn6 = new JButton("6");
btn6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn6.getText();
txtdisplay.setText(your_enter_num);
}
});
btn6.setBounds(120, 128, 45, 23);
contentPane.add(btn6);
JButton button_7 = new JButton("-");
button_7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(txtdisplay.getText());
txtdisplay.setText("");
operation = "-";
}
});
button_7.setBounds(175, 128, 45, 23);
contentPane.add(button_7);
final JButton btn1 = new JButton("1");
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn1.getText();
txtdisplay.setText(your_enter_num);
}
});
btn1.setBounds(10, 160, 45, 23);
contentPane.add(btn1);
final JButton btn2 = new JButton("2");
btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn2.getText();
txtdisplay.setText(your_enter_num);
}
});
btn2.setBounds(65, 162, 45, 23);
contentPane.add(btn2);
final JButton btn3 = new JButton("3");
btn3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn3.getText();
txtdisplay.setText(your_enter_num);
}
});
btn3.setBounds(120, 162, 45, 23);
contentPane.add(btn3);
JButton button_11 = new JButton("+");
button_11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(txtdisplay.getText());
txtdisplay.setText("");
operation = "+";
}
});
button_11.setBounds(175, 162, 45, 23);
contentPane.add(button_11);
final JButton btn0 = new JButton("0");
btn0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btn0.getText();
txtdisplay.setText(your_enter_num);
}
});
btn0.setBounds(10, 194, 45, 23);
contentPane.add(btn0);
final JButton btnp = new JButton(".");
btnp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String your_enter_num = txtdisplay.getText() + btnp.getText();
txtdisplay.setText(your_enter_num);
}
});
btnp.setFont(new Font("Times New Roman", Font.PLAIN, 12));
btnp.setBounds(65, 194, 45, 23);
contentPane.add(btnp);
JButton button_14 = new JButton("+/-");
button_14.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double x= Double.parseDouble(String.valueOf(txtdisplay.getText()));
x = x * (-1);
txtdisplay.setText(String.valueOf(x));
}
});
button_14.setFont(new Font("Tahoma", Font.PLAIN, 8));
button_14.setBounds(120, 196, 45, 23);
contentPane.add(button_14);
JButton button_15 = new JButton("=");
button_15.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
secondnum = Double.parseDouble(txtdisplay.getText());
if(operation == "+")
{
res = firstnum + secondnum;
ans = String.format("%.0f", res);
txtdisplay.setText(ans);
}
else if(operation == "-")
{
res = firstnum - secondnum;
ans = String.format("%.0f", res);
txtdisplay.setText(ans);
}
else if(operation == "*")
{
res = firstnum * secondnum;
ans = String.format("%.0f", res);
txtdisplay.setText(ans);
}
else if(operation == "/")
{
res = firstnum / secondnum;
ans = String.format("%.0f", res);
txtdisplay.setText(ans);
}
else if(operation == "%")
{
res = firstnum % secondnum;
ans = String.format("%.0f", res);
txtdisplay.setText(ans);
}
}
});
button_15.setBounds(175, 196, 45, 23);
contentPane.add(button_15);
JButton button_16 = new JButton("%");
button_16.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(txtdisplay.getText());
txtdisplay.setText("");
operation = "%";
}
});
button_16.setBounds(65, 62, 45, 23);
contentPane.add(button_16);
JButton btnBk = new JButton("B");
btnBk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String back = null;
if(txtdisplay.getText().length()>0)
{
StringBuilder strbldr = new StringBuilder(txtdisplay.getText());
strbldr.deleteCharAt(txtdisplay.getText().length()-1);
back = strbldr.toString();
txtdisplay.setText(back);
}
}
});
btnBk.setBounds(120, 62, 45, 23);
contentPane.add(btnBk);
JButton button_18 = new JButton("/");
button_18.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(txtdisplay.getText());
txtdisplay.setText("");
operation = "/";
}
});
button_18.setBounds(175, 62, 45, 23);
contentPane.add(button_18);
JPanel panel = new JPanel();
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
try {
String url ="http://alamgir-hossain.simplesite.com/";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, new Color(102, 0, 0)));
panel.setBounds(46, 225, 145, 25);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblDesignBy = new JLabel("Design by ");
lblDesignBy.setFont(new Font("Monotype Corsiva", Font.BOLD, 15));
lblDesignBy.setBounds(6, 3, 133, 20);
panel.add(lblDesignBy);
lblDesignBy.setHorizontalAlignment(SwingConstants.CENTER);
}
}
Click any Bellow Tabs/Tags
Alamgir-Hossain
(14)
Algorithms
(5)
Android problem
(2)
ANN
(1)
ArticleWriting
(26)
Artificial Intelligence
(1)
Assembly
(1)
Bangla Love Poem
(3)
Bangla Poem
(2)
best programming solution
(9)
Books
(2)
BUET IICT MSC Admission
-2021
(1)
C
(49)
Campus
(7)
CPP
(88)
Database
(4)
Differences
(2)
Fishing
(1)
HSC
(1)
Html
(4)
interesting programming solution
(9)
Interview
(2)
It job preparation
(7)
JAVA
(97)
JavaScript
(5)
JSON
(1)
lead generation
(1)
machine learning
(2)
ML Projects
(3)
NewsPaper
(19)
Others
(13)
Perl
(23)
Php
(4)
Poem
(4)
Presentation
(1)
ProblemSolving
(3)
Project
(21)
Prolog
(13)
Python
(33)
research
(18)
Research Tool
(1)
Security
(3)
Social Engineering
(1)
Testimonials
(5)
Tutorial
(2)
Writings
(15)
XML
(1)
YoutubeSEO
(1)
উক্তি
(1)
কবিতা-আলগীর হোসেন
(2)
লেখনী
(33)
LATEST
3-latest-65px
Popular Posts
-
All instructions for connection & insert data in mysql from java JSP and Servlet using tomcat serverFrom this tutorial you can learn about... All instructions for connection & insert data in mysql from java JSP and Servlet using tomc...
-
% Prolog program for addition and multplication-------- % Alamgir Hossain % CSE, JUST go :- write ( 'Enter first number : ' ...
-
Inverse Lagrange’s Interpolation Formula Theory : . Example : 1. Use Lagrange’s inverse interpolation fo...
-
Project Name : Online examination system. Framework : MVC framework in java(3 layer architecture). Language: JAVA JSP, SERVLET, JS...
-
Here is the source code for online exam system using PHP, MYSQL,AJAX, JAVASCRIPT etc.... Source code for Online Exam System
No comments:
Post a Comment