Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
AnasayfaAnasayfa  Latest imagesLatest images  Kayıt OlKayıt Ol  Giriş yapGiriş yap  

 

 Basit Telefon Defteri

Aşağa gitmek 
YazarMesaj
Apocalypse
Genelkurmay Başkanı
Genelkurmay Başkanı
Apocalypse


Erkek Mesaj Sayısı : 411
Yaş : 31
Nerden : Ms-Dos
Kayıt tarihi : 20/02/09

Basit Telefon Defteri Empty
MesajKonu: Basit Telefon Defteri   Basit Telefon Defteri EmptyPaz Şub. 22, 2009 2:48 am

--------------------------------------------------------------------------------

basit bir tel rehberi. kayıt ediyor,isim girilince girilen ismin telefonunu ekrana mesaj olark veriyor.
package tlf;

import java.io.*;
import java.util.StringTokenizer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* @author S33006
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class PhoneBook extends JFrame implements ActionListener{
FileWriter cikti;
JLabel lbl1;
JLabel lbl2;
JTextField txt1;
JTextField txt2;
JButton bt1;
JButton bt2;
JButton bt3;
Container c;
File f = new File("rehber.txt");
public static **** main(String[] args){

JFrame jf = new PhoneBook ();
jf.setVisible(true);
}
public PhoneBook (){
super("telefon rehberi");
c = getContentPane() ;


c.setLayout(new GridLayout(4,2));
this.setSize(new Dimension(257, 118));

lbl1 = new JLabel ("AD SOYAD: ");
c.add(lbl1);

txt1 = new JTextField (15);
c.add(txt1);

lbl2 = new JLabel ("TELEFON NO: ");
c.add(lbl2);

txt2 = new JTextField (15);
c.add(txt2);

bt1= new JButton("KAYDET");
bt1.addActionListener( this);
c.add(bt1);

bt2 = new JButton(" NO GOSTER");
bt2.addActionListener( this);
c.add(bt2);

bt3 = new JButton("TEMİZLE");
bt3.addActionListener( this);
c.add(bt3);

setVisible( true);

}


public **** actionPerformed(ActionEvent e){

if(e.getSource() == bt1){

try
{

cikti = new FileWriter("rehber.txt",true);
cikti.write(txt1.getText()+"\t"+txt2.getText());
cikti.write("\n");
cikti.close();



}catch(Exception ex) {

JOptionPane.showMessageDialog(null,"dosya doğru açılmadı" );

System.exit(1);
}

}
//ad soyad bolumune aranılan isim giriliyor, "NO GOSTER" tuşuna basınca mesaj olarak numara geliyor
else if(e.getSource() == bt2){
try {

InputStreamReader fis = new FileReader(f);
BufferedReader buf = new BufferedReader(fis);
String line = "";
boolean isFound = false;

while ( (line = buf.readLine()) != null) {

StringTokenizer token = new StringTokenizer(line,"\t");

if(token.nextToken().equals(txt1.getText())){
isFound = true;
JOptionPane.showMessageDialog(null,token.nextToken () );
break;
}
}
if(!isFound)
JOptionPane.showMessageDialog(null,"ARADIĞINIZ İSİMDE BİR KAYIT BULUNAMADI!" );

}
catch (Exception el) {

}
}else if(e.getSource() == bt3){



txt1.setText("");
txt2.setText("");


}
}
}
Sayfa başına dön Aşağa gitmek
 
Basit Telefon Defteri
Sayfa başına dön 
1 sayfadaki 1 sayfası
 Similar topics
-
» C / C++ da Basit Saat Yapımı
» 150 bin İstanbulluya Telefon Şoku
» Sanat Galerileri (adres ve telefon) (A-G)
» Sanat Galerileri (adres ve telefon) (H-Z)
» Telefon Şarjdayken Sakın Konuşma Yapmayın

Bu forumun müsaadesi var:Bu forumdaki mesajlara cevap veremezsiniz
 :: Programlama :: Java-
Buraya geçin:  
Copyright © Osmanlı Tim
Osmanlı Güvenlik || The Ottoman Security
Developed By CeMRe-eX || The Labrador
Yetkinforum.com | ©phpBB | Bedava yardımlaşma forumu | Suistimalı göstermek | Son tartışmalar