//====================================================== 
// Kondenser modellemesi
// Dr. Turhan Coban
// EGE Üniversitesi Mühendislik Fakultesi, Makina Bölümü
// turhan.coban@ege.edu.tr
// =====================================================
// Bu model Türkoğlu için geliştirilmiştir 
import java.lang.Integer;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.Locale;
import java.text.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.table.*;

public class secondarycoolantTable extends JApplet implements ItemListener,ActionListener
{
  Container c;
  Color bg;
  JTabbedPane tabPane = new JTabbedPane();
  final static String say1 = "ikincil soğutkan termofiziksel özellikleri";

  final static String say3 = " ";
  final static String say4 = " ";
  JPanel panel1;
  //JPanel panel2;
  //JPanel panel3;
  //JPanel panel4;
  JPanel girisPaneli;
  JScrollPane cikisPaneli; 
  JLabel     l1[]=new JLabel[3];            //  Label prompt unit
  JLabel     l2[]=new JLabel[3];            //  Label prompt unit
  JTextField t1[]=new JTextField[3];
  JComboBox  c1[]=new JComboBox[3];
  JTextArea  output;
  JTable jt;
  //jt.setFont(16);
  secondarycoolantModel scmodel;
  double aa[]=new double[10]; 
  String s1[];
  String s2[];
  String s3[];
  Icon turkoglu_logo;
  JButton b1;
  double ts;    // yoğuşma sıcaklığı
  double xs;
  String sogutmaakiskani;
  double xi;	
    public void init()
    { 
	    ts=25.0;
	    xi=0.0;
	    sogutmaakiskani="su";
	    scmodel=new secondarycoolantModel(); 
	    s1=scmodel.g.liste();        
        c = getContentPane();
        panel1 = new JPanel();
        panel1.setBackground(c.getBackground()); 
        JPanel pane1 = new JPanel()
        {
        public Dimension getPrefferedSize()
        {
            Dimension size=super.getPreferredSize();
            size.width=600;
            return size;
        }
        };

      //==========================
      //pencereleri içeriği
      turkoglu_logo=new ImageIcon("turkoglu_logo.jpg");
      b1=new JButton(turkoglu_logo);
      output=new JTextArea(toString());
      output.setBackground(bg);
      l1[0]=new JLabel("ikincil soğutkan ");
      l1[1]=new JLabel("ikincil soğutkan sıcaklığı");
      l1[2]=new JLabel("ikincil soğutkan karışım miktarı ");

      l2[0]=new JLabel(" ");
      l2[1]=new JLabel(" derece C");
      l2[2]=new JLabel("   ");

      c1[0]=new JComboBox(s1);
      t1[0]=new JTextField(""+ts);
      t1[1]=new JTextField(""+xi);
      jt=new JTable(scmodel);
      jt.setBackground(bg);
      girisPaneli=new JPanel();
      girisPaneli.setLayout(new GridLayout(3,3));
      cikisPaneli=new JScrollPane(jt);
      pane1.setLayout(new BorderLayout());
      //soğutucu akışkan
      girisPaneli.add(l1[0]);
      girisPaneli.add(c1[0]);
      girisPaneli.add(l2[0]);
      //ikincil akışkan 
      girisPaneli.add(l1[1]);
      girisPaneli.add(t1[0]);
      girisPaneli.add(l2[1]);
      //ikincil akışkan su karışım miktarı
      girisPaneli.add(l1[2]);
      girisPaneli.add(t1[1]);
      girisPaneli.add(l2[2]);
 
    t1[0].setBackground(bg);
    t1[1].setBackground(bg);
    
    c1[0].addItemListener(this);

    t1[0].addActionListener(this);
    t1[1].addActionListener(this);
    
    panel1.add(girisPaneli,BorderLayout.NORTH);   
    //cikisPaneli.add(jt,BorderLayout.NORTH);
    panel1.add(cikisPaneli,BorderLayout.SOUTH);  
    
      //==========================  
      tabPane.addTab(say1,panel1);
      c.add(tabPane);    
    }

    public void itemStateChanged(ItemEvent e)
    { Double V0=new Double(t1[0].getText());
      ts=V0.doubleValue();
      Double V1=new Double(t1[1].getText());
      xi=V1.doubleValue();  
	  sogutmaakiskani=(String)c1[0].getSelectedItem();
	  scmodel.setValues(sogutmaakiskani,ts,xi);
	  repaint();
    }
    
    public void actionPerformed(ActionEvent e)
    {
    Double V0=new Double(t1[0].getText());
      ts=V0.doubleValue();
      Double V1=new Double(t1[1].getText());
      xi=V1.doubleValue();  
	  sogutmaakiskani=(String)c1[0].getSelectedItem();
	  scmodel.setValues(sogutmaakiskani,ts,xi);
	  repaint();
   } 


                
    public static void main(String s[])
    {
        //main program
	    JFrame f = new JFrame("ikincil soğutkan termofiziksel özellikleri");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new secondarycoolantTable();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(1000,800));
        f.setVisible(true);
    }    
 }

