28 Şubat 2011, 00:05
|
#2 |
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
| Cevap: Java Hesap Makinesi
Kod: Kodu kopyalamak için üzerine çift tıklayın!
HESAP CLASS'I
import java.awt.Color;
import java.awt.Font;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
public class Hesap extends JFrame
{
private JLabel displayJLabel;
@SuppressWarnings({"unused","unused", "unused"})
public Hesap()
{
super( "HESAP MAKINEM" );
JMenu fileMenu = new JMenu( "MENU" );
fileMenu.setMnemonic( 'F' );
JMenuItem toplaItem = new JMenuItem( "TOPLAMA" );
toplaItem.setMnemonic( 'T' );
fileMenu.add( toplaItem );
toplaItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
Toplama can= new Toplama();
can.setSize( 250, 200 );
can.setVisible( true );
}
}
);
JMenuItem cikarmaItem = new JMenuItem("CIKARTMA");
cikarmaItem.setMnemonic('B');
fileMenu.add(cikarmaItem);
cikarmaItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
{
Cikartma can= new Cikartma();
can.setSize( 250, 200 );
can.setVisible( true );
}
}
}
);
JMenuItem carpItem = new JMenuItem("CARPMA");
carpItem.setMnemonic('C');
fileMenu.add(carpItem);
carpItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
{
Carpma can= new Carpma();
can.setSize( 250, 200 );
can.setVisible( true );
}
}
}
);
JMenuItem bolItem = new JMenuItem("BOLME");
bolItem.setMnemonic('D');
fileMenu.add(bolItem);
bolItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
{
Bolme can= new Bolme();
can.setSize( 250, 200 );
can.setVisible( true );
}
}
}
);
JMenuItem exitItem = new JMenuItem( "ÇIKIŞ" );
exitItem.setMnemonic( 'x' );
fileMenu.add( exitItem );
exitItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
System.exit( 0 );
}
}
);
displayJLabel = new JLabel( "HESAP MAKİNEM(CAN EROL)", SwingConstants.CENTER );
displayJLabel.setFont( new Font( "Serif", Font.PLAIN,45) );
getContentPane().setBackground( Color.ORANGE );
add( displayJLabel, BorderLayout.CENTER );
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
bar.add( fileMenu );
}
public static void main( String args[] )
{
Hesap Can= new Hesap();
Can.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Can.setSize( 650, 175 );
Can.setVisible( true );
}
}
TOPLA CLASS'I
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.*;
public class Toplama extends JFrame
{
private TextField A;
private TextField B;
private TextField C;
private Label ilk;
private Label iki;
private Label uc;
private Button Topla;
@SuppressWarnings({"unused","unused", "unused"})
public Toplama()
{
super( "TOPLAMA ISLEMI" );
setLayout(new FlowLayout());
ilk = new Label("ILK SAYI ");
add(ilk);
A = new TextField(15);
add(A);
iki = new Label("IKINCI SAYI");
add(iki);
B = new TextField(15);
add(B);
uc = new Label("ESITTIR ");
add(uc);
C = new TextField(15);
add(C);
Topla = new Button("TOPLA");
add(Topla);
Topla.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
float x = Integer.parseInt(A.getText());
float y = Integer.parseInt(B.getText());
float esittir = x+y;
C.setText(String.valueOf(esittir));
}
}
);
JMenu fileMenu = new JMenu( "MENU" );
fileMenu.setMnemonic( 'F' );
JMenuItem exitItem = new JMenuItem( "ÇIKIŞ" );
exitItem.setMnemonic( 'x' );
fileMenu.add( exitItem );
exitItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
System.exit( 0 );
}
}
);
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
bar.add( fileMenu );
}
public static void main( String args[] )
{
Toplama can= new Toplama();
can.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
can.setSize( 250, 200 );
can.setVisible( true );
}
}
CIKARTMA CLASS'I
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.*;
public class Cikartma extends JFrame
{
private TextField A;
private TextField B;
private TextField C;
private Label ilk;
private Label iki;
private Label uc;
private Button cikartma;
@SuppressWarnings({"unused","unused", "unused"})
public Cikartma()
{
super( "CIKARTMA ISLEMI" );
setLayout(new FlowLayout());
ilk = new Label("ILK SAYI ");
add(ilk);
A = new TextField(15);
add(A);
iki = new Label("IKINCI SAYI");
add(iki);
B = new TextField(15);
add(B);
uc = new Label("ESITTIR ");
add(uc);
C = new TextField(15);
add(C);
cikartma = new Button("CIKART");
add(cikartma);
cikartma.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
float x = Integer.parseInt(A.getText());
float y = Integer.parseInt(B.getText());
float esittir = x-y;
C.setText(String.valueOf(esittir));
}
}
);
JMenu fileMenu = new JMenu( "MENU" );
fileMenu.setMnemonic( 'F' );
JMenuItem exitItem = new JMenuItem( "ÇIKIŞ" );
exitItem.setMnemonic( 'x' );
fileMenu.add( exitItem );
exitItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
System.exit( 0 );
}
}
);
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
bar.add( fileMenu );
}
public static void main( String args[] )
{
Cikartma can= new Cikartma();
can.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
can.setSize( 250, 200 );
can.setVisible( true );
}
}
CARPMA CLASS' I
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.*;
public class Carpma extends JFrame
{
private TextField A;
private TextField B;
private TextField C;
private Label ilk;
private Label iki;
private Label uc;
private Button carpma;
@SuppressWarnings({"unused","unused", "unused"})
public Carpma()
{
super( "CARPMA ISLEMI" );
setLayout(new FlowLayout());
ilk = new Label("ILK SAYI ");
add(ilk);
A = new TextField(15);
add(A);
iki = new Label("IKINCI SAYI");
add(iki);
B = new TextField(15);
add(B);
uc = new Label("ESITTIR ");
add(uc);
C = new TextField(15);
add(C);
carpma = new Button("CARP");
add(carpma);
carpma.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
float x = Integer.parseInt(A.getText());
float y = Integer.parseInt(B.getText());
float esittir = x*y;
C.setText(String.valueOf(esittir));
}
}
);
JMenu fileMenu = new JMenu( "MENU" );
fileMenu.setMnemonic( 'F' );
JMenuItem exitItem = new JMenuItem( "ÇIKIŞ" );
exitItem.setMnemonic( 'x' );
fileMenu.add( exitItem );
exitItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
System.exit( 0 );
}
}
);
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
bar.add( fileMenu );
}
public static void main( String args[] )
{
Carpma can= new Carpma();
can.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
can.setSize( 250, 200 );
can.setVisible( true );
}
}
BOLME
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.*;
public class Bolme extends JFrame
{
private TextField A;
private TextField B;
private TextField C;
private Label ilk;
private Label iki;
private Label uc;
private Button bol;
@SuppressWarnings({"unused","unused", "unused"})
public Bolme()
{
super( "BOLME ISLEMI" );
setLayout(new FlowLayout());
ilk = new Label("ILK SAYI ");
add(ilk);
A = new TextField(15);
add(A);
iki = new Label("IKINCI SAYI");
add(iki);
B = new TextField(15);
add(B);
uc = new Label("ESITTIR ");
add(uc);
C = new TextField(15);
add(C);
bol = new Button("BOL");
add(bol);
bol.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
float x = Integer.parseInt(A.getText());
float y = Integer.parseInt(B.getText());
float esittir = x/y;
C.setText(String.valueOf(esittir));
}
}
);
JMenu fileMenu = new JMenu( "MENU" );
fileMenu.setMnemonic( 'F' );
JMenuItem exitItem = new JMenuItem( "ÇIKIŞ" );
exitItem.setMnemonic( 'x' );
fileMenu.add( exitItem );
exitItem.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
System.exit( 0 );
}
}
);
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
bar.add( fileMenu );
}
public static void main( String args[] )
{
Bolme can= new Bolme();
can.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
can.setSize( 250, 200 );
can.setVisible( true );
}
}
Alıntı ama umarım işini görür. |
| |