diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 8b8e942..c150264 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -1224,7 +1224,75 @@ public class TasksFrame extends JFrame { e8.setText("€"); e8.setBounds(360,70,20,20); + JButton jButton = new JButton(); + jButton.setVisible(true); + jButton.setText("Berechne GuV"); + jButton.setBounds(1,120,110,30); + + JLabel summe1 = new JLabel(); + summe1.setText("∑"); + summe1.setVisible(true); + summe1.setBounds(108,115,20,20); + + JLabel summe2 = new JLabel(); + summe2.setText("∑"); + summe2.setVisible(true); + summe2.setBounds(290,85,20,20); + + JLabel erg1 = new JLabel(); + erg1.setBounds(130,115,80,20); + erg1.setVisible(true); + + JLabel erg2 = new JLabel(); + erg2.setBounds(310,85,80,20); + erg2.setVisible(true); + JLabel ausgabe = new JLabel(); + ausgabe.setVisible(true); + ausgabe.setBounds(250, 120,150,20); + + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String texta = t1.getText(); + String textb = t2.getText(); + String textc = t3.getText(); + String textd = t4.getText(); + String texte = t5.getText(); + String textf = t6.getText(); + String textg = t7.getText(); + String texth = t8.getText(); + + Integer val_a = Integer.valueOf(texta); + Integer val_b = Integer.valueOf(textb); + Integer val_c = Integer.valueOf(textc); + Integer val_d = Integer.valueOf(textd); + Integer val_e = Integer.valueOf(texte); + Integer val_f = Integer.valueOf(textf); + Integer val_g = Integer.valueOf(textg); + Integer val_h = Integer.valueOf(texth); + Integer res1 = setupAufwendungen(val_a, val_b, val_c, val_d, val_e); + Integer res2 = setupErtraege(val_f,val_g,val_h); + erg1.setText(String.valueOf(res1 +" €")); + erg2.setText(String.valueOf(res2 +"€")); + jPanel.add(erg1); + jPanel.add(erg2); + if(res1>res2) + { + ausgabe.setText("Verlust: " +(res1-res2) +"€"); + ausgabe.setForeground(Color.RED); + } else + { + ausgabe.setText("Gewinn: " + (res2-res1) +"€"); + ausgabe.setForeground(Color.GREEN); + } + } + }); + + jPanel.add(ausgabe); + jPanel.add(summe2); + jPanel.add(summe1); + jPanel.add(jButton); jPanel.add(t1); jPanel.add(t2); jPanel.add(t3); @@ -1233,8 +1301,6 @@ public class TasksFrame extends JFrame { jPanel.add(t6); jPanel.add(t7); jPanel.add(t8); - jPanel.add(t4); - jPanel.add(t5); jPanel.add(l1); jPanel.add(l2); jPanel.add(l3); @@ -1258,6 +1324,7 @@ public class TasksFrame extends JFrame { public int setupAufwendungen(int a, int b, int c, int d, int e) { int x = 0; + x = a+b+c+d+e; return x; }