|
|
@ -74,61 +74,83 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public double setupLeibnizR(int t) { |
|
|
|
double sum=0; |
|
|
|
for(int i=0;i<t;i++){ |
|
|
|
sum += Math.pow(-1,i)/((2*i)+1); |
|
|
|
} |
|
|
|
JPanel jPanel = setupPanel("Leibniz F. von 0 bis" + t); |
|
|
|
private void setupHelloWorld() { |
|
|
|
|
|
|
|
JLabel summe = new JLabel(); |
|
|
|
summe.setVisible(true); |
|
|
|
summe.setText(String.valueOf(sum)); |
|
|
|
summe.setBounds(10,50,100,30); |
|
|
|
JPanel jPanel = setupPanel("Hello World"); |
|
|
|
|
|
|
|
jPanel.add(summe); |
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setBounds(20, 80, 150, 30); |
|
|
|
jLabel.setVisible(true); |
|
|
|
|
|
|
|
return sum; |
|
|
|
} |
|
|
|
Button button = new Button("Say Hello World"); |
|
|
|
button.setBounds(10, 50, 150, 30); |
|
|
|
button.setVisible(true); |
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
jLabel.setText("Hello World"); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<Integer> setup5ModList(int from, int to) { |
|
|
|
jPanel.add(jLabel); |
|
|
|
jPanel.add(button); |
|
|
|
|
|
|
|
ArrayList<Integer> mods = new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
JTextField jTextField = new JTextField(); |
|
|
|
jTextField.setVisible(true); |
|
|
|
jTextField.setBounds(3, 40, 250, 30); |
|
|
|
public void setupSum() { |
|
|
|
JPanel jPanel = setupPanel("Summe"); |
|
|
|
|
|
|
|
for (int i = from; i < to; i++) { |
|
|
|
int e = i % 5; |
|
|
|
mods.add(e); |
|
|
|
jTextField.setText(jTextField.getText() + String.valueOf(e) + " "); |
|
|
|
} |
|
|
|
JTextField a = new JTextField(); |
|
|
|
a.setBounds(10, 50, 30, 20); |
|
|
|
a.setVisible(true); |
|
|
|
|
|
|
|
JLabel sum = new JLabel(); |
|
|
|
sum.setBounds(40, 50, 10, 20); |
|
|
|
sum.setVisible(true); |
|
|
|
sum.setText("+"); |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("mods 2"); |
|
|
|
jPanel.add(jTextField); |
|
|
|
JTextField b = new JTextField(); |
|
|
|
b.setBounds(50, 50, 30, 20); |
|
|
|
b.setVisible(true); |
|
|
|
|
|
|
|
return mods; |
|
|
|
} |
|
|
|
JLabel equal = new JLabel(); |
|
|
|
equal.setBounds(90, 50, 30, 20); |
|
|
|
equal.setVisible(true); |
|
|
|
equal.setText("="); |
|
|
|
|
|
|
|
private void setupSumCalc(int from, int to) { |
|
|
|
JTextField result = new JTextField(); |
|
|
|
result.setBounds(100, 50, 40, 20); |
|
|
|
result.setVisible(true); |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Sum from to"); |
|
|
|
JButton add = new JButton("add"); |
|
|
|
add.setBounds(10, 90, 100, 30); |
|
|
|
add.setVisible(true); |
|
|
|
add.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
Integer val_a = Integer.valueOf(texta); |
|
|
|
Integer val_b = Integer.valueOf(textb); |
|
|
|
int res = calcSumm(val_a, val_b); |
|
|
|
result.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setVisible(true); |
|
|
|
jLabel.setBounds(30, 30, 50, 20); |
|
|
|
jPanel.add(a); |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(equal); |
|
|
|
jPanel.add(result); |
|
|
|
jPanel.add(add); |
|
|
|
jPanel.add(sum); |
|
|
|
|
|
|
|
int sum = 0; |
|
|
|
for (int i = from; i < to; i++) { |
|
|
|
sum += i; |
|
|
|
} |
|
|
|
|
|
|
|
jLabel.setText(String.valueOf(sum)); |
|
|
|
} |
|
|
|
|
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
public int calcSumm(int a, int b) { |
|
|
|
return a+b; |
|
|
|
} |
|
|
|
|
|
|
|
public void setupDiff(){ |
|
|
@ -185,81 +207,62 @@ public class TasksFrame extends JFrame { |
|
|
|
return a-b; |
|
|
|
} |
|
|
|
|
|
|
|
public void setupSum() { |
|
|
|
JPanel jPanel = setupPanel("Summe"); |
|
|
|
private void setupSumCalc(int from, int to) { |
|
|
|
|
|
|
|
JTextField a = new JTextField(); |
|
|
|
a.setBounds(10, 50, 30, 20); |
|
|
|
a.setVisible(true); |
|
|
|
JPanel jPanel = setupPanel("Sum from to"); |
|
|
|
|
|
|
|
JLabel sum = new JLabel(); |
|
|
|
sum.setBounds(40, 50, 10, 20); |
|
|
|
sum.setVisible(true); |
|
|
|
sum.setText("+"); |
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setVisible(true); |
|
|
|
jLabel.setBounds(30, 30, 50, 20); |
|
|
|
|
|
|
|
JTextField b = new JTextField(); |
|
|
|
b.setBounds(50, 50, 30, 20); |
|
|
|
b.setVisible(true); |
|
|
|
int sum = 0; |
|
|
|
for (int i = from; i < to; i++) { |
|
|
|
sum += i; |
|
|
|
} |
|
|
|
|
|
|
|
JLabel equal = new JLabel(); |
|
|
|
equal.setBounds(90, 50, 30, 20); |
|
|
|
equal.setVisible(true); |
|
|
|
equal.setText("="); |
|
|
|
jLabel.setText(String.valueOf(sum)); |
|
|
|
|
|
|
|
JTextField result = new JTextField(); |
|
|
|
result.setBounds(100, 50, 40, 20); |
|
|
|
result.setVisible(true); |
|
|
|
jPanel.add(jLabel); |
|
|
|
} |
|
|
|
|
|
|
|
JButton add = new JButton("add"); |
|
|
|
add.setBounds(10, 90, 100, 30); |
|
|
|
add.setVisible(true); |
|
|
|
add.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
Integer val_a = Integer.valueOf(texta); |
|
|
|
Integer val_b = Integer.valueOf(textb); |
|
|
|
int res = calcSumm(val_a, val_b); |
|
|
|
result.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
jPanel.add(a); |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(equal); |
|
|
|
jPanel.add(result); |
|
|
|
jPanel.add(add); |
|
|
|
jPanel.add(sum); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
private ArrayList<Integer> setup5ModList(int from, int to) { |
|
|
|
|
|
|
|
public int calcSumm(int a, int b) { |
|
|
|
return a+b; |
|
|
|
} |
|
|
|
ArrayList<Integer> mods = new ArrayList<>(); |
|
|
|
|
|
|
|
private void setupHelloWorld() { |
|
|
|
JTextField jTextField = new JTextField(); |
|
|
|
jTextField.setVisible(true); |
|
|
|
jTextField.setBounds(3, 40, 250, 30); |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Hello World"); |
|
|
|
for (int i = from; i < to; i++) { |
|
|
|
int e = i % 5; |
|
|
|
mods.add(e); |
|
|
|
jTextField.setText(jTextField.getText() + String.valueOf(e) + " "); |
|
|
|
} |
|
|
|
|
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setBounds(20, 80, 150, 30); |
|
|
|
jLabel.setVisible(true); |
|
|
|
|
|
|
|
Button button = new Button("Say Hello World"); |
|
|
|
button.setBounds(10, 50, 150, 30); |
|
|
|
button.setVisible(true); |
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
jLabel.setText("Hello World"); |
|
|
|
} |
|
|
|
}); |
|
|
|
JPanel jPanel = setupPanel("mods 2"); |
|
|
|
jPanel.add(jTextField); |
|
|
|
|
|
|
|
return mods; |
|
|
|
} |
|
|
|
|
|
|
|
jPanel.add(jLabel); |
|
|
|
jPanel.add(button); |
|
|
|
public double setupLeibnizR(int t) { |
|
|
|
double sum=0; |
|
|
|
for(int i=0;i<t;i++){ |
|
|
|
sum += Math.pow(-1,i)/((2*i)+1); |
|
|
|
} |
|
|
|
JPanel jPanel = setupPanel("Leibniz F. von 0 bis" + t); |
|
|
|
|
|
|
|
JLabel summe = new JLabel(); |
|
|
|
summe.setVisible(true); |
|
|
|
summe.setText(String.valueOf(sum)); |
|
|
|
summe.setBounds(10,50,100,30); |
|
|
|
|
|
|
|
jPanel.add(summe); |
|
|
|
|
|
|
|
return sum; |
|
|
|
} |
|
|
|
} |