Ders programı uygulaması indir

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener,ItemListener {
	 DefaultListModel<String>[] dlm;
     JList<String>[] jlist;
     String[] lbl= {"Ders","Hoca","Gün","Saat","Teorik","Uygulama"};
     JComboBox<String> jcb;
     JComboBox<Integer> jcb_id;
     JComboBox<Integer> jcb_orgun;
	public Calistir()  {
		this.setTitle("Ders Programı");
		this.setSize(700,450);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLayout(new FlowLayout());
		
		String[] btn_txt={"Ders","Hoca","Eşleştirme"};
		JPanel jpn_main=new JPanel();
		jpn_main.setPreferredSize(new Dimension(700, 450));
		
		dlm=new DefaultListModel[lbl.length];
		jlist=new JList[dlm.length];
		
		
		for(int i=0;i<dlm.length;i++) {
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100, 400));
			
			JLabel jlb=new JLabel(lbl[i]);
			jlb.setPreferredSize(new Dimension(100,25));
			
			dlm[i]=new DefaultListModel<String>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane jscp=new JScrollPane(jlist[i]);
		    jscp.setPreferredSize(new Dimension(100, 300));
		    
		    jpn.add(jlb);
		    jpn.add(jscp);
		  
		    jpn_main.add(jpn);
		    if(i!=0&&(i-1)<btn_txt.length){
		    	JButton btn=new JButton(btn_txt[i-1]);
		    	btn.setPreferredSize(new Dimension(100,25));
		    	btn.addActionListener(this);
		    	btn.setActionCommand(btn_txt[i-1]);	
		    	jpn.add(btn);
		    }
		    if(i==0) {
		       jcb=new JComboBox<String>();
		       jcb.setSelectedIndex(-1);
		       jcb.setPreferredSize(new Dimension(100, 25));
		       jcb.addItemListener(this);
		       jcb_id=new JComboBox<Integer>(); 
		       jcb_orgun=new JComboBox<Integer>();
		       jpn.add(jcb);   
		    }
		}
		combodoldur();
		if(jcb_id.getItemCount()==0)
		listdoldur(0,0);
		else
		listdoldur(jcb_id.getItemAt(0),jcb_orgun.getItemAt(0));
		this.add(jpn_main);
	   this.setVisible(true);
	}
	@Override
	public void actionPerformed(ActionEvent arg0) {
	
		switch(arg0.getActionCommand()) {
		
		case "Ders":new Ders(this);break;
		case "Hoca":new Hoca(this);break;
		case "Eşleştirme":new Eslestirme(this);break;
		}
	}
 public static void main(String[] arg) {
	 
	 new Calistir();
 }
