import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.math.*;
/**
*
* pH-Wert Berechner
*/
public class phwertberechner extends JApplet
{
// Anfang Attribute
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private JLabel jLabel3 = new JLabel();
private JLabel jLabel4 = new JLabel();
private JButton jButton1 = new JButton();
private JLabel jLabel5 = new JLabel();
JComboBox c1 = new JComboBox();
public static final String s00 =
"Lösungsart auswählen";
public static final String s0 =
"Säure";
public static final String s01 =
"Base";
JComboBox c2 = new JComboBox();
public static final String s0000 =
"Säure auswählen";
public static final String s000 =
"Base auswählen";
//Name der Säuren
public static final String s1 =
"<html>HI</html>";
public static final String s2 =
"<html>HClO<sub>4</sub></html>";
public static final String s3 =
"<html>HBr</html>";
public static final String s4 =
"<html>HCl</html>";
public static final String s5 =
"<html>H<sub>2</sub>SO<sub>4</sub></html>";
public static final String s6 =
"<html>H<sub>3</sub>O<sup>+</sup></html>";
public static final String s7 =
"<html>HNO<sub>3</sub></html>";
public static final String s8 =
"<html>[(NH<sub>2</sub>)CO(NH<sub>3</sub>)]<sup>+</sup></html>";
public static final String s9 =
"<html>HOOC-COOH</html>";
public static final String s10 =
"<html>H<sub>2</sub>SO<sub>3</sub></html>";
public static final String s11 =
"<html>HSO<sub>4</sub><sup>-</sup></html>";
public static final String s12 =
"<html>H<sub>3</sub>PO<sub>4</sub></html>";
public static final String s13 =
"<html>[Fe(H<sub>2</sub>O)<sub>6</sub>]<sup>3+</sup></html>";
public static final String s14 =
"<html>HF</html>";
public static final String s15 =
"<html>HNO<sub>2</sub></html>";
public static final String s16 =
"<html>HCOOH</html>";
public static final String s17 =
"<html>C<sub>6</sub>H<sub>5</sub>NH<sub>3</sub><sup>+</sup></html>";
public static final String s18 =
"<html>CH<sub>3</sub>COOH</html>";
public static final String s19 =
"<html>[Al(H<sub>2</sub>O)<sub>6</sub>]<sup>3+</sup></html>";
public static final String s20 =
"<html>H<sub>2</sub>CO<sub>3</sub></html>";
public static final String s21 =
"<html>H<sub>2</sub>S</html>";
public static final String s22 =
"<html>HSO<sub>3</sub><sup>-</sup></html>";
public static final String s23 =
"<html>H<sub>2</sub>PO<sub>4</sub><sup>-</sup></html>";
public static final String s24 =
"<html>NH<sub>4</sub><sup>+</sup></html>";
public static final String s25 =
"<html>HCN</html>";
public static final String s26 =
"<html>[Zn(H<sub>2</sub>O)<sub>6</sub>]<sup>2+</sup></html>";
public static final String s27 =
"<html>C<sub>6</sub>H<sub>5</sub>OH</html>";
public static final String s28 =
"<html>HCO<sub>3</sub><sup>-</sup></html>";
public static final String s29 =
"<html>HPO<sub>4</sub><sup>2-</sup></html>";
public static final String s30 =
"<html>HS<sup>-</sup></html>";
public static final String s31 =
"<html>H<sub>2</sub>O</html>";
public static final String s32 =
"<html>NH<sub>3</sub></html>";
public static final String s33 =
"<html>OH<sup>-</sup></html>";
//Namen der Basen
public static final String s34 =
"<html>I<sup>-</sup></html>";
public static final String s35 =
"<html>ClO<sub>4</sub><sup>-</sup></html>";
public static final String s36 =
"<html>Br<sup>-</sup></html>";
public static final String s37 =
"<html>Cl<sup>-</sup></html>";
public static final String s38 =
"<html>HSO<sub>4</sub><sup>-</sup></html>";
public static final String s39 =
"<html>H<sub>2</sub>O</html>";
public static final String s40 =
"<html>NO<sub>3</sub><sup>-</sup></html>";
public static final String s41 =
"<html>CO(NH<sub>2</sub>)<sub>2</sub></html>";
public static final String s42 =
"<html>HOOC-COO<sup>-</sup></html>";
public static final String s43 =
"<html>HSO<sub>3</sub><sup>-</sup></html>";
public static final String s44 =
"<html>SO<sub>4</sub><sup>2-</sup></html>";
public static final String s45 =
"<html>H<sub>2</sub>PO<sub>4</sub><sup>-</sup></html>";
public static final String s46 =
"<html>[Fe(OH)(H<sub>2</sub>O)<sub>5</sub>]<sup>2+</sup></html>";
public static final String s47 =
"<html>F<sup>-</sup></html>";
public static final String s48 =
"<html>NO<sub>2</sub><sup>-</sup></html>";
public static final String s49 =
"<html>HCOO<sup>-</sup></html>";
public static final String s50 =
"<html>C<sub>6</sub>H<sub>5</sub>NH<sub>2</sub></html>";
public static final String s51 =
"<html>CH<sub>3</sub>COO<sup>-</sup></html>";
public static final String s52 =
"<html>[Al(OH)(H<sub>2</sub>O)<sub>5</sub>]<sup>2+</sup></html>";
public static final String s53 =
"<html>HCO<sub>3</sub><sup>-</sup></html>";
public static final String s54 =
"<html>HS<sup>-</sup></html>";
public static final String s55 =
"<html>SO<sub>3</sub><sup>2-</sup></html>";
public static final String s56 =
"<html>HPO<sub>4</sub><sup>2-</sup></html>";
public static final String s57 =
"<html>NH<sub>3</sub></html>";
public static final String s58 =
"<html>CN<sup>-</sup></html>";
public static final String s59 =
"<html>[Zn(OH)(H<sub>2</sub>O)<sub>5</sub>]<sup>+</sup></html>";
public static final String s60 =
"<html>C<sub>6</sub>H<sub>5</sub>O<sup>-</sup></html>";
public static final String s61 =
"<html>CO<sub>3</sub><sup>2-</sup></html>";
public static final String s62 =
"<html>PO<sub>4</sub><sup>3-</sup></html>";
public static final String s63 =
"<html>S<sup>2-</sup></html>";
public static final String s64 =
"<html>OH<sup>-</sup></html>";
public static final String s65 =
"<html>NH<sub>2</sub><sup>-</sup></html>";
public static final String s66 =
"<html>O<sup>2-</sup></html>";
private JTextField jTextField1 = new JTextField();
private JTextField jTextField2 = new JTextField();
private JLabel jLabel6 = new JLabel();
int ind=0;
int in=0;
// Ende Attribute
public void init()
{
Container cp = getContentPane();
cp.setLayout(null);
cp.setBounds(0, 0, 430, 340);
// Anfang Komponenten
jLabel1.setBounds(112, 24, 193, 24);
jLabel1.setText("pH-Wert Berechner");
jLabel1.setFont(new Font("MS Sans Serif", Font.BOLD + Font.ITALIC, 19));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(jLabel1);
jLabel2.setBounds(40, 72, 166, 24);
jLabel2.setText("Art der Lösung");
jLabel2.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel2);
jLabel3.setBounds(40, 112, 171, 24);
jLabel3.setText("Name des Stoffes");
jLabel3.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel3);
jLabel4.setBounds(40, 160, 172, 24);
jLabel4.setText("Ausgangskonzentration");
jLabel4.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel4);
jButton1.setBounds(96, 200, 233, 33);
jButton1.setText("Berechnung starten");
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
jLabel5.setBounds(40, 248, 162, 24);
jLabel5.setText("pH-Wert");
jLabel5.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel5);
c1.setBounds(208, 72, 145, 30);
cp.add(c1);
c1.addItem(s00);
c1.addItem(s0);
c1.addItem(s01);
c2.setBounds(208, 112, 145, 30);
cp.add(c2);
c1.addItemListener( new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (e.getStateChange() != ItemEvent.SELECTED)
{
c2.removeAllItems();
ind=c1.getSelectedIndex();
if (ind==1)
{
c2.addItem(s0000);
c2.addItem(s1); //Menü für Säuren
c2.addItem(s2);
c2.addItem(s3);
c2.addItem(s4);
c2.addItem(s5);
c2.addItem(s6);
c2.addItem(s7);
c2.addItem(s8);
c2.addItem(s9);
c2.addItem(s10);
c2.addItem(s11);
c2.addItem(s12);
c2.addItem(s13);
c2.addItem(s14);
c2.addItem(s15);
c2.addItem(s16);
c2.addItem(s17);
c2.addItem(s18);
c2.addItem(s19);
c2.addItem(s20);
c2.addItem(s21);
c2.addItem(s22);
c2.addItem(s23);
c2.addItem(s24);
c2.addItem(s25);
c2.addItem(s26);
c2.addItem(s27);
c2.addItem(s28);
c2.addItem(s29);
c2.addItem(s30);
c2.addItem(s31);
c2.addItem(s32);
c2.addItem(s33);
}
else if(ind==2) //Menü für Basen
{
c2.addItem(s000);
c2.addItem(s34);
c2.addItem(s35);
c2.addItem(s36);
c2.addItem(s37);
c2.addItem(s38);
c2.addItem(s39);
c2.addItem(s40);
c2.addItem(s41);
c2.addItem(s42);
c2.addItem(s43);
c2.addItem(s44);
c2.addItem(s45);
c2.addItem(s46);
c2.addItem(s47);
c2.addItem(s48);
c2.addItem(s49);
c2.addItem(s50);
c2.addItem(s51);
c2.addItem(s52);
c2.addItem(s53);
c2.addItem(s54);
c2.addItem(s55);
c2.addItem(s56);
c2.addItem(s57);
c2.addItem(s58);
c2.addItem(s59);
c2.addItem(s60);
c2.addItem(s61);
c2.addItem(s62);
c2.addItem(s63);
c2.addItem(s64);
c2.addItem(s65);
c2.addItem(s66);
}
c2.addItemListener( new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (e.getStateChange() != ItemEvent.SELECTED)
{
in=c2.getSelectedIndex(); //wie komme ich an den Index, den ich ja brauche um die K und pK Werte zu suchen?
System.out.println(in);
}
}
});
}
}
});
jTextField1.setBounds(208, 160, 145, 24);
jTextField1.setText("0.0");
cp.add(jTextField1);
jTextField2.setBounds(208, 248, 145, 24);
jTextField2.setText("");
cp.add(jTextField2);
jLabel6.setBounds(360, 160, 29, 24);
jLabel6.setText("mol/l");
jLabel6.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel6);
// Ende Komponenten
}
// Anfang Methoden
public void jButton1_ActionPerformed(ActionEvent evt)
{
// TODO hier Quelltext einfügen
}
public static void main(double[] args)
{
double[][] array = new double[32][2]; //Matrix für Säuren
array[0][0] = 1;
array[1][0] = 2;
array[2][0] = 3;
array[3][0] = 4;
array[4][0] = 5;
array[5][0] = 6;
array[6][0] = 7;
array[7][0] = 8;
array[8][0] = 9;
array[9][0] = 10;
array[10][0] = 1;
array[11][0] = 12;
array[12][0] = 13;
array[13][0] = 14;
array[14][0] = 15;
array[15][0] = 16;
array[16][0] = 17;
array[17][0] = 18;
array[18][0] = 19;
array[19][0] = 20;
array[20][0] = 21;
array[21][0] = 22;
array[22][0] = 23;
array[23][0] = 24;
array[24][0] = 25;
array[25][0] = 26;
array[26][0] = 27;
array[27][0] = 28;
array[28][0] = 29;
array[29][0] = 30;
array[30][0] = 31;
array[31][0] = 32;
array[32][0] = 33;
//Ks Werte
array[0][1] = 100000000000.00;
array[1][1] = 10000000000.00;
array[2][1] = 1000000000.00;
array[3][1] = 10000000.00;
array[4][1] = 1000.00;
array[5][1] = 55.5;
array[6][1] = 21;
array[7][1] = 0.66;
array[8][1] = 0.056;
array[9][1] = 0.015;
array[10][1] = 0.012;
array[11][1] = 0.0075;
array[12][1] = 0.006;
array[13][1] = 0.00072;
array[14][1] = 0.00045;
array[15][1] = 0.00018;
array[16][1] = 0.000026;
array[17][1] = 0.000018;
array[18][1] = 0.000014;
array[19][1] = 0.0000003;
array[20][1] = 0.00000012;
array[21][1] = 0.000000091;
array[22][1] = 0.000000062;
array[23][1] = 0.00000000056;
array[24][1] = 0.0000000004;
array[25][1] = 0.00000000025;
array[26][1] = 0.00000000013;
array[27][1] = 0.00000000004;
array[28][1] = 0.00000000000044;
array[29][1] = 0.0000000000001;
array[30][1] = 0.00000000000000018;
array[31][1] = 0.00000000000000000000001;
array[32][1] = 0.000000000000000000000001;
//pKs Werte
array[0][2] = -11.00;
array[1][2] = -10.00;
array[2][2] = -9.00;
array[3][2] = -7.00;
array[4][2] = -3.00;
array[5][2] = -1.74;
array[6][2] = -1.32;
array[7][2] = 0.18;
array[8][2] = 1.25;
array[9][2] = 1.81;
array[10][2] = 1.92;
array[11][2] = 2.12;
array[12][2] = 2.22;
array[13][2] = 3.14;
array[14][2] = 3.35;
array[15][2] = 3.75;
array[16][2] = 4.58;
array[17][2] = 4.75;
array[18][2] = 4.85;
array[19][2] = 6.52;
array[20][2] = 6.92;
array[21][2] = 7.04;
array[22][2] = 7.20;
array[23][2] = 9.25;
array[24][2] = 9.40;
array[25][2] = 9.60;
array[26][2] = 9.89;
array[27][2] = 10.40;
array[28][2] = 12.36;
array[29][2] = 13.00;
array[30][2] = 15.74;
array[31][2] = 23.00;
array[32][2] = 24.00;
double[][] array1 = new double[32][2]; //Matrix für Basen
array1[0][0] = 1;
array1[1][0] = 2;
array1[2][0] = 3;
array1[3][0] = 4;
array1[4][0] = 5;
array1[5][0] = 6;
array1[6][0] = 7;
array1[7][0] = 8;
array1[8][0] = 9;
array1[9][0] = 10;
array1[10][0] = 1;
array1[11][0] = 12;
array1[12][0] = 13;
array1[13][0] = 14;
array1[14][0] = 15;
array1[15][0] = 16;
array1[16][0] = 17;
array1[17][0] = 18;
array1[18][0] = 19;
array1[19][0] = 20;
array1[20][0] = 21;
array1[21][0] = 22;
array1[22][0] = 23;
array1[23][0] = 24;
array1[24][0] = 25;
array1[25][0] = 26;
array1[26][0] = 27;
array1[27][0] = 28;
array1[28][0] = 29;
array1[29][0] = 30;
array1[30][0] = 31;
array1[31][0] = 32;
array1[32][0] = 33;
//Kb Werte
array1[0][1] = 0.0000000000000000000000001;
array1[1][1] = 0.000000000000000000000001;
array1[2][1] = 0.00000000000000000000001;
array1[3][1] = 0.000000000000000000001;
array1[4][1] = 0.00000000000000001;
array1[5][1] = 0.00000000000000018;
array1[6][1] = 0.00000000000000048;
array1[7][1] = 0.000000000000015;
array1[8][1] = 0.000000000000177;
array1[9][1] = 0.00000000000065;
array1[10][1] = 0.00000000000083;
array1[11][1] = 0.0000000000013;
array1[12][1] = 0.0000000000017;
array1[13][1] = 0.000000000014;
array1[14][1] = 0.000000000022;
array1[15][1] = 0.000000000056;
array1[16][1] = 0.00000000038;
array1[17][1] = 0.00000000056;
array1[18][1] = 0.00000000071;
array1[19][1] = 0.000000033;
array1[20][1] = 0.000000083;
array1[21][1] = 0.00000011;
array1[22][1] = 0.00000016;
array1[23][1] = 0.000018;
array1[24][1] = 0.000025;
array1[25][1] = 0.00004;
array1[26][1] = 0.000078;
array1[27][1] = 0.00025;
array1[28][1] = 0.023;
array1[29][1] = 0.1;
array1[30][1] = 55.5;
array1[31][1] = 1000000000.00;
array1[32][1] = 10000000000.00;
//pKb Werte
array1[0][2] = 25.00;
array1[1][2] = 24.00;
array1[2][2] = 23.00;
array1[3][2] = 21.00;
array1[4][2] = 17.00;
array1[5][2] = 15.74;
array1[6][2] = 15.32;
array1[7][2] = 13.82;
array1[8][2] = 12.75;
array1[9][2] = 12.19;
array1[10][2] = 12.08;
array1[11][2] = 11.88;
array1[12][2] = 11.78;
array1[13][2] = 10.86;
array1[14][2] = 10.65;
array1[15][2] = 10.25;
array1[16][2] = 9.42;
array1[17][2] = 9.25;
array1[18][2] = 9.15;
array1[19][2] = 7.48;
array1[20][2] = 7.08;
array1[21][2] = 6.96;
array1[22][2] = 6.80;
array1[23][2] = 4.75;
array1[24][2] = 4.60;
array1[25][2] = 4.40;
array1[26][2] = 4.11;
array1[27][2] = 3.60;
array1[28][2] = 1.64;
array1[29][2] = 1.00;
array1[30][2] = -1.74;
array1[31][2] = -9.00;
array1[32][2] = -10.00;
}
// Ende Methoden
}