From 001f915482ea7bbabcc45dcbd5bea563f7003e74 Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Mon, 6 Feb 2023 15:52:18 +0100 Subject: [PATCH] Extention of the Button faku in setupFakultaet --- src/main/java/src/TasksFrame.java | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 03b70c4..76ef362 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -102,8 +102,6 @@ public class TasksFrame extends JFrame { } - - private void setupExponent() { JPanel jPanel = setupPanel("Potenzrechner"); @@ -240,7 +238,6 @@ public class TasksFrame extends JFrame { return roundOff; } - private void setupUmrechnen() { JPanel jPanel = setupPanel("Dezimal nach Binär"); @@ -354,7 +351,6 @@ public class TasksFrame extends JFrame { } } - private void setupKgV() { JPanel jPanel = setupPanel("kgV"); @@ -444,7 +440,6 @@ public class TasksFrame extends JFrame { return quersumme; } - public int calcMod(int n, int x) { int rest = n % x; @@ -594,7 +589,6 @@ public class TasksFrame extends JFrame { } - public int calcSumm(int a, int b) { return a+b; } @@ -674,9 +668,14 @@ public class TasksFrame extends JFrame { { JPanel jPanel = setupPanel("Berechnen Sie die Fakultaet einer Zahl:"); + JLabel text1 = new JLabel(); + text1.setText("Zahleingabe:"); + text1.setVisible(true); + text1.setBounds(0,25,80,30); + JTextField a = new JTextField(); a.setVisible(true); - a.setBounds(50,25,35,30); + a.setBounds(90,25,35,30); a.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); JButton faku = new JButton("Calculate Fakultaet"); @@ -689,6 +688,18 @@ public class TasksFrame extends JFrame { res.setBounds(50,100,35,30); res.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); + JLabel text2 = new JLabel(); + text2.setText("! = "); + text2.setVisible(true); + text2.setBounds(30,100,40,30); + text2.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); + + JTextField new2 = new JTextField(); + new2.setBounds(0,100,35,30); + new2.setVisible(true); + new2.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); + + faku.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -696,16 +707,19 @@ public class TasksFrame extends JFrame { Integer val_a = Integer.valueOf(texta); Integer res1 = Fakultaet(val_a); res.setText(String.valueOf(res1)); + new2.setText(String.valueOf(val_a)); + jPanel.add(res); + jPanel.add(text2); + jPanel.add(new2); } }); jPanel.add(a); jPanel.add(faku); - jPanel.add(res); + jPanel.add(text1); } - public void setupArea() { JPanel jPanel = setupPanel("Area and perimeter of a Rectangle:"); @@ -785,8 +799,6 @@ public class TasksFrame extends JFrame { } - - public int calcArea(int a, int b) { int area = a * b; @@ -799,7 +811,6 @@ public class TasksFrame extends JFrame { return perimeter; } - public void setupSumFromTo(){ JPanel jPanel = setupPanel("Sum from to"); @@ -851,7 +862,6 @@ public class TasksFrame extends JFrame { return sum+to; } - private ArrayList setup5ModList(int from, int to) { ArrayList mods = new ArrayList<>();