@Override
public void valueChanged(ListSelectionEvent arg0) {
	JList secilen=(JList)arg0.getSource();
	for(int i=0;i<jlist.length;i++)
		jlist[i].setSelectedIndex(secilen.getSelectedIndex());
}
Connection baglanti;
public void baglan() {
	try {
			baglanti=DriverManager.getConnection("jdbc:sqlite:Ders Programi.db");
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	
}
public void combodoldur() {
	try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select distinct sinif,orgun from dersler");
		ResultSet veri=sorgu.executeQuery();
		jcb.removeAllItems();
	    jcb_id.removeAllItems();
	    jcb_orgun.removeAllItems();
		while(veri.next()) {
			int sinif=veri.getInt("sinif");
			int orgun=veri.getInt("orgun");
			jcb.addItem(sinif+".Sınıf"+"("+orgun+".Örgün"+")");
			jcb_id.addItem(sinif);
			jcb_orgun.addItem(orgun);
			
		}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this, e.getMessage()+"dsaasds");
	}
	
}
public void listdoldur(int sinif,int orgun) {
	try {
			baglan();
			 String sql="select d.teoriksaati as 'teorik', d.uygsaati as 'uyg', d.sinif as 'sinif',d.orgun as 'orgun',h.hocaismi as 'hoca',d.dersismi as 'ders',s.saad as 'saat',g.isim as 'gun' ,e.tip as 'tip' from eslestirme e inner join hoca h on h.id=e.hocaid inner join gun g on g.id=e.gunid inner join Saat s on s.id=e.saatid	inner join dersler d on d.id=e.dersid 	and e.dersid=d.id  where sinif=? and orgun=?" ;
			 		
			PreparedStatement sorgu=baglanti.prepareStatement(sql);
			sorgu.setInt(1,sinif);
			sorgu.setInt(2, orgun);
			ResultSet veri=sorgu.executeQuery();
		   for(int i=0;i<dlm.length;i++)
			   dlm[i].clear();
			while(veri.next()) {
				dlm[0].addElement(veri.getString("ders"));
				dlm[1].addElement(veri.getString("hoca"));
				dlm[2].addElement(veri.getString("gun"));
				dlm[3].addElement(veri.getString("saat"));
				dlm[4].addElement(veri.getString("teorik"));
				dlm[5].addElement(veri.getString("uyg"));
				
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
}
@Override
public void itemStateChanged(ItemEvent arg0) {
	
          if(arg0.getStateChange()==2) {
	int secilen=jcb.getSelectedIndex();	
	if(secilen>-1) {
	listdoldur(jcb_id.getItemAt(secilen),jcb_orgun.getItemAt(secilen));

}
}
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
public class Ders extends JFrame implements ActionListener,ListSelectionListener,WindowListener{
      DefaultListModel<String>[] dlm;
      JList<String>[] jlist;
      String[] lbl= {"Ders Ad","Kodu","Teorik Saati","Uyg Saati","Sınıf","Örgün"};
	  JTextField[] jtext;
	  Calistir frm;
      public Ders(Calistir frm) {
    	 this.frm=frm;
    	 frm.setVisible(false);
		this.setTitle("Ders");
		this.setSize(700,450);
		this.addWindowListener(this);
		this.setLayout(new FlowLayout());
		
		JPanel jpn_main=new JPanel();
		jpn_main.setPreferredSize(new Dimension(700, 450));
	   
		dlm=new DefaultListModel[lbl.length];
		jlist=new JList[dlm.length];
		jtext=new JTextField[jlist.length];
		
		for(int i=0;i<dlm.length;i++) {
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100, 450));
			
			JLabel jlb=new JLabel(lbl[i]);
			jlb.setPreferredSize(new Dimension(100,25));
			
			dlm[i]=new DefaultListModel<String>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane jscp=new JScrollPane(jlist[i]);
		    jscp.setPreferredSize(new Dimension(100, 300));
		    
		    jtext[i]=new JTextField();
		    jtext[i].setPreferredSize(new Dimension(100, 25));
		    
		    jpn.add(jlb);
		    jpn.add(jscp);
		    jpn.add(jtext[i]);
		    if(i==0) {
		    JButton btn=new JButton("Ekle");
		    btn.setPreferredSize(new Dimension(100, 25));
		    btn.addActionListener(this);
		    jpn.add(btn);	
		    }
		    jpn_main.add(jpn);
		}
		listdoldur();
		this.add(jpn_main);
		this.setVisible(true);
	}
   public boolean kontrol() {
	   int sayac=0;
	   for(int i=0;i<jtext.length;i++)
		    if(jtext[i].getText().length()>0)
		    	sayac++;
	   if(sayac==jtext.length)
		   return true;
	   else
		   return false;
   }
   Connection baglanti;
   public void baglan() {
   	try {
			baglanti=DriverManager.getConnection("jdbc:sqlite:Ders Programi.db");
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
   	
   }
   public void listdoldur() {
   	try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("select * from dersler");
			ResultSet veri=sorgu.executeQuery();
		   for(int i=0;i<dlm.length;i++)
			   dlm[i].clear();
			while(veri.next()) {
				dlm[0].addElement(veri.getString("dersismi"));
				dlm[1].addElement(veri.getString("kodu"));
				dlm[2].addElement(""+veri.getInt("teoriksaati"));
				dlm[3].addElement(""+veri.getInt("uygsaati"));
				dlm[4].addElement(""+veri.getInt("sinif"));
				dlm[5].addElement(""+veri.getInt("orgun"));
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
   }
   public boolean kontrol_ders() {
	   
	   for(int i=0;i<dlm[0].getSize();i++) {
		   if(dlm[0].getElementAt(i).equals(jtext[0].getText())&&dlm[4].getElementAt(i).equals(jtext[4].getText())&&dlm[5].getElementAt(i).equals(jtext[5].getText()))
	           return false;
	   }
   return true;}
	@Override
	public void actionPerformed(ActionEvent e) {
		if(kontrol()&&kontrol_ders()) {
		   
			try {
				 int teoriks=Integer.parseInt(jtext[2].getText());
				 int uygs=Integer.parseInt(jtext[3].getText());
				 int sinif=Integer.parseInt(jtext[4].getText());
				 int orgun=Integer.parseInt(jtext[5].getText());
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("insert into dersler(dersismi,kodu,teoriksaati,uygsaati,sinif,orgun) values(?,?,?,?,?,?)");
		    sorgu.setString(1, jtext[0].getText());
		    sorgu.setString(2, jtext[1].getText());
		    sorgu.setInt(3, teoriks);
		    sorgu.setInt(4, uygs);
		    sorgu.setInt(5, sinif);
		    sorgu.setInt(6, orgun);
		    sorgu.executeUpdate();
		    for(int i=0;i<jtext.length;i++)
		    	jtext[i].setText("");
		    listdoldur();
		    frm.combodoldur();
			} catch (Exception e2) {
			JOptionPane.showMessageDialog(this, e2.getMessage());
		}
		}
	}
	@Override
	public void valueChanged(ListSelectionEvent arg0) {
		JList secilen=(JList)arg0.getSource();
		for(int i=0;i<jlist.length;i++)
			jlist[i].setSelectedIndex(secilen.getSelectedIndex());
		
	}
	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosing(WindowEvent arg0) {
		frm.setVisible(true);
		
	}
	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
public class Eslestirme extends JFrame implements ActionListener,ListSelectionListener,WindowListener {
	 DefaultListModel<String>[] dlm;
	 DefaultListModel<Integer>[] dlm_id;
	 DefaultListModel<Integer> dlm_teouyg;
	 DefaultListModel<Integer> dlm_sinifid;
     JList<String>[] jlist;
     String[] lbl= {"Ders","Hoca","Saat","Gün","Tip"};
     JComboBox<String>[] jcb;
     JComboBox<Integer>[] jcb_id;
     Calistir frm;
	public Eslestirme(Calistir frm) {
		 this.frm=frm;
    	 frm.setVisible(false);
		this.setTitle("Eslestirme");
		this.setSize(600,450);
		this.addWindowListener(this);
		this.setLayout(new FlowLayout());
		
		JPanel jpn_main=new JPanel();
		jpn_main.setPreferredSize(new Dimension(600, 450));
	   
		dlm_teouyg=new DefaultListModel<Integer>();
		dlm_sinifid=new DefaultListModel<Integer>();
		dlm=new DefaultListModel[lbl.length];
		dlm_id=new DefaultListModel[lbl.length];
		jlist=new JList[dlm.length];
		jcb=new JComboBox[jlist.length];
		jcb_id=new JComboBox[jlist.length];
		
		for(int i=0;i<dlm.length;i++) {
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100, 450));
			
			JLabel jlb=new JLabel(lbl[i]);
			jlb.setPreferredSize(new Dimension(100,25));
			
			dlm[i]=new DefaultListModel<String>();
			dlm_id[i]=new DefaultListModel<Integer>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane jscp=new JScrollPane(jlist[i]);
		    jscp.setPreferredSize(new Dimension(100, 300));
		    
		    jcb[i]=new JComboBox<String>();
		    jcb[i].setPreferredSize(new Dimension(100, 25));
		    jcb_id[i]=new JComboBox<Integer>();
		    
		    jpn.add(jlb);
		    jpn.add(jscp);
		    jpn.add(jcb[i]); 
		    if(i==0) {
		    JButton btn=new JButton("Ekle");
		    btn.setPreferredSize(new Dimension(100, 25));
		    btn.addActionListener(this);
		    jpn.add(btn);	
		    }
		    jpn_main.add(jpn);
		}
		combodoldur();
		listdoldur();
		this.add(jpn_main);
	   this.setVisible(true);
	}
	Connection baglanti;
    public void baglan() {
    	try {
			baglanti=DriverManager.getConnection("jdbc:sqlite:Ders Programi.db");
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
    	
    }
    public void combodoldur() {
    	try {
    		PreparedStatement sorgu=null;
    		ResultSet veri=null;
			baglan();
			sorgu=baglanti.prepareStatement("select id,dersismi,sinif,orgun,teoriksaati,uygsaati from dersler");
		    veri=sorgu.executeQuery();
			jcb[0].removeAllItems();
			jcb_id[0].removeAllItems();
			dlm_teouyg.clear();
			dlm_sinifid.clear();
			while(veri.next()) {
				int sinif_id=veri.getInt("sinif");
				 jcb[0].addItem(veri.getString("dersismi")+"("+sinif_id+"."+veri.getInt("orgun")+"."+"Ögün"+")");
				 jcb_id[0].addItem(veri.getInt("id"));
				 dlm_teouyg.addElement(veri.getInt("teoriksaati")+veri.getInt("uygsaati"));
				 dlm_sinifid.addElement(sinif_id);
			}
			sorgu=baglanti.prepareStatement("select id,hocaismi from hoca");
		    veri=sorgu.executeQuery();
			jcb[1].removeAllItems();
			jcb_id[1].removeAllItems();
			while(veri.next()) {
				 jcb[1].addItem(veri.getString("hocaismi"));
				 jcb_id[1].addItem(veri.getInt("id"));
			}
			sorgu=baglanti.prepareStatement("select id,saad from Saat");
		    veri=sorgu.executeQuery();
			jcb[2].removeAllItems();
			jcb_id[2].removeAllItems();
			while(veri.next()) {
				 jcb[2].addItem(veri.getString("saad"));
				 jcb_id[2].addItem(veri.getInt("id"));	
			}
			sorgu=baglanti.prepareStatement("select id,isim from gun");
		    veri=sorgu.executeQuery();
			jcb[3].removeAllItems();
			jcb_id[3].removeAllItems();
			while(veri.next()) {
				 jcb[3].addItem(veri.getString("isim"));
				 jcb_id[3].addItem(veri.getInt("id"));
			}
			jcb[4].addItem("Teorik");
			jcb[4].addItem("Uygulama");
			jcb_id[4].addItem(1);
			jcb_id[4].addItem(2);
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
    }
    public void listdoldur() {
       	try {
    			baglan();
    			PreparedStatement sorgu=baglanti.prepareStatement("select d.sinif as 'sinif',d.orgun as 'orgun',h.id as 'h',s.id as 's',g.id as 'g',d.dersismi as 'ders',h.hocaismi as 'hoca',g.isim as 'gun',s.saad as 'saat' ,e.tip as 'tip' from eslestirme e inner join dersler d on d.id=e.dersid inner join hoca h on h.id=e.hocaid inner join gun g on g.id=e.gunid inner join Saat s on s.id=e.saatid");
    				
    			ResultSet veri=sorgu.executeQuery();
    		   for(int i=0;i<dlm.length;i++)
    			   dlm[i].clear();
    			while(veri.next()) {
    				int sinif_id=veri.getInt("sinif");
    				dlm[0].addElement(veri.getString("ders")+"("+veri.getInt("sinif")+"."+veri.getInt("orgun")+"."+"Ögün"+")");
    				dlm[1].addElement(veri.getString("hoca"));
    				dlm[2].addElement(veri.getString("saat"));
    				dlm[3].addElement(veri.getString("gun"));
    				String tip="Teorik";
    				if(veri.getInt("tip")==2)
    					tip="Uygulama";
    			    dlm[4].addElement(tip);
    			
    			    dlm_id[0].addElement(sinif_id);
    				dlm_id[1].addElement(veri.getInt("h"));
    				dlm_id[2].addElement(veri.getInt("s"));
    				dlm_id[3].addElement(veri.getInt("g"));
    				
    			}
    		} catch (Exception e) {
    			JOptionPane.showMessageDialog(this, e.getMessage());
    		}
       }
    public boolean teouyg_kontrol(String ders,int teouyg_saat) {
    	int sayac=0;
    	for(int i=0;i<dlm[0].getSize();i++) {
    		
    		if(dlm[0].getElementAt(i).equals(ders))
    			sayac++;
    	}
    		if(sayac==teouyg_saat)//teouyg_saat adlı dlm de teo+uyg toplamı var
    			return false;
    return true;}
    public boolean kontrol(int sinif_id,int h_id,int s_id,int g_id) {
    	
    	for(int i=0;i<dlm_id[0].size();i++) {
    		
    		//Hoca aynı saatte ve aynı gunde derse giremez
    		if(h_id==dlm_id[1].getElementAt(i)&&s_id==dlm_id[2].getElementAt(i)&&g_id==dlm_id[3].getElementAt(i))
				return false;
    		//Aynı saatte aynı sınıfa baska bir ders olamaz
			if(dlm_id[0].getElementAt(i)==sinif_id&&s_id==dlm_id[2].getElementAt(i)&&g_id==dlm_id[3].getElementAt(i))
				return false;
    			
    	}
   return true;
    }
	@Override
	public void actionPerformed(ActionEvent e) {
		int secilen_d=jcb[0].getSelectedIndex();
		int secilen_h=jcb[1].getSelectedIndex();
		int secilen_s=jcb[2].getSelectedIndex();
		int secilen_g=jcb[3].getSelectedIndex();
		if(secilen_d>-1&&secilen_h>-1&&secilen_s>-1&&secilen_g>-1) {
		 int d_id=jcb_id[0].getItemAt(secilen_d);
		 int h_id=jcb_id[1].getItemAt(secilen_h);
		 int s_id=jcb_id[2].getItemAt(secilen_s);
		 int g_id=jcb_id[3].getItemAt(secilen_g);
		 int sinif_id=dlm_sinifid.getElementAt(secilen_d);
		 if(kontrol(sinif_id,h_id,s_id,g_id)&&teouyg_kontrol(jcb[0].getItemAt(secilen_d), dlm_teouyg.getElementAt(secilen_d))) {
			 int tip=1;
				if(jcb[4].getItemAt(jcb[4].getSelectedIndex())=="Uygulama")
					tip=2;
			try {
				PreparedStatement sorgu=baglanti.prepareStatement("insert into eslestirme(dersid,hocaid,gunid,saatid,tip) values(?,?,?,?,?)");
			     sorgu.setInt(1, d_id);
			     sorgu.setInt(2, h_id);
			     sorgu.setInt(3, g_id);
			     sorgu.setInt(4, s_id);
			     sorgu.setInt(5, tip);
			     sorgu.executeUpdate();
			     listdoldur();
			     frm.combodoldur();
			     frm.listdoldur(frm.jcb_id.getItemAt(0),frm.jcb_orgun.getItemAt(0));
			} catch (Exception e2) {
				JOptionPane.showMessageDialog(this, e2.getMessage());
		      } 	 
		   }
		 else
			 JOptionPane.showMessageDialog(this, "Aynı gün ve aynı saatte ");
		}
	}
	@Override
	public void valueChanged(ListSelectionEvent arg0) {
		JList secilen=(JList)arg0.getSource();
		for(int i=0;i<jlist.length;i++)
			jlist[i].setSelectedIndex(secilen.getSelectedIndex());
		
	}
	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosing(WindowEvent arg0) {
		frm.setVisible(true);
		
	}
	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Hoca extends JFrame implements ActionListener,WindowListener{
      DefaultListModel<String> dlm;
      JList<String> jlist;
      JTextField jtext;
      Calistir frm;
	public Hoca(Calistir frm) {
		 this.frm=frm;
    	 frm.setVisible(false);
		this.setTitle("Hoca");
		this.setSize(150,500);
		this.addWindowListener(this);
		this.setLayout(new FlowLayout());
		
		JPanel jpn=new JPanel();
		jpn.setPreferredSize(new Dimension(150, 500));
        
		dlm=new DefaultListModel<String>();
		jlist=new JList<String>(dlm);
	
		JScrollPane jscp=new JScrollPane(jlist);
		jscp.setPreferredSize(new Dimension(100, 300));
		 
		jtext=new JTextField();
		jtext.setPreferredSize(new Dimension(100, 25));
		
		JButton btn=new JButton("Ekle");
		btn.setPreferredSize(new Dimension(100, 25));
		btn.addActionListener(this);
		JLabel jlb=new JLabel("Hocalar");
		jlb.setPreferredSize(new Dimension(100,25));
	   
		jpn.add(jlb);
		jpn.add(jscp);
		jpn.add(jtext);
		jpn.add(btn);
		listdoldur();
		this.add(jpn);
	    this.setVisible(true);
	}
	Connection baglanti;
    public void baglan() {
    	try {
			baglanti=DriverManager.getConnection("jdbc:sqlite:Ders Programi.db");
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
    	
    }
    public void listdoldur() {
    	try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("select hocaismi from hoca");
			ResultSet veri=sorgu.executeQuery();
			dlm.clear();
			while(veri.next()) {
				dlm.addElement(veri.getString("hocaismi"));
				
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
    }
	@Override
	public void actionPerformed(ActionEvent arg0) {
	  
		   if(jtext.getText().length()>0) {
    try {
		PreparedStatement sorgu=baglanti.prepareStatement("insert into hoca(hocaismi) values(?)");
		sorgu.setString(1, jtext.getText());
		sorgu.executeUpdate();
		jtext.setText("");
		listdoldur();
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this, e.getMessage());
	}
	}
	}
	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosing(WindowEvent arg0) {
			frm.setVisible(true);
		
	}
	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}

Uygulamanın tamamını indir

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Calistir extends JFrame implements ActionListener {
       String[] lbl_txt= {"Takım İsmi","Puan","Averaj","A Gol","Y Gol ","O Mac"};
       Connection baglanti;
       DefaultTableModel dtm; 
       JTable tbl;
        DefaultListModel<Integer>[] dlm;
        DefaultListModel<String> tkm_ad;
        DefaultListModel<String> tkm_isim;
        DefaultListModel<Integer> tkm_id;
        DefaultListModel<Integer>[] deger;
        DefaultListModel<Integer>[] yeni_deger;
   
        int[][] degerler; 
	public Calistir() {
		this.setTitle("Takım Bilgileri");
		this.setSize(450, 600);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLayout(new FlowLayout());
	    
		JPanel jpn_main=new JPanel();
		jpn_main.setPreferredSize(new Dimension(350, 600));
		jpn_main.setLayout(new FlowLayout());
		
		dtm=new DefaultTableModel();
		dtm.setColumnIdentifiers(lbl_txt);
		
		dlm=new DefaultListModel[4];
		deger=new DefaultListModel[lbl_txt.length-1];
		yeni_deger=new DefaultListModel[lbl_txt.length-1];
		
		tkm_ad=new DefaultListModel<String>();
	    tkm_isim=new DefaultListModel<String>();
		tkm_id=new DefaultListModel<Integer>();
	
	   for(int i=0;i<dlm.length;i++) {
		         dlm[i]=new DefaultListModel();
		     
	   }
	   for(int i=0;i<yeni_deger.length;i++) {
	         yeni_deger[i]=new DefaultListModel<Integer>();
	         deger[i]=new DefaultListModel<Integer>();
 }
	  
		         listdoldur();
		int yukseklik= dtm.getDataVector().size()*18;
		tbl=new JTable(dtm);
	    tbl.getColumnModel().getColumn(0).setPreferredWidth(100);
	    
	   for(int i=1;i<lbl_txt.length;i++)
		   tbl.getColumnModel().getColumn(i).setPreferredWidth(40);
	   
	    JScrollPane jscp=new JScrollPane(tbl);
	    jscp.setPreferredSize(new Dimension(300,yukseklik));
	     jscp.setMaximumSize(new Dimension(300, 500));
	    jpn_main.add(jscp);
	    
		JButton btn=new JButton("Maçlar");
		btn.setPreferredSize(new Dimension(100, 25));
		btn.addActionListener(this);
		jpn_main.add(btn);
		
		this.add(jpn_main);
		this.setVisible(true);
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
	    this.setVisible(false);   
		new Maclar(this);
	}
	public void baglan() {
		try {
			Class.forName("org.sqlite.JDBC");
			baglanti=DriverManager.getConnection("jdbc:sqlite::resource:Odev.db");				
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	}
	int sayac=0;
	public void listdoldur() {
		try {
			sayac=0;
			PreparedStatement sorgu=null;
			ResultSet veri=null;
			baglan();
			 sorgu=baglanti.prepareStatement("select * from Takimlar ");
			 veri=sorgu.executeQuery();
			  tkm_ad.clear();
			  tkm_id.clear();
			  
			  while(veri.next()) {
				tkm_ad.addElement(veri.getString("T_Ad"));
				tkm_id.addElement(veri.getInt("ID"));
			sayac++;
			  }
			veri.close();
			veri=null;
			 baglanti.close();
			 baglan();
			 sorgu=baglanti.prepareStatement("select * from Skorlar ");
			 veri=sorgu.executeQuery();
			 for(int i=0;i<dlm.length;i++)
				    dlm[i].clear();
			 while(veri.next()) {
				 dlm[0].addElement(veri.getInt("Takim1"));
				 dlm[1].addElement(veri.getInt("Takim2"));
				 dlm[2].addElement(veri.getInt("Skor1"));
				 dlm[3].addElement(veri.getInt("Skor2"));
			 }
			 veri.close();
			 baglanti.close();
			 degerler=new int[sayac][5];
			 hesapla();
			
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage()+"HATA Calistir");
		}	
	}
	public void hesapla() {
	          
		for(int i=0;i<dlm[2].size();i++) {
				int[] skor= {dlm[2].getElementAt(i),dlm[3].getElementAt(i)};
		int[] takim= {dlm[0].getElementAt(i),dlm[1].getElementAt(i)};
        int[] puan= {0,0},averaj= {0,0},y_gol= {skor[1],skor[0]};
		           if(skor[0]==skor[1]) {
                	puan[0]=1;
                	puan[1]=1;  
                   }			
                   else if(skor[0]>skor[1]) {
                	   puan[0]=3; 
                       puan[1]=0;
                   }	   
                   else {
                	   puan[0]=0;
                       puan[1]=3;
                   }
		           averaj[0]=skor[0]-skor[1];
		           averaj[1]=skor[1]-skor[0];
		   
		        for(int j=0;j<takim.length;j++) {
		        	for(int k=0;k<tkm_id.size();k++) {
		        		  if(takim[j]==tkm_id.getElementAt(k))
		        		  {    
		        			 degerler[k][0]+=puan[j];
		        			 degerler[k][1]+=averaj[j];
		        			 degerler[k][2]+=skor[j];
		        			 degerler[k][3]+=y_gol[j];
		        			 degerler[k][4]+=1;
		        		
		        			  break;
		        		  }
		        	}        	
		       }
		       
		}
		
		for(int i=0;i<sayac;i++) {

			deger[0].addElement(  degerler[i][0]);
			deger[1].addElement( degerler[i][1]);
			deger[2].addElement(degerler[i][2]);
			deger[3].addElement( degerler[i][3]);
			deger[4].addElement( degerler[i][4]);
      }  
		
		 int indis=0;
	        tkm_isim.clear();
	        for(int i=0;i<yeni_deger.length;i++)
	        	yeni_deger[i].clear();
	      int syc=0;
			  while(deger[0].size()!=0) {
				 int buyuk=deger[0].getElementAt(0);
				 indis=0;
				for(int j=1;j<deger[0].size();j++) {
			               if(deger[0].getElementAt(j)>buyuk) 
			               {   
			                   buyuk=deger[0].getElementAt(j);
			            	   indis=j;
			                 
			               }
				}
			
			   tkm_isim.addElement( tkm_ad.getElementAt(indis));
					yeni_deger[0].addElement (deger[0].getElementAt(indis));
					yeni_deger[1].addElement (deger[1].getElementAt(indis));
					yeni_deger[2].addElement(deger[2].getElementAt(indis));
					yeni_deger[3].addElement (deger[3].getElementAt(indis));
					yeni_deger[4].addElement (deger[4].getElementAt(indis));
			
				  for(int k=0;k<deger.length;k++)
	                  deger[k].remove(indis);
				     tkm_ad.remove(indis);
				    
			 }
		  dtm.getDataVector().removeAllElements();//Table tamamen temizlemek için
		  dtm.fireTableDataChanged();
		  for(int i=0;i<tkm_isim.size();i++) {
				
	    	  String[] veriler= {tkm_isim.getElementAt(i),yeni_deger[0].getElementAt(i)+"",yeni_deger[1].getElementAt(i)+"",yeni_deger[2].getElementAt(i)+"",yeni_deger[3].getElementAt(i)+"",yeni_deger[4].getElementAt(i)+""};
	    	  dtm.addRow(veriler);
		}
	
	}
	
public static void main(String[] arg) {
	
 new Calistir();

}
}
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Maclar extends JFrame implements ActionListener,ListSelectionListener,WindowListener {
       String[] lbl_txt= {"1.Takım İsmi","2.Takım İsmi","1.T Skor","2.T Skor"};
	   DefaultListModel<String>[] dlm;
       JList<String>[] jlist;
       JComboBox<String>[] jcb;
       JComboBox<Integer>[] jcb_id;
       JTextField[] jtext;
       DefaultListModel<Integer>[] Y_Mac; 
       Connection baglanti;
	   Calistir frm1;
       public Maclar(Calistir frm1) {
    	this.frm1=frm1;  
		this.setTitle("Takım Bilgileri");
		this.setSize(500, 600);
		this.setLayout(new FlowLayout());
		this.addWindowListener(this);
		
		JPanel jpn_main=new JPanel();
		jpn_main.setPreferredSize(new Dimension(500, 600));
		jpn_main.setLayout(new FlowLayout());
		
		dlm=new DefaultListModel[lbl_txt.length];
		jlist=new JList[dlm.length];
		
		jcb=new JComboBox[2];
		Y_Mac=new DefaultListModel[jcb.length];
		jtext=new JTextField[jcb.length];
		jcb_id=new JComboBox[3];
		
		for(int i=0;i<dlm.length;i++) {
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100, 500));
			
			JLabel jlb=new JLabel(lbl_txt[i]);
			jlb.setPreferredSize(new Dimension(100, 25));
			jpn.add(jlb);
			
		    dlm[i]=new DefaultListModel<String>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane jscp=new JScrollPane(jlist[i]);
			jscp.setPreferredSize(new Dimension(100, 300));
			jpn.add(jscp);
             
		
			if(i<jcb.length) {
				Y_Mac[i]=new DefaultListModel<Integer>();
			    jcb[i]=new JComboBox<String>();
			    jcb[i].setPreferredSize(new Dimension(100, 25));
			    jpn.add(jcb[i]);
			}
			if(i>=jcb.length) {
			jtext[i-jcb.length]=new JTextField();
			jtext[i-jcb.length].setPreferredSize(new Dimension(100, 25));
			jpn.add(jtext[i-jcb.length]);
			}
			if(i<jcb_id.length) 
		  jcb_id[i]=new JComboBox<Integer>();//idler için
			
			if(i==0) {
				  JButton btn=new JButton("Ekle");
				  btn.setPreferredSize(new Dimension(100, 25));	  
				  btn.addActionListener(this);
				  jpn.add(btn);	
					}
		  jpn_main.add(jpn);
		}
		combodoldur();
		listdoldur();
		this.add(jpn_main);
		this.setVisible(true);
	}
	@Override
	public void valueChanged(ListSelectionEvent arg0) {
	   JList secilen=(JList)arg0.getSource();
		for(int i=0;i<jlist.length;i++)
	               jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	}
	@Override
	public void actionPerformed(ActionEvent arg0) {
	
		int secilen1=jcb[0].getSelectedIndex();//1. takım eğer bir sey secmezsek -1 degeri döner
		int secilen2=jcb[1].getSelectedIndex();//2.takım
		int[] takim_id= {jcb_id[0].getItemAt(secilen1),jcb_id[1].getItemAt(secilen2)};
		if(secilen1>-1&&secilen2>-1&&jtext[0].getText().length()>0&&jtext[1].getText().length()>0&&takim_id[0]!=takim_id[1]&&Mac_kontrol(takim_id[0],takim_id[1])) {
			try {
				int[] skor= {Integer.parseInt(jtext[0].getText()),Integer.parseInt(jtext[1].getText())};
				baglan();
				PreparedStatement sorgu=baglanti.prepareStatement("insert into Skorlar(Takim1,Takim2,Skor1,Skor2) values(?,?,?,?)");
				sorgu.setInt(1, takim_id[0]);
				sorgu.setInt(2, takim_id[1]);
				sorgu.setInt(3, skor[0]);
				sorgu.setInt(4, skor[1]);
				sorgu.executeUpdate();
				baglanti.close();
				listdoldur();       
				           for(int i=0;i<jtext.length;i++)
				        	   jtext[i].setText("");	
				frm1.listdoldur();           
			} catch (Exception e) {
			JOptionPane.showMessageDialog(this,e.getMessage()+"HAta Maclar");
			}
		}
		
		else
		JOptionPane.showMessageDialog(this,"Aynı Maç tekrar yapılamaz veya Aynı takımlar maç yapamazlar skor bilgileri doğru girilmelidir");
	}
	public boolean Mac_kontrol(int takim1,int takim2) {
	  	
		for(int i=0;i<dlm[0].getSize();i++) 
			if(Y_Mac[0].getElementAt(i)==takim1&&Y_Mac[1].getElementAt(i)==takim2)
				return false;
	return true;
	}
	

	public void baglan() {
		try {
			Class.forName("org.sqlite.JDBC");
			baglanti=DriverManager.getConnection("jdbc:sqlite::resource:Odev.db");				
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	}
	public void combodoldur() {
		try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("select ID,T_Ad from Takimlar");
			ResultSet veri=sorgu.executeQuery();
			for(int i=0;i<jcb.length;i++)
				jcb[i].removeAllItems();
			
			while(veri.next()) {
				jcb[0].addItem(veri.getString("T_Ad"));
				jcb[1].addItem(veri.getString("T_Ad"));
			    jcb_id[0].addItem(veri.getInt("ID"));
			    jcb_id[1].addItem(veri.getInt("ID"));
			}
			veri.close();
			baglanti.close();
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
		
	}
	
  public void listdoldur() {
	  try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select s.ID as 'ID', t.T_Ad as 'T1_Ad',(select T_Ad  from Takimlar where ID=s.Takim2) as 'T2_Ad',s.Takim1 as 'Takim1',s.Takim2 'Takim2',s.Skor1 as 'Skor1',s.Skor2 as 'Skor2' from Takimlar t inner join Skorlar s on t.ID=s.Takim1 ");
	   ResultSet veri=sorgu.executeQuery();
	   for(int i=0;i<dlm.length;i++)
		       dlm[i].clear();
	   jcb_id[2].removeAllItems();
	   for(int i=0;i<Y_Mac.length;i++)
	       Y_Mac[i].clear();
	   while(veri.next()) {
		   jcb_id[2].addItem(veri.getInt("ID"));
		   dlm[0].addElement(veri.getString("T1_Ad"));
		   dlm[1].addElement(veri.getString("T2_Ad"));
		   dlm[2].addElement(veri.getInt("Skor1")+"");
		   dlm[3].addElement(veri.getInt("Skor2")+"");
		   Y_Mac[0].addElement(veri.getInt("Takim1"));
		   Y_Mac[1].addElement(veri.getInt("Takim2"));
	   }
	veri.close();
	baglanti.close();
	  } catch (Exception e) {
		  JOptionPane.showMessageDialog(this, e.getMessage());
	}
  }
@Override
public void windowActivated(WindowEvent arg0) {
	// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
	
}
@Override
public void windowClosing(WindowEvent arg0) {
	// TODO Auto-generated method stub
	frm1.setVisible(true);//kapanış olurken diğer formu görünür yap	
}
@Override
public void windowDeactivated(WindowEvent arg0) {
	// TODO Auto-generated method stub	
}
@Override
public void windowDeiconified(WindowEvent arg0) {
	// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
	// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
	// TODO Auto-generated method stub
}
}

 

Fatura Hesaplama

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener {
      String[] jlb= {"Ad","SoyAd","Tür","MetreKüp","Tutar"};
	  DefaultListModel<String>[] dlm;
	  JList[] jlist;
	  JTextField[] jtext; 
	  JComboBox<String> jcbtur;
	  DefaultListModel<Integer>[] dlm_id;
	  String[] btn_txt= {"Ekle","Sil","Güncelle"};
	  Connection baglanti;
 	public Calistir() {
       this.setTitle("Su Fatura Hesaplama");
       this.setSize(600, 500);
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       this.setLayout(new FlowLayout());
       
       JPanel jpn_main=new JPanel();//Diğer panellerin kaymaması için
       jpn_main.setPreferredSize(new Dimension(600,500));
        
       Dimension boyut=new Dimension(100,25);
       
       dlm=new DefaultListModel[jlb.length];
       jlist=new JList[dlm.length];
       dlm_id=new DefaultListModel[2];
       jcbtur=new JComboBox<String>();
       jcbtur.setPreferredSize(boyut);
       jtext=new JTextField[3];
       for(int i=0;i<jlb.length;i++) {
    	   JPanel jpn=new JPanel();
    	   jpn.setPreferredSize(new Dimension(100,450));
    	   JLabel jlbl=new JLabel(jlb[i]);
    	   jlbl.setPreferredSize(boyut);
    	   jpn.add(jlbl);
    	   dlm[i]=new DefaultListModel<String>();
    	   jlist[i]=new JList<String>(dlm[i]);
    	   jlist[i].addListSelectionListener(this);
    	   JScrollPane scp=new JScrollPane(jlist[i]);
    	   scp.setPreferredSize(new Dimension(100,300));
    	   jpn.add(scp);
    	   if(i<jtext.length) {
    		   jtext[i]=new JTextField();
    		   jtext[i].setPreferredSize(boyut);
    	   }
    	   if(i<2) {
    		   jpn.add(jtext[i]);
    	   dlm_id[i]=new DefaultListModel<Integer>();
    	   }
    		   if(i==2) 
        	   jpn.add(jcbtur);
        	if(i==3)
        		jpn.add(jtext[i-1]);
         if(i<btn_txt.length)
         {
        	 JButton jbtn=new JButton(btn_txt[i]);
        	 jbtn.setPreferredSize(boyut);
        	 jbtn.addActionListener(this);
        	 jbtn.setActionCommand(btn_txt[i]);
        	 jpn.add(jbtn);
        	 
         }
    	   jpn_main.add(jpn);
       }
       combodoldur();
       listedoldur();
       this.add(jpn_main);
       this.setVisible(true);
	}
	
@Override
public void actionPerformed(ActionEvent arg0) {
		
	   switch(arg0.getActionCommand()) {
	   case "Ekle":ekle();break;
	   case "Sil":sil();break;
	   case "Güncelle":guncelle();break;
	   }
		
	}
public void ekle() {
try {
	
	int secilentur=jcbtur.getSelectedIndex();
	if(jtext[0].getText().length()>0&&jtext[1].getText().length()>0&&secilentur>-1){
		int secilenid=dlm_id[0].getElementAt(secilentur);
	    int miktar=Integer.parseInt(jtext[2].getText());
	    PreparedStatement sorgu=baglanti.prepareStatement("insert into Faturalar(Ad,SoyAd,TurID,MetreKup) values(?,?,?,?)");
	     sorgu.setString(1, jtext[0].getText());
	     sorgu.setString(2, jtext[1].getText());
	     sorgu.setInt(3, secilenid);
	     sorgu.setInt(4, miktar);
	     sorgu.executeUpdate();
	     listedoldur();
	     for(int i=0;i<jtext.length;i++)
	    	 jtext[i].setText("");
	}

} catch (Exception e) {
	JOptionPane.showMessageDialog(this,e.getMessage());
}
}
public void sil() {
	try {
		int secilen=jlist[0].getSelectedIndex();
		if(secilen>-1) {
			PreparedStatement sorgu=baglanti.prepareStatement("delete from Faturalar where ID=?");
			sorgu.setInt(1, dlm_id[1].getElementAt(secilen));
			sorgu.executeUpdate();
			listedoldur();
		}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
	
}
public void guncelle() {
	try {
		int secilentur=jcbtur.getSelectedIndex();
		int secilen=jlist[0].getSelectedIndex();
		if(jtext[0].getText().length()>0&&jtext[1].getText().length()>0&&secilentur>-1&&secilen>-1){
			int secilenid=dlm_id[0].getElementAt(secilentur);
		    int miktar=Integer.parseInt(jtext[2].getText());
		    PreparedStatement sorgu=baglanti.prepareStatement("update Faturalar set Ad=?,SoyAd=?,TurID=?,MetreKup=? where ID=?");
		     sorgu.setString(1, jtext[0].getText());
		     sorgu.setString(2, jtext[1].getText());
		     sorgu.setInt(3, secilenid);
		     sorgu.setInt(4, miktar);
		     sorgu.setInt(5, dlm_id[1].getElementAt(secilen));
		     sorgu.executeUpdate();
		     listedoldur();
		     for(int i=0;i<jtext.length;i++)
		    	 jtext[i].setText("");
		}

	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
public void baglan() {

  try {
	baglanti=DriverManager.getConnection("jdbc:sqlite:Fatura.db");
} catch (Exception e) {
	JOptionPane.showMessageDialog(this,e.getMessage());
}
}
public void combodoldur() {
	try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select ID,TUR from Turler");
	jcbtur.removeAllItems();
	dlm_id[0].clear();
	ResultSet veri=sorgu.executeQuery();
	
	while(veri.next()) {
		jcbtur.addItem(veri.getString("TUR"));
		dlm_id[0].addElement(veri.getInt("ID"));
		
	}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
public void listedoldur() {
	try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select t.Tur as 'Tad',f.ID as 'ID',f.Ad as 'Ad',f.SoyAd as 'SoyAd',f.MetreKup as 'MetreKup',t.M0F as 'M0F',t.M25F as 'M25F',t.M35f as 'M35F' from Faturalar f inner join Turler t on t.ID=f.TurID");
	    ResultSet veri=sorgu.executeQuery();
	  
	    for(int i=0;i<dlm.length;i++)
	    	dlm[i].clear();
	    dlm[1].clear();
	   
	    while(veri.next()) {
	    	
	    	dlm_id[1].addElement(veri.getInt("ID"));
	    	dlm[0].addElement(veri.getString("Ad"));
	    	dlm[1].addElement(veri.getString("SoyAd"));
	    	dlm[2].addElement(veri.getString("Tad"));
	    	double metrekup=veri.getDouble("MetreKup");
	    	dlm[3].addElement(metrekup+"");
	    	double tutar=0;
	    	if(0<metrekup&&metrekup<25)
	    		tutar=metrekup*veri.getInt("M0F");
	    	if(25<metrekup&&metrekup<35)
	    		tutar=metrekup*veri.getInt("M0F")+metrekup*veri.getInt("M25F");
	    	if(metrekup>35)
	    		tutar=metrekup*veri.getInt("M0F")+metrekup*veri.getInt("M25F")+metrekup*veri.getInt("M35F");
	    	dlm[4].addElement(""+tutar);
	    }
	
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
 public static void main(String[] arg) {
	 
	 new Calistir();
 }

@Override
public void valueChanged(ListSelectionEvent e) {
	JList secilen=(JList)e.getSource();
	for(int i=0;i<jlist.length;i++)
		jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	
}

}

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener{
    DefaultListModel<String>[] dlm;
    DefaultListModel<Double>[] degerler;
    DefaultListModel<Integer> id;
    DefaultListModel<String> durumlar;
    JRadioButton[] rbtn;
    JList<String>[] jlist;
    JTextField[] jtext;
    DefaultTableModel dtm; 
    JTable jtbl;
    String[] btn_isim= {"Ekle","Sil","Güncelle"};
    String[] jlb_text= {"İsim","Soy İsim","Boy","Kilo"};
    String[] column= {"İsim","Soy İsim","Vücut Endeksi","Durum","İdeal Kilo"};
    String[] cinsiyet= {"Erkek","Kadın"};
    ButtonGroup bg=new ButtonGroup();
   Connection baglanti;
    public Calistir() {
		this.setTitle("Vücut kitle Endeksi İdeal Kilo");
		this.setSize(1200, 650);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new FlowLayout());
        
        JPanel main_jpn=new JPanel();
        main_jpn.setPreferredSize(new Dimension(1200,650));
        main_jpn.setLayout(new FlowLayout());
        
        degerler=new DefaultListModel[2];
        id=new DefaultListModel<Integer>();
        durumlar=new DefaultListModel<String>();
        dlm=new DefaultListModel[jlb_text.length];
        jlist=new JList[dlm.length];
        jtext=new JTextField[dlm.length];
        JPanel[] jpn= {new JPanel(),new JPanel()};
        jpn[0].setPreferredSize(new Dimension(110*dlm.length+75,650));
        jpn[1].setPreferredSize(new Dimension(1100-(125*dlm.length),650));
       
 
        main_jpn.add(jpn[0]);
        main_jpn.add(jpn[1]);
       
        dtm=new DefaultTableModel();
        jtbl=new JTable(dtm);
        
        rbtn=new JRadioButton[2];
        dtm.setColumnIdentifiers(column);
        JScrollPane tscp=new JScrollPane(jtbl);
        tscp.setPreferredSize(new Dimension(1100-(125*dlm.length),450));
        jpn[1].add(tscp);
        Dimension boyut=new Dimension(100, 25);
        for(int i=0;i<dlm.length;i++) {
        	JPanel jpn_list=new JPanel();
        	jpn_list.setPreferredSize(new Dimension(100, 650));
     
        	JLabel jlb=new JLabel(jlb_text[i]);
        	jlb.setPreferredSize(boyut);
        	dlm[i]=new DefaultListModel<String>();
            jlist[i]=new JList<String>(dlm[i]);
            jlist[i].addListSelectionListener(this);
        	JScrollPane scp=new JScrollPane(jlist[i]);
        	scp.setPreferredSize(new Dimension(100,350));
        	jpn_list.add(jlb);
        	jpn_list.add(scp);
        	jtext[i]=new JTextField();
        	jtext[i].setPreferredSize(boyut);
        	jpn_list.add(jtext[i]);
        	if(i<btn_isim.length) {
                 JButton btn=new JButton(btn_isim[i]);
                 btn.setPreferredSize(new Dimension(100,33));
                 btn.addActionListener(this);
                 btn.setActionCommand(btn_isim[i]);
               jpn_list.add(btn);        
        	}
        	if(i==dlm.length-1) {
        		for(int j=0;j<rbtn.length;j++) {
        			rbtn[j]=new JRadioButton(cinsiyet[j]);
        			rbtn[j].setPreferredSize(new Dimension(75, 15));
        			rbtn[0].setSelected(true);
        		    bg.add(rbtn[j]);
        		    jpn_list.add(rbtn[j]);
        	        degerler[j]=new DefaultListModel<Double>();

        		}
        	}
          jpn[0].add(jpn_list);
        }
        degerdoldur();
        listdoldur();
        this.add(main_jpn);
        this.setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {

		switch(arg0.getActionCommand()) {
		case "Ekle":ekle();break;
		case "Sil":sil();break;
		case "Güncelle":guncelle();break;
		}
	}
	public boolean dogrula()
	{
		int sayac=0;
		for(int i=0;i<jtext.length;i++)
 			    if(jtext[i].getText().length()>0)
                         sayac++;		
	 if(sayac==jtext.length)
		 return true;
	 else
		 return false;
				 
	}
public void ekle() {
  try {
	  double boy=Double.parseDouble(jtext[2].getText());
	  double kilo=Double.parseDouble(jtext[3].getText());
	 if(dogrula()) {
	  baglan();
	  String cins=rbtn[1].getText();
	  if(rbtn[0].isSelected())
		  cins=rbtn[0].getText();
	PreparedStatement sorgu=baglanti.prepareStatement("insert into Kisiler(Ad,SoyAd,Boy,Kilo,Cinsiyet) values(?,?,?,?,?)");
	 sorgu.setString(1, jtext[0].getText());
	 sorgu.setString(2, jtext[1].getText());
	 sorgu.setDouble(3, boy);
	 sorgu.setDouble(4, kilo);
	 sorgu.setString(5,cins);
	 sorgu.executeUpdate();
	 baglanti.close();
	 listdoldur();
	 for(int i=0;i<jtext.length;i++)
		 jtext[i].setText("");
	 }
	 rbtn[0].setSelected(true);
  } catch (Exception e) {
	  JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());	
	}
  }	

public void sil() {
	int secilen=jlist[0].getSelectedIndex();
	try {
		if(secilen>-1)
		{   baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("delete from Kisiler where ID=?");
			sorgu.setInt(1, id.getElementAt(secilen));
			sorgu.executeUpdate();
			baglanti.close();
			listdoldur();
		}
	} catch (Exception e) {
		 JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());
		 }
	
}
public void guncelle() {
	int secilen=jlist[0].getSelectedIndex();
	try {
		double boy=Double.parseDouble(jtext[2].getText());
		double kilo=Double.parseDouble(jtext[3].getText());
		if(secilen>-1&&dogrula()) {
			 String cins=rbtn[0].getText();
			  if(rbtn[1].isSelected())
				  cins=rbtn[1].getText();
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("update Kisiler set Ad=?,SoyAd=?,Boy=?,Kilo=?,Cinsiyet=? where ID=?");
			sorgu.setString(1, jtext[0].getText());
			sorgu.setString(2, jtext[1].getText());
			sorgu.setDouble(3, boy);
			sorgu.setDouble(4, kilo);
			sorgu.setString(5, cins);
			sorgu.setInt(6, id.getElementAt(secilen));
			sorgu.executeUpdate();
		   baglanti.close();
		   for(int i=0;i<jtext.length;i++)
		       jtext[i].setText("");
		  listdoldur();
		  rbtn[0].setSelected(true);
		}
		
	} catch (Exception e) {
		 JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());	
	}
}
	@Override
	public void valueChanged(ListSelectionEvent e) {
		JList secilen=(JList)e.getSource();
		for(int i=0;i<jlist.length;i++)
			jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	}
public static void main(String[] arg) {
	new Calistir();
}
public void degerdoldur() {
	try {
		 
	     baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select Baslangic,Bitis,Durum from Degerler");
	    ResultSet veri=sorgu.executeQuery();
	    while(veri.next()) {
	    	degerler[0].addElement(veri.getDouble("Baslangic"));
	    	degerler[1].addElement(veri.getDouble("Bitis"));
	    	durumlar.addElement(veri.getString("Durum"));
	    }
	    	veri.close();
	    	baglanti.close();
	} catch (Exception e) {
		 JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());	
		 }
}
public String durumbul(double endeks)
{   String durum="Aşırı Şişman";
	for(int i=0;i<degerler[0].size();i++)
	{
		 double bas=degerler[0].getElementAt(i),bitis=degerler[1].getElementAt(i);
		if(endeks>=bas&&endeks<=bitis)
		{
			 durum=durumlar.getElementAt(i);
			 break;
		}
	}

return durum;
}
public double virgul2(double sayi) {
	int s=(int)(sayi*100);
	sayi=s/100.0;
	return sayi;
}
public double idealkilo(double boy,String cins)
{
   double[] dgr= {45.5,2.3,60};
   double erkek=50;
   double sonuc=0;	
    if(cins.equals("Erkek"))
            dgr[0]=erkek;
    sonuc=dgr[0]+(dgr[1]*(boy/0.0254-dgr[2]));
return virgul2(sonuc);
}
public void baglan() {
	try {
		baglanti=DriverManager.getConnection("jdbc:sqlite:Vucut Endeksi.db");
	} catch (Exception e) {
	  JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());
	}
}
public void listdoldur() {

	try {
		baglan();
		  dtm.getDataVector().removeAllElements();//Table tamamen temizlemek için
		  dtm.fireTableDataChanged();
	   PreparedStatement sorgu=baglanti.prepareStatement("select ID,Ad,SoyAd,Boy,Kilo,Cinsiyet from Kisiler");
	   ResultSet veri=sorgu.executeQuery();
	   id.clear();
	   for(int i=0;i<dlm.length;i++)
		   dlm[i].clear();
	while(veri.next()) {
	   id.addElement(veri.getInt("ID"));
	   String ad=veri.getString("Ad");
	   String adsoy=veri.getString("SoyAd");
	    double boy=veri.getDouble("Boy");
	    double kilo=veri.getDouble("Kilo");
	    dlm[0].addElement(ad);
	    dlm[1].addElement(adsoy);
	    dlm[2].addElement(""+boy);
	    dlm[3].addElement(""+kilo);
	    double endeks=virgul2(kilo/((boy)*boy));
	    double idkilo=idealkilo(boy,veri.getString("Cinsiyet"));
	    String drm=durumbul(endeks);
	    String[] rows= {ad,adsoy,""+endeks,drm,""+idkilo};
	    dtm.addRow(rows);
	}
	}
	catch(Exception e)
	{
		 JOptionPane.showMessageDialog(this, "Hata="+e.getMessage());
	}
}
}

 

Cafe otomasyon

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener{
        
		JList<String>[] jlist;
        DefaultListModel<String>[] dlm;
        DefaultListModel<Integer>[] id;
        DefaultListModel<Double> fiyat;
        JTextField jtmiktar;
        JComboBox<String>[] jcb;
        String[] jlb_text= {"Masalar","Ürünler","Miktar","Fiyat","Tutar"};
        String[] btn_isim= {"Ekle","Sil","Güncelle","Adisyon","Göster"};
        Connection baglanti;
        public Calistir() {
		 this.setTitle("Cafe Otomasyon");
		 this.setSize(750, 750);
		 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 this.setLayout(new FlowLayout());
		 
		 JPanel main_jpn=new JPanel();
		 main_jpn.setPreferredSize(new Dimension(700,700));
		 main_jpn.setLayout(new FlowLayout());

		dlm=new DefaultListModel[jlb_text.length];
		jlist=new JList[dlm.length];
		jcb=new JComboBox[2];//
		id=new DefaultListModel[3];
		fiyat=new DefaultListModel<Double>();
		for(int i=0;i<dlm.length;i++)
		{    
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100,600));
			JLabel jlb=new JLabel(jlb_text[i]);
			jlb.setPreferredSize(new Dimension(100,25));
			dlm[i]=new DefaultListModel<String>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane  jscp=new JScrollPane(jlist[i]);
			jscp.setPreferredSize(new Dimension(100,350));
			JButton jbtn=new JButton(btn_isim[i]);
			jbtn.setPreferredSize(new Dimension(100,25));
			jbtn.addActionListener(this);
			jbtn.setActionCommand(btn_isim[i]);
			jpn.add(jlb);
			jpn.add(jscp);
			if(i<jcb.length)
			{   id[i]=new DefaultListModel<Integer>();
				jcb[i]=new JComboBox<String>();
				jcb[i].setPreferredSize(new Dimension(100,25));
				jpn.add(jcb[i]);
			}
			if(i==jcb.length)
			{    id[i]=new DefaultListModel<Integer>();
				jtmiktar=new JTextField();
				jtmiktar.setPreferredSize(new Dimension(100,25));
				jpn.add(jtmiktar);
			}
			if(i>jcb.length)
			{
				JPanel bosjpn=new JPanel();
				bosjpn.setPreferredSize(new Dimension(100,25));
				jpn.add(bosjpn);
			}
			jpn.add(jbtn);
			main_jpn.add(jpn);
		}
		 combodoldur();
		 listedoldur();
		 this.add(main_jpn);
		 this.setVisible(true);
	}
  public static void main(String[] arg) {
	  new Calistir();
  }
@Override
public void actionPerformed(ActionEvent arg0) {
	switch(arg0.getActionCommand()) {
	case "Ekle":ekle();break;
	case "Sil":sil();break;
	case "Güncelle":guncelle();break;
	case "Adisyon":adisyon();break;
	case "Göster":goster();break;
	}
	
}
public void ekle() {
	int secilen_masa=jcb[0].getSelectedIndex();
	int secilen_urun=jcb[1].getSelectedIndex();
	if(secilen_masa>-1&&secilen_urun>-1&&jtmiktar.getText().length()>0) {
	try {
		double miktar=Double.parseDouble(jtmiktar.getText());
		int masa_id=id[0].getElementAt(secilen_masa);
		int urun_id=id[1].getElementAt(secilen_urun);
	   	   if(baglanti.isClosed())
			  baglan();
		   PreparedStatement sorgu=baglanti.prepareStatement("insert into Adisyon(MasaID,UrunID,Miktar) values(?,?,?)");
		   sorgu.setInt(1, masa_id);
		   sorgu.setInt(2, urun_id);
		   sorgu.setDouble(3, miktar);
		   sorgu.executeUpdate();
		   baglanti.close();
		   jtmiktar.setText("");
		   jcb[0].setSelectedIndex(0);
		   jcb[1].setSelectedIndex(0);
		   listedoldur();
	}catch(Exception ex)
	{
		JOptionPane.showMessageDialog(this, ex.getMessage());
	}
	}
}
public void sil() {
	int secilen=jlist[0].getSelectedIndex();
	if(secilen>-1) {
 	try {
 		if(baglanti.isClosed())
 			baglan();
         PreparedStatement sorgu=baglanti.prepareStatement("delete from Adisyon where ID=?");
         sorgu.setInt(1, id[2].getElementAt(secilen));
         sorgu.executeUpdate();
         baglanti.close();
         listedoldur();
	}
	catch(Exception ex)
	{
		JOptionPane.showMessageDialog(this, ex.getMessage());
	}
}
}
public void guncelle() {
	int secilen=jlist[0].getSelectedIndex();
	int secilen_masa=jcb[0].getSelectedIndex();
	int secilen_urun=jcb[1].getSelectedIndex();
	if(secilen>-1&&secilen_masa>-1&&secilen_urun>-1) {
	
		try {
			double miktar=Double.parseDouble(jtmiktar.getText());
			
			if(baglanti.isClosed())
				baglan();
		    int masa_id=id[0].getElementAt(secilen_masa);
			int urun_id=id[1].getElementAt(secilen_urun);
			int adisyon_id=id[2].getElementAt(secilen);//liste adisyon idler
		    PreparedStatement sorgu=baglanti.prepareStatement("update Adisyon set MasaID=?,UrunID=?,Miktar=? where ID=?");
			sorgu.setInt(1, masa_id);
			sorgu.setInt(2, urun_id);
			sorgu.setDouble(3, miktar);
			sorgu.setInt(4, adisyon_id);
            sorgu.executeUpdate();
            baglanti.close();
            listedoldur();
            jtmiktar.setText("");
		}
		catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
		}
	}	
}
public void adisyon() {
	 int secilen=jcb[0].getSelectedIndex();
		if(secilen>-1) {
		try {
			if(baglanti.isClosed())
				baglan();
	       PreparedStatement sorgu=baglanti.prepareStatement("delete from Adisyon where MasaID=?");
		   sorgu.setInt(1, id[0].getElementAt(secilen));
		   sorgu.executeUpdate();
		   baglanti.close();
		  listedoldur();
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	    
		}
    }
public void goster() {
	 int secilen=jcb[0].getSelectedIndex();
		if(secilen>-1) {
		try {
			if(baglanti.isClosed())
				baglan();
	       PreparedStatement sorgu=baglanti.prepareStatement("select u.UrunAd as 'UrunAd',(u.UrunFiyat*a.Miktar) as 'Tutar' from Adisyon a inner join Urunler u  on u.ID=a.UrunID where a.MasaID=?");
		   sorgu.setInt(1, id[0].getElementAt(secilen));
		   int sayac=0;
		   ResultSet veri=sorgu.executeQuery();
		  String urunler="";
		  double tutar=0.0;
		   while(veri.next())
		   {
			   if(urunler.length()>0)
				   urunler+=",";
			   urunler+=veri.getString("UrunAd");
			   tutar+=veri.getDouble("Tutar");
		   sayac++;
		   }
		   veri.close();
		   baglanti.close();
		   JOptionPane.showMessageDialog(this,"Ürün Sayısı="+sayac+" "+urunler+" Toplam Tutar="+tutar);
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());	
			}
		}
}
public void baglan(){
 
	try {
	baglanti=DriverManager.getConnection("jdbc:sqlite:otomasyon.db");
} catch (Exception e) {
	JOptionPane.showMessageDialog(this, e.getMessage());
}	
}
public void combodoldur(){
	PreparedStatement sorgu=null;
	ResultSet veri=null;
try {
	baglan();
	sorgu=baglanti.prepareStatement("select ID,UrunAd,UrunFiyat from Urunler");
	veri=sorgu.executeQuery();
    for(int i=0;i<jcb.length;i++)
    {
    	jcb[i].removeAllItems();
    	id[i].clear();
    }
     fiyat=new DefaultListModel<Double>();
	while(veri.next())
	{
	     jcb[1].addItem(veri.getString("UrunAd"));	
	     id[1].addElement(veri.getInt("ID"));
	     fiyat.addElement(veri.getDouble("UrunFiyat"));
	}
     veri.close();
     sorgu=baglanti.prepareStatement("select ID,MasaAdi from Masalar");
     veri=sorgu.executeQuery();
     while(veri.next())
     {
    	 jcb[0].addItem(veri.getString("MasaAdi"));
    	 id[0].addElement(veri.getInt("ID"));
     }
} catch (Exception e) {
	JOptionPane.showMessageDialog(this, e.getMessage());
}
}
public void listedoldur() {
	try {
		baglan();
		String sql="select a.ID as 'ID',m.MasaAdi as 'MasaAdi',u.UrunAd as 'UrunAd',a.Miktar as 'Miktar',u.UrunFiyat as 'Fiyat',u.UrunFiyat*a.Miktar as 'Tutar'  from Masalar m inner join Adisyon  a on m.ID=a.MasaID inner join Urunler u on u.ID=a.UrunID"; 
		PreparedStatement sorgu=baglanti.prepareStatement(sql);
		for(int i=0;i<dlm.length;i++)
			dlm[i].clear();
		id[2].clear();
		ResultSet veri=sorgu.executeQuery();
		while(veri.next())
		{   id[2].addElement(veri.getInt("ID"));
			dlm[0].addElement(veri.getString("MasaAdi"));
			dlm[1].addElement(veri.getString("UrunAd"));
			double miktar=veri.getDouble("Miktar");
			dlm[2].addElement(miktar+"");
			double fiyat=veri.getDouble("Fiyat");
			dlm[3].addElement(fiyat+"");	
			double tutar=fiyat*miktar;
			dlm[4].addElement(""+tutar);
		}
		veri.close();
		baglanti.close();
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this, e.getMessage());
	}
	
}
@Override
public void valueChanged(ListSelectionEvent e) {
	JList secilen=(JList)e.getSource();
	for(int i=0;i<jlist.length;i++)
		 jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	
}
}

 

