NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import java.awt.Component;
import javax.swing.*;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class MainClass {

private static final Component Selam = null;


public MainClass() {
JFrame frame = new JFrame("Hesap Makinesi");
frame.setVisible(true);
frame.setSize(300, 350);
frame.setLayout(null);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);

JMenuBar menu = new JMenuBar();
JMenuItem ss = new JMenuItem();

frame.setJMenuBar(menu);
JMenu yardim = new JMenu("Yardım");
menu.add(yardim);
JMenu hakkinda = new JMenu("Hakkında");
menu.add(hakkinda);

hakkinda.addMouseListener(new MouseAdapter() {

public void mousePressed(MouseEvent e) {

JOptionPane.showMessageDialog(null, "BU BASİT BİR HESAP MAKİNESİDİR.");

}


});


yardim.addMouseListener(new MouseAdapter() {

public void mousePressed(MouseEvent e) {

JOptionPane.showMessageDialog(null, "YAPMAK İSTEDİĞİNİZ İŞLEMİ SEÇİP ='E TIKLAYINIZ.");

}


});





bilesenler(frame.getContentPane());

}


private void bilesenler(Container contentPane) {

JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JLabel label1 = new JLabel("0");
JTextField tf = new JTextField(20);

JButton btn0 = new JButton("0");
JButton btn1 = new JButton("1");
JButton btn2 = new JButton("2");
JButton btn3 = new JButton("3");
JButton btn4 = new JButton("4");
JButton btn5 = new JButton("5");
JButton btn6 = new JButton("6");
JButton btn7 = new JButton("7");
JButton btn8 = new JButton("8");
JButton btn9 = new JButton("9");
JButton btn10 = new JButton("+");
JButton btn11 = new JButton("-");
JButton btn12 = new JButton("/");
JButton btn13 = new JButton("*");
JButton btn14 = new JButton("=");
JButton btn15 = new JButton("C");


tf.setEditable(false);

panel1.setBounds(0,0,240,60);
panel2.setBounds(0,60,350,350);
panel1.setLayout(null);
panel2.setLayout(null);




label1.setBounds(135, 0, 50, 50);
tf.setBounds(65, 40,150, 20);


//ilk sıra
btn7.setBounds(40, 20, 42, 42);
btn8.setBounds(90,20,42,42);
btn9.setBounds(140,20,42,42);
btn10.setBounds(190,20,42,42);

//ikinci sıra
btn4.setBounds(40, 65, 42, 42);
btn5.setBounds(90,65,42,42);
btn6.setBounds(140,65,42,42);
btn11.setBounds(190,65,42,42);

//ücüncü sıra
btn1.setBounds(40, 110, 42, 42);
btn2.setBounds(90,110,42,42);
btn3.setBounds(140,110,42,42);
btn12.setBounds(190,110,42,42);

//dördüncü sıra
btn0.setBounds(40, 155, 42, 42);
btn15.setBounds(90,155,42,42);
btn14.setBounds(140,155,42,42);
btn13.setBounds(190,155,42,42);




btn7.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"7");

}

});



btn8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"8");

}

});


btn9.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"9");

}

});


btn4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"4");

}

});


btn5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"5");

}

});

btn6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"6");

}

});

btn1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"1");

}

});

btn2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"2");

}

});

btn3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"3");

}

});


btn0.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String temp = tf.getText();
tf.setText(temp +"0");

}

});




double sonuc = 0;

if(btn10.isSelected() || btn11.isSelected() || btn12.isSelected() || btn13.isSelected() ) {

Double sayi1 = Double.parseDouble(tf.getText());
sonuc = sonuc+sayi1;
tf.setText(" ");
System.out.println(sonuc);

}



panel2.add(btn7);
panel2.add(btn8);
panel2.add(btn9);
panel2.add(btn10);
panel2.add(btn4);
panel2.add(btn5);
panel2.add(btn6);
panel2.add(btn11);
panel2.add(btn1);
panel2.add(btn2);
panel2.add(btn3);
panel2.add(btn12);
panel2.add(btn0);
panel2.add(btn15);
panel2.add(btn14);
panel2.add(btn13);


panel1.add(label1);
panel1.add(tf);

contentPane.add(panel1);
contentPane.add(panel2);
}


public double hesapla() {



return 0;
}





public static void main(String[] args) {
// TODO Auto-generated method stub

new MainClass();


}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.