NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Main {

public String sonuc;


public Main() {
JFrame j1 = new JFrame("Hesap Makinası"); // CTRL SHIFT O
j1.setSize(400,400);
bilesenleriEkle(j1.getContentPane());
j1.setVisible(true);
j1.setDefaultCloseOperation(j1.EXIT_ON_CLOSE);
}

public void bilesenleriEkle(Container contentPane) {
JPanel p1 = new JPanel();
p1.setLayout(null);

JTextField jt = new JTextField();
jt.setBounds(40,50,225,25);
JButton b7 = new JButton("7");
b7.setBounds(40, 100, 45, 45);
b7.addActionListener(new ActionListener() {

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

}
});

JButton b8 = new JButton("8");
b8.setBounds(100, 100, 45, 45);
b8.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"8");

}
});
JButton b9 = new JButton("9");
b9.setBounds(160, 100, 45, 45);
b9.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"9");

}
});
JButton arti = new JButton("+");
arti.setBounds(220, 100, 45, 45);
arti.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"+");

}
});
JButton b4 = new JButton("4");
b4.setBounds(40, 160, 45, 45);
b4.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"4");

}
});
JButton b5 = new JButton("5");
b5.setBounds(100, 160, 45, 45);
b5.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"5");

}
});

JButton b6 = new JButton("6");
b6.setBounds(160, 160, 45, 45);
b6.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"6");

}
});

JButton eksi = new JButton("-");
eksi.setBounds(220, 160, 45, 45);
eksi.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"-");

}
});
JButton b1 = new JButton("1");
b1.setBounds(40, 220, 45, 45);
b1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"1");

}
});
JButton b2 = new JButton("2");
b2.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"2");
}
});
b2.setBounds(100, 220, 45, 45);
JButton b3 = new JButton("3");
b3.setBounds(160, 220, 45, 45);
b3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"3");
}
});
JButton bolum = new JButton("/");
bolum.setBounds(220, 220, 45, 45);
bolum.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"/");
}
});
JButton b0 = new JButton("0");
b0.setBounds(40, 280, 45, 45);
b0.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"0");

}
});
JButton c = new JButton("C");
c.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
jt.setText(null);

}
});
c.setBounds(100, 280, 45, 45);
JButton esittir = new JButton("=");
esittir.setBounds(160, 280, 45, 45);
esittir.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {

sonuc = jt.getText();
//Integer temp = Integer.parseInt(sonuc);
Double blabla = Double.parseDouble(sonuc);
System.out.println(blabla+10);


}
});

JButton carpim = new JButton("*");
carpim.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
String temp = jt.getText();
jt.setText(temp +"*");

}
});
carpim.setBounds(220, 280, 45, 45);

p1.add(jt);
p1.add(b7);
p1.add(b8);
p1.add(b9);
p1.add(arti);
p1.add(b4);
p1.add(b5);
p1.add(b6);
p1.add(eksi);
p1.add(b1);
p1.add(b2);
p1.add(b3);
p1.add(bolum);
p1.add(b0);
p1.add(c);
p1.add(esittir);
p1.add(carpim);







p1.add(b9);



contentPane.add(p1);
}

public static void main(String[] args) {
new Main();
}

}
     
 
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.