Su İhtiyac Hesaplama

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class Calistir extends JFrame implements ActionListener, ListSelectionListener {
      String[] jlbl= {"Ad","SoyAd","Kilo","Günlük Su İhtiyacı"};
	  DefaultListModel<String>[] dlm;
	  DefaultListModel<Integer> dlm_id;
	  JList<String>[] jlist;
 	  JTextField[] jtext;
 	  JTextField[] jtext_gun;
 	  JPanel main_jpn;
	  JButton jbtn;
	  String[] btn_text= {"Ekle","Sil","Güncelle"};
	  Connection baglanti=null;
	  JFrame gun_frm;
	  public Calistir() {
		this.setTitle("Su İhtiyacı Hesaplama");
		this.setSize(450, 450);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLayout(new FlowLayout());
		
		dlm=new DefaultListModel[jlbl.length];
		jlist=new JList[dlm.length];
		dlm_id=new DefaultListModel<Integer>();
		jtext=new JTextField[dlm.length-1];
		main_jpn=new JPanel();
		main_jpn.setPreferredSize(new Dimension(450,450));
		for(int i=0;i<dlm.length;i++)
		{
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100,450));
			jpn.setLayout(new FlowLayout());
		    JLabel jlab=new JLabel(jlbl[i]);
		    jlab.setPreferredSize(new Dimension(100,20));
			dlm[i]=new DefaultListModel<String>();
		    jlist[i]=new JList<String>(dlm[i]);
		    jlist[i].addListSelectionListener(this);
           JScrollPane jscp=new JScrollPane(jlist[i]);
           jscp.setPreferredSize(new Dimension(100,300));
           jpn.add(jlab);
           jpn.add(jscp);
            if(i<jtext.length)
            {
            	jtext[i]=new JTextField();
            	jtext[i].setPreferredSize(new Dimension(100,25));
            	jbtn=new JButton(btn_text[i]);
            	jbtn.setPreferredSize(new Dimension(100,25));
            	jbtn.addActionListener(this);
            	jbtn.setActionCommand(btn_text[i]);
            	jpn.add(jtext[i]);
            	jpn.add(jbtn);
            }
           main_jpn.add(jpn);
		}
		verigetir();
		this.add(main_jpn);
		this.setVisible(true);
	}

	@Override
	public void valueChanged(ListSelectionEvent arg0) {//Herhangi jlistler tıklanırsa tıklansın bu fonksiyon çalısır
		  JList jsecilen=(JList)arg0.getSource();
		  for(int i=0;i<jlist.length;i++)
			  jlist[i].setSelectedIndex(jsecilen.getSelectedIndex());
	}
	@Override
	public void actionPerformed(ActionEvent arg0) {
        int secilen=jlist[0].getSelectedIndex();
		switch(arg0.getActionCommand())
		{
		case "Ekle":Ekle();break; 
		case "Sil":Sil();break; 
		case "Güncelle":Guncelle();break; 
		case "guncelle":guncelle(secilen);break;
		case "cıkıs":cıkıs();break;
		}
	}
	public double sayicevir(String s)
	{   
		double sayi=-1;
		try {
			sayi=Double.parseDouble(s);
			return sayi;
		}catch(Exception ex)
		{
			return sayi;
		}	
	}
	public boolean dogrula(JTextField[] txt)
	{
		int sayac=0;
		for(int i=0;i<txt.length;i++)
			if(txt[i].getText().length()>0)
				  sayac++;
		  if(sayac==txt.length)
			  return true;
	         
	return false;
		  }
