NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package furkan;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class App1 extends JFrame{
int sayi;
int sonuc=0;
int isaretci=0;
public App1(){

//super("Flow Layout Ornek");
//Container com = null;
//Ekle(com);
//this.setVisible(true);
this.setTitle("Flow Layout Ornek");
this.setSize(300,200);
this.setLayout(new FlowLayout());
Ekle(this.getContentPane());
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
private void Ekle(Container contentPane){
//contentPane.setLayout(new GridLayout(4,4));
JPanel butonPanel=new JPanel(new GridLayout(4,4));
JPanel ustPanel=new JPanel();
JButton num7=new JButton("7");
JButton num8=new JButton("8");
JButton num9=new JButton("9");
JButton numArti=new JButton("+");
JButton num4=new JButton("4");
JButton num5=new JButton("5");
JButton num6=new JButton("6");
JButton numEksi=new JButton("-");
JButton num1=new JButton("1");
JButton num2=new JButton("2");
JButton num3=new JButton("3");
JButton numCarp=new JButton("*");
JButton num0=new JButton("0");
JButton numClear=new JButton("Clear");
JButton numEsittir=new JButton("=");
JButton numBol=new JButton("/");
JTextField textField=new JTextField(20);
JLabel label=new JLabel("*****");

ustPanel.add(label);
ustPanel.add(textField);

num7.setBackground(Color.BLACK);
num7.setForeground(Color.WHITE);
butonPanel.add(num7);
num7.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"7");

}
});
num8.setBackground(Color.BLACK);
num8.setForeground(Color.WHITE);
butonPanel.add(num8);
num8.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"8");
}
});
num9.setBackground(Color.BLACK);
num9.setForeground(Color.WHITE);
butonPanel.add(num9);
num9.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"9");
}
});
numArti.setBackground(Color.BLACK);
numArti.setForeground(Color.WHITE);
butonPanel.add(numArti);
numArti.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
sonuc=Integer.parseInt(textField.getText());
isaretci=1;
textField.setText(null);
//int toplam=0;
//sayi=Integer.parseInt(textField.getText());
//textField.setText("+");
//textField.setText(null);
//toplam=sayi+toplam;
//sonuc=(String.valueOf(toplam));



}
});
num4.setBackground(Color.BLACK);
num4.setForeground(Color.WHITE);
butonPanel.add(num4);
num4.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"4");
}
});
num5.setBackground(Color.BLACK);
num5.setForeground(Color.WHITE);
butonPanel.add(num5);
num5.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"5");
}
});
num6.setBackground(Color.BLACK);
num6.setForeground(Color.WHITE);
butonPanel.add(num6);
num6.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"6");
}
});
numEksi.setBackground(Color.BLACK);
numEksi.setForeground(Color.WHITE);
butonPanel.add(numEksi);
numEksi.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText("-");
}
});
num1.setBackground(Color.BLACK);
num1.setForeground(Color.WHITE);
butonPanel.add(num1);
num1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"1");
}
});
num2.setBackground(Color.BLACK);
num2.setForeground(Color.WHITE);
butonPanel.add(num2);
num2.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"2");
}
});
num3.setBackground(Color.BLACK);
num3.setForeground(Color.WHITE);
butonPanel.add(num3);
num3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"3");
}
});
numCarp.setBackground(Color.BLACK);
numCarp.setForeground(Color.WHITE);
butonPanel.add(numCarp);
numCarp.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText("*");
}
});
num0.setBackground(Color.BLACK);
num0.setForeground(Color.WHITE);
butonPanel.add(num0);
num0.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(textField.getText()+"0");
}
});
numClear.setBackground(Color.BLACK);
numClear.setForeground(Color.WHITE);
butonPanel.add(numClear);
numClear.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText(" ");
isaretci=0;
sonuc=0;
}
});
numEsittir.setBackground(Color.BLACK);
numEsittir.setForeground(Color.WHITE);
butonPanel.add(numEsittir);
numEsittir.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(isaretci==1){
sayi=Integer.parseInt(textField.getText());
sonuc=sayi+sonuc;
textField.setText(String.valueOf(sonuc));
}
}
});
numBol.setBackground(Color.BLACK);
numBol.setForeground(Color.WHITE);
butonPanel.add(numBol);
numBol.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
textField.setText("/");
}
});


contentPane.add(ustPanel);
contentPane.add(butonPanel);
/*add(new Button("üst"), BorderLayout.PAGE_START);
add(new Button("sol"), BorderLayout.LINE_START);
add(new Button("orta"), BorderLayout.CENTER);
add(new Button("sağ"), BorderLayout.LINE_END);
add(new Button("alt"), BorderLayout.PAGE_END);*/
}

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

}

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