// ====================================================== // Thermodynamics package in java // steamTable class to calculate properties of steam // user interface (JApplet) // Dr. Turhan Coban // Ege Üniversitesi Mühendislik fakultesi Makina bölümü // email : Turhan.Coban@ege.edu.tr // File Name : sogut1Table.java // requires : sogut1.java, sogut1Model.java // ===================================================== import java.io.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.table.*; public class sogut1Table extends JApplet implements ActionListener,ItemListener { JPanel inputPanel; JPanel outputPanel; JPanel totalPanel; JLabel l1[]=new JLabel[5]; // Label prompt unit JLabel l2[]=new JLabel[5]; // Label prompt unit JTextField t1[]=new JTextField[4]; // Input field JComboBox c1[]=new JComboBox[3]; // Selection field JTextArea output; JTable jt; sogut1Model sm; sogut1 st; //static final long serialVersionUID = -5240653397607159099L; public String unit; public String pair; public String gas; public double v1; public double v2; protected StringTokenizer token; String s1[]={"SI","EN"}; String s2[]={"tx","tp","tv","th","tu","ts","pv","pt","ph","pu","ps","px","vp","vt"}; String s3[]; Container c; Color bg; String ss[]; public void init() { unit="SI"; pair="tx"; c=getContentPane(); c.setLayout(new FlowLayout()); bg=c.getBackground(); //adding max-min prompts and input fields gas="R22"; st=new sogut1(gas); token=new StringTokenizer(st.readGasNames()); s3=new String[token.countTokens()]; int i=0; while(token.hasMoreTokens()) { s3[i++]=new String((String)token.nextToken()); } v1=0.0; v2=1.0; st.setUnit(unit); sm=new sogut1Model(gas,unit,pair,v1,v2); inputPanel=new JPanel(); inputPanel.setLayout(new GridLayout(5,3)); outputPanel=new JPanel(); outputPanel.setLayout(new BorderLayout()); totalPanel=new JPanel(); totalPanel.setLayout(new BorderLayout()); l1[0]=new JLabel("birim"); l1[1]=new JLabel("bilinen termodinamik çifti seçiniz : "); l1[2]=new JLabel(" Sıcaklık"); l1[3]=new JLabel(" Kuruluk der."); l1[4]=new JLabel("Soğutucu akışkanın ismi"); l2[0]=new JLabel(""); l2[1]=new JLabel(""); l2[2]=new JLabel(" derece C"); l2[3]=new JLabel(" kg buh/kg kar."); l2[4]=new JLabel(); l2[4].setText(st.rd.openName); c1[0]=new JComboBox(s1); c1[1]=new JComboBox(s2); c1[2]=new JComboBox(s3); t1[0]=new JTextField(""+v1); t1[1]=new JTextField(""+v2); t1[2] = new JTextField(); t1[2].setText(pair); t1[3]=new JTextField(); t1[3].setText(gas); inputPanel.add(l1[0]); inputPanel.add(c1[0]); inputPanel.add(l2[4]); inputPanel.add(l1[4]); inputPanel.add(c1[2]); inputPanel.add(t1[3]); inputPanel.add(l1[1]); inputPanel.add(c1[1]); inputPanel.add(t1[2]); inputPanel.add(l1[2]); inputPanel.add(t1[0]); inputPanel.add(l2[2]); inputPanel.add(l1[3]); inputPanel.add(t1[1]); inputPanel.add(l2[3]); t1[0].setBackground(bg); t1[1].setBackground(bg); t1[2].setBackground(bg); t1[3].setBackground(bg); t1[0].setFont(l1[0].getFont()); t1[1].setFont(l1[0].getFont()); t1[2].setFont(l1[0].getFont()); t1[3].setFont(l1[0].getFont()); c1[0].setBackground(bg); c1[1].setBackground(bg); c1[2].setBackground(bg); c1[0].addItemListener(this); c1[1].addItemListener(this); c1[2].addItemListener(this); t1[0].addActionListener(this); t1[1].addActionListener(this); t1[2].addActionListener(this); t1[3].addActionListener(this); output=new JTextArea(); setArea(); jt=new JTable(sm); jt.setBackground(bg); jt.setFont(l1[0].getFont()); output.setFont(l1[0].getFont()); output.setForeground(l1[0].getForeground()); outputPanel.add(output,BorderLayout.NORTH); outputPanel.add(jt,BorderLayout.SOUTH); totalPanel.add(inputPanel,BorderLayout.NORTH); totalPanel.add(outputPanel,BorderLayout.SOUTH); c.add(totalPanel,BorderLayout.NORTH); } public void setArea() { String s=""; s+="Dr. Turhan Çoban, \n"; s+="Ege Universitesi, Mühendislik fakultesi\n"; s+="Makina Mühendisliği\n"; s+="elmek : turhan.coban@ege.edu.tr\n"; s+="Japon Soğutma enstitüsü Hal Denklemi (referans :ASHRAE Thermodynamic Properties of Refrigerant)\n"; //s+=r1.rd.toString(); output.setText(s); sm.setValues(gas,unit,pair,v1,v2); output.setBackground(c.getBackground()); } public void itemStateChanged(ItemEvent ev) { unit=(String)c1[0].getSelectedItem(); pair=(String)c1[1].getSelectedItem(); t1[2].setText(pair); gas=(String)c1[2].getSelectedItem(); t1[3].setText(gas); //st=new ref(gas); sm.setValues(gas,unit,pair,v1,v2); //sm=new refModel(gas,unit,pair,v1,v2); l2[4].setText(st.rd.openName); if(pair.charAt(0)=='t') l1[2].setText(" Sıcaklık "); if(pair.charAt(0)=='p') l1[2].setText(" Basınç "); if(pair.charAt(0)=='v') l1[2].setText(" öz. hacim "); if(pair.charAt(1)=='t') l1[3].setText(" Sıcaklık "); if(pair.charAt(1)=='p') l1[3].setText(" Basınç "); if(pair.charAt(1)=='v') l1[3].setText(" öz. hacim "); if(pair.charAt(1)=='h') l1[3].setText(" Entalpi "); if(pair.charAt(1)=='u') l1[3].setText(" İç enerji "); if(pair.charAt(1)=='s') l1[3].setText(" Entropi "); if(pair.charAt(1)=='x') l1[3].setText(" kuruluk der."); if(unit.equals("SI")) { if(pair.charAt(0)=='t') l2[2].setText(" derece C"); if(pair.charAt(0)=='p') l2[2].setText(" kPa"); if(pair.charAt(0)=='v') l2[2].setText(" m^3/kg"); if(pair.charAt(1)=='t') l2[3].setText(" degree C"); if(pair.charAt(1)=='p') l2[3].setText(" kPa"); if(pair.charAt(1)=='v') l2[3].setText(" m^3/kg"); if(pair.charAt(1)=='h') l2[3].setText(" KJ/kg"); if(pair.charAt(1)=='u') l2[3].setText(" KJ/kg"); if(pair.charAt(1)=='s') l2[3].setText(" KJ/kg K"); if(pair.charAt(1)=='x') l2[3].setText(" kg buhar/kg karışım"); } else { if(pair.charAt(0)=='t') l2[2].setText(" derece F"); if(pair.charAt(0)=='p') l2[2].setText(" lbf/in^2"); if(pair.charAt(0)=='v') l2[2].setText(" ft^3/lbm"); if(pair.charAt(1)=='t') l2[3].setText(" degree F"); if(pair.charAt(1)=='p') l2[3].setText(" lbf/in^2"); if(pair.charAt(1)=='v') l2[3].setText(" ft^3/lbm"); if(pair.charAt(1)=='h') l2[3].setText(" BTU/lbm"); if(pair.charAt(1)=='u') l2[3].setText(" BTU/lbm"); if(pair.charAt(1)=='s') l2[3].setText(" BTU/lbm R"); if(pair.charAt(1)=='x') l2[3].setText(" lbm buhar/lbm karışım"); } t1[1].setText(""); t1[0].setText(""); repaint(); } public void actionPerformed( ActionEvent e) { if(e.getSource()==t1[2]) { String st1=(String)c1[1].getSelectedItem(); pair=st1; String st2=t1[2].getText(); for(int j=0;j