public void Ekle() {
	double kilo=sayicevir(jtext[2].getText());
	if(dogrula(jtext)&&kilo!=-1) {
		 double ihtiyac=0.032*kilo;
		    int ihtiyac1=(int)(ihtiyac*100);
		    ihtiyac=ihtiyac1/100.0;
		try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("insert into Sahıslar(S_Ad,S_SoyAd,S_Kilo,S_Suihtiyac) values(?,?,?,?)");
			sorgu.setString(1, jtext[0].getText());
			sorgu.setString(2, jtext[1].getText());
			sorgu.setDouble(3, kilo);
			sorgu.setDouble(4, ihtiyac);
			sorgu.executeUpdate();
			baglanti.close();
			for(int i=0;i<jtext.length;i++)
				    jtext[i].setText("");
			verigetir();
		}catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
		}
	}
}
public void Sil() {
 int secilen=jlist[0].getSelectedIndex();
 if(secilen>-1)
 {
	 try {
		 baglan();
		 PreparedStatement sorgu=baglanti.prepareStatement("delete from Sahıslar where S_No=?");
		 sorgu.setInt(1, dlm_id.getElementAt(secilen)); 
		 sorgu.executeUpdate();
		 baglanti.close();
		 verigetir();
	 }
	 catch(Exception ex)
	 {
		 JOptionPane.showMessageDialog(this, ex.getMessage());
	 }
 }
	
}	
public void Guncelle() {
 int secilen=jlist[0].getSelectedIndex();
 
	if(secilen>-1)
	{   
		this.setVisible(false);
		gun_frm(dlm,secilen);	
	}
}
public void guncelle(int secilen)
{   double kilo=sayicevir(jtext_gun[2].getText());
	if(dogrula(jtext_gun)&&kilo!=-1&&secilen>-1)
	{
		try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("update Sahıslar set S_Ad=?,S_SoyAd=?,S_Kilo=?,S_Suihtiyac=? where S_No=?");
			sorgu.setString(1, jtext_gun[0].getText());
			sorgu.setString(2, jtext_gun[1].getText());
			sorgu.setDouble(3, kilo);
			double ihtiyac=0.032*kilo;
			int ihtiyac1=(int)(ihtiyac*100);//Virgulden sonra iki basamak alamak için
            sorgu.setDouble(4,ihtiyac1/100.0);
            sorgu.setInt(5, dlm_id.getElementAt(secilen));
            sorgu.executeUpdate();
            baglanti.close();
            verigetir();//buraya kadar hersey yapılırsa jlistleri dolduruyorum
            this.setVisible(true);//Ana formun visible 'nı true(görünür) yapıyorum
            gun_frm.dispose();//ve gun_frm formun yok ediyorum
		}catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
			
		}
		
	}
}
public void cıkıs() {
	this.setVisible(true);
	gun_frm.dispose();
}
public void baglan() {
	
	try {
       Class.forName("org.sqlite.JDBC");
	 baglanti=DriverManager.getConnection("jdbc:sqlite:Suihtiyac.db");	
   }
	catch(Exception ex){
	
		JOptionPane.showMessageDialog(this, ex.getMessage());
}
}
public void verigetir()
{
   try {
	   baglan();
	   Statement sorgu=baglanti.createStatement();
	   ResultSet veri=sorgu.executeQuery("select S_No,S_Ad,S_SoyAd,S_Kilo,S_Suihtiyac from Sahıslar");
	   for(int i=0;i<dlm.length;i++)
		   dlm[i].clear();
	   dlm_id.clear();
	   while(veri.next())
	   {
		   dlm_id.addElement(veri.getInt("S_No"));
		   dlm[0].addElement(veri.getString("S_Ad"));
		   dlm[1].addElement(veri.getString("S_SoyAd"));
		   dlm[2].addElement(veri.getDouble("S_Kilo")+"");
		   dlm[3].addElement(veri.getDouble("S_Suihtiyac")+" Lt"); 
	   }
	   veri.close();
	   baglanti.close();
	   
   }catch(Exception ex)	{
	   
	   JOptionPane.showMessageDialog(this, ex.getMessage());
   }

}
public void gun_frm(DefaultListModel<String>[] dlm,int secilen)
{
    gun_frm=new JFrame("Güncelle");
	gun_frm.setSize(250,200);
	gun_frm.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//X simgesine basıldığında hiç bir sey yapama
	gun_frm.setLayout(new FlowLayout());
    
	JPanel ana_jpn=new JPanel();
	JPanel jpn_lbl=new JPanel();
	JPanel jpn_jtext=new JPanel();
	ana_jpn.setPreferredSize(new Dimension(250,200));
	jpn_lbl.setPreferredSize(new Dimension(40,130));
	jpn_jtext.setPreferredSize(new Dimension(100,130));
	
	jtext_gun=new JTextField[jtext.length];
	for(int i=0;i<jtext_gun.length;i++)
	{
		jtext_gun[i]=new JTextField();
		jtext_gun[i].setPreferredSize(new Dimension(100,20));
	    JLabel jlb_gun= new JLabel(jlbl[i]+":");
	    jlb_gun.setPreferredSize(new Dimension(40,20));
	    jlb_gun.setHorizontalAlignment(JLabel.RIGHT);
	    jpn_lbl.add(jlb_gun);
	    jpn_jtext.add(jtext_gun[i]);
	    jtext_gun[i].setText(dlm[i].getElementAt(secilen));
	}
	jbtn=new JButton("Güncelle");
	jbtn.setPreferredSize(new Dimension(100,20));
	jbtn.addActionListener(this);
	jbtn.setActionCommand("guncelle");
	jpn_jtext.add(jbtn);
	jbtn=new JButton("Çık");
	jbtn.setPreferredSize(new Dimension(100,20));
	jbtn.addActionListener(this);
	jbtn.setActionCommand("cıkıs");
	jpn_jtext.add(jbtn);
	ana_jpn.add(jpn_lbl);
	ana_jpn.add(jpn_jtext);
	gun_frm.add(ana_jpn);
	gun_frm.setVisible(true);	
}
public static void main(String[] args) {
		new Calistir();
	}
}

 

Sqlite browser burdan indirin
Sql jdbc burdan indirin
Sqlite Örneğini indir

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;//Veri tabanına Bağlantı yapmak için kullandığımız kütüphane 

public class Calistir  implements ActionListener,ListSelectionListener {
	
	JTextField[] jtext_gun;
	 JLabel[] jlb;
	 String[] lbltitle= {"Ad:","SoyAd:","Yas:"};
	 JButton jbtn_gun;
	 JPanel jpn_gun,jpnlb_gun;
	 int yas_gun=-1; 
     JFrame frm,frmgun;
	 JList jlist[],jlistyas;
	 DefaultListModel<String> dlm[];
	 DefaultListModel<Integer> dlmyas,dlmidler;
	 JTextField[] jtext;
	 String[] jbtntitle= {"Ekle","Sil","Güncelle"};
	 JButton[] jbtn;
	 JPanel jpn[],jpnyas;
	 JScrollPane scjpn[],scjpnyas;
	 public Calistir() {
       frm=new JFrame("Sqlite Bağlanti");
       frm.setSize(400, 500);
       frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frm.setLayout(new FlowLayout());
       
       jpn=new JPanel[2];
       dlm=new DefaultListModel[jpn.length];
       dlmidler=new DefaultListModel<Integer>();
       jlist=new JList[dlm.length];
       scjpn=new JScrollPane[jlist.length];
       jbtn=new JButton[3];
       jtext=new JTextField[3];
       
       for(int i=0;i<jpn.length;i++)
       {
    	   jpn[i]=new JPanel();
    	   jpn[i].setPreferredSize(new Dimension(100,400));
    	   jpn[i].setLayout(new FlowLayout());
    	   dlm[i]=new DefaultListModel<String>();
    	   jlist[i]=new JList<String>(dlm[i]);
    	   jlist[i].addListSelectionListener(this);
    	   scjpn[i]=new JScrollPane(jlist[i]);
    	   scjpn[i].setPreferredSize(new Dimension(100,300));
    	   jpn[i].add(scjpn[i]);
    	   frm.add(jpn[i]);   
       }
    	  jpnyas=new JPanel();
    	  jpnyas.setPreferredSize(new Dimension(100,400));
    	  jpnyas.setLayout(new FlowLayout());
   	      dlmyas=new DefaultListModel<Integer>();
   	      jlistyas=new JList<Integer>(dlmyas);
   	      jlistyas.addListSelectionListener(this);
   	      scjpnyas=new JScrollPane(jlistyas);
   	      scjpnyas.setPreferredSize(new Dimension(100,300));
   	      jpnyas.add(scjpnyas);
   	     
   	      for(int i=0;i<jpn.length;i++)//JButtonlar ve JTextField lar oluşturulup panele atılıyor 
   	      {   jtext[i]=new JTextField();
   	          jtext[i].setPreferredSize(new Dimension(100,20));
   	    	  jbtn[i]=new JButton(jbtntitle[i]);
   	    	  jbtn[i].setPreferredSize(new Dimension(100,20));
   	    	  jbtn[i].addActionListener(this);
   	    	  jbtn[i].setActionCommand(jbtntitle[i]);
   	    	  jpn[i].add(jtext[i]);
   	    	  jpn[i].add(jbtn[i]);
   	    	  if(i==jpn.length-1)
   	    	  { 
   	          jtext[2]=new JTextField();
   	          jtext[2].setPreferredSize(new Dimension(100,20));
   	    	  jbtn[2]=new JButton(jbtntitle[2]);
   	    	  jbtn[2].setPreferredSize(new Dimension(100,20));
   	    	  jbtn[2].addActionListener(this);
   	    	  jbtn[2].setActionCommand(jbtntitle[2]);
   	    	  jpnyas.add(jtext[2]);
   	    	  jpnyas.add(jbtn[2]);
   	    	  }
   	      }
   	   frm.add(jpnyas); 
   	   verigetir();
       frm.setVisible(true);
	}
	 public void  KGuncelle(int secilen)
		{   frm.setVisible(false);
			frmgun=new JFrame("Kişi Güncelle");
			frmgun.setSize(300, 300);
			frmgun.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
			frmgun.setLayout(new FlowLayout());
	
			jpn_gun=new JPanel();
			jpn_gun.setPreferredSize(new Dimension(100,150));
			jpn_gun.setLayout(new FlowLayout());
			
			jpnlb_gun=new JPanel();
			jpnlb_gun.setPreferredSize(new Dimension(40,150));
			jpnlb_gun.setLayout(new FlowLayout());
			
			
			jlb=new JLabel[3];
			jtext_gun=new JTextField[jlb.length];
			
			for(int i=0;i<lbltitle.length;i++)
			{
				jlb[i]=new JLabel(lbltitle[i]);
				jlb[i].setPreferredSize(new Dimension(40,20)); 
				jlb[i].setHorizontalAlignment(JLabel.RIGHT);
			    jtext_gun[i]=new JTextField();
			    jtext_gun[i].setPreferredSize(new Dimension(100,20));
			    jpnlb_gun.add(jlb[i]);
			    jpn_gun.add(jtext_gun[i]);	
			}
			for(int i=0;i<dlm.length;i++)
			     jtext_gun[i].setText(dlm[i].getElementAt(secilen));
			     jtext_gun[2].setText(dlmyas.getElementAt(secilen).toString());
			     
			
			jbtn_gun=new JButton("Kaydet");
			jbtn_gun.setPreferredSize(new Dimension(100,20));
			jbtn_gun.addActionListener(this);
			jbtn_gun.setActionCommand("Kaydet");
			jpn_gun.add(jbtn_gun);
			frmgun.add(jpnlb_gun);
			frmgun.add(jpn_gun);
			frmgun.setVisible(true);
		}
		
	public static void main(String[] args) {
		
        new Calistir();
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
	    int yas=sayicevir(jtext[2].getText());
	    int secilen=jlist[0].getSelectedIndex();
		if(arg0.getActionCommand().equals("Ekle")&&jtext_kontrol(jtext)&&yas!=-1)
		{
			for(int i=0;i<dlm.length;i++)
			      dlm[i].addElement(jtext[i].getText());
			dlmyas.addElement(yas);
			
			ekle(jtext,yas);//Fonskiyonu çağrıyorum eklemesi için
			for(int i=0;i<jtext.length;i++)
				jtext[i].setText("");
		  verigetir();
		}
		else if(arg0.getActionCommand().equals("Sil")&&secilen>-1) {
			sil(dlm,secilen);
			for(int i=0;i<dlm.length;i++)
	    		     dlm[i].removeElementAt(secilen);
		           dlmyas.removeElementAt(secilen);	
		}
		else if(arg0.getActionCommand().equals("Güncelle")&&secilen>-1){
               frm.setVisible(false);// Bu formu gizle
              KGuncelle(secilen);//guncelle fromunu aç
			   }
			   else if(arg0.getActionCommand().equals("Kaydet")&&jtext_kontrol(jtext_gun))
			   {  
				   yas_gun=sayicevir(jtext_gun[2].getText());
				   if(yas_gun!=-1)
				   {  
			          frm.setVisible(true);//Eğer girilen bilgiler doğruysa frm göster
			          frmgun.dispose();//guncelle formunu yoket
			      for(int i=0;i<dlm.length;i++)
				      dlm[i].removeElementAt(secilen);
			          dlmyas.removeElementAt(secilen);   
			          dlm[0].insertElementAt(jtext_gun[0].getText(),secilen);
			          dlm[1].insertElementAt(jtext_gun[1].getText(),secilen);
			          dlmyas.insertElementAt(yas_gun,secilen);
				   guncelle(secilen);
				   verigetir(); 				
				   }
			    }
}
	 public boolean jtext_kontrol(JTextField[] jtxt)
	{
		 boolean durum=true;
		 for(int i=0;i<jtxt.length;i++)
		 {
			 if(jtxt[i].getText().length()==0)
			 {
				 durum=false;
				 break;
			 }
		 }
   return durum;  
	}
  public int sayicevir(String s)
   {  int yas=0;
     
      try {
    	  yas=Integer.parseInt(s);
      }catch(Exception ex)
      {
    	  yas=-1;
      }
   return yas;	   
   }
	@Override
	public void valueChanged(ListSelectionEvent arg0) {
	    JList secilen=(JList)arg0.getSource();
	    for(int i=0;i<jlist.length;i++)
	    	  jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	    jlistyas.setSelectedIndex(secilen.getSelectedIndex());
	}
//Veri Tabanı İşlemleri
Connection baglanti=null;
public void baglan()
{
     try {
    	 Class.forName("org.sqlite.JDBC");//Sql sınıfının hızlı yüklenmesi için
    	 baglanti=DriverManager.getConnection("jdbc:sqlite:Deneme.db");
     }catch(Exception ex)
     {
    	 JOptionPane.showMessageDialog(frm, "Hata="+ex.getMessage());//Bağlantıda hata olursa mesagebox' ta gösteriyoruz
     }
}
public void verigetir()
{    baglan();
    try {
    	Statement sorgu=baglanti.createStatement();//Yeni sorgu oluşturuyoruz
    	ResultSet veri=sorgu.executeQuery("select * from Kisiler");
        for(int i=0;i<dlm.length;i++)
        	dlm[i].clear();
            dlmyas.clear();
            dlmidler.clear();
    	while(veri.next())
    	{
    		dlm[0].addElement(veri.getString("Ad"));
    		dlm[1].addElement(veri.getString("SoyAd"));
    		dlmyas.addElement(veri.getInt("Yas"));
    		dlmidler.addElement(veri.getInt("KNO"));
    	}
    	veri.close();//Okuyucuyu kapatıyoruz
    	baglanti.close();//bağlantıyı kapatıyoruz
    }catch(Exception ex)
    {
    	JOptionPane.showMessageDialog(frm, "Hata="+ex.getMessage());
    }
}
public void ekle(JTextField[] jtxt,int yas)
{    baglan();//Veri tabanına bağlanıyoruz
   try {
	   PreparedStatement sorgu=baglanti.prepareStatement("insert into Kisiler(Ad,SoyAd,Yas) values(?,?,?)");
		sorgu.setString(1, jtxt[0].getText());//Paremetre ekliyoruz tip neyse ona göre
		sorgu.setString(2, jtxt[1].getText());
		sorgu.setInt(3, yas);
		sorgu.executeUpdate();
		baglanti.close();
   }catch(Exception ex)
   {
	   JOptionPane.showMessageDialog(frm, "Hata="+ex.getMessage()); 
   }
}
public void sil(DefaultListModel<String>[] dlmsil,int secilen)
{
	  baglan();//Veri tabanına bağlanıyoruz
	   try {
		  PreparedStatement sorgu=baglanti.prepareStatement("delete from Kisiler where Ad=? and SoyAd=?");
	      sorgu.setString(1,dlmsil[0].getElementAt(secilen));//Jlist secilen eleman silinecek
	      sorgu.setString(2,dlmsil[1].getElementAt(secilen));
	      sorgu.executeUpdate();//Sorguyu çalıştırıyoruz
	      baglanti.close();
	   }catch(Exception ex)
	   {
		   JOptionPane.showMessageDialog(frm, "Hata="+ex.getMessage()); 
	   }
}
public void guncelle(int secilen)
{      baglan();
	try {
		PreparedStatement sorgu=baglanti.prepareStatement("update Kisiler set Ad=?,SoyAd=?,Yas=? where KNO=?");
		sorgu.setString(1,jtext_gun[0].getText());
		sorgu.setString(2, jtext_gun[1].getText());
		sorgu.setInt(3, yas_gun);
		sorgu.setInt(4,dlmidler.getElementAt(secilen));
		sorgu.executeUpdate();
		baglanti.close();

	}catch(Exception ex)
	{
		JOptionPane.showMessageDialog(frm, "Hata="+ex.getMessage()); 
	}
}
}