|
|
@ -9,6 +9,8 @@ import java.util.ArrayList; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import static java.lang.Double.valueOf; |
|
|
|
|
|
|
|
public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
private final JScrollPane jScrollPane; |
|
|
@ -81,11 +83,75 @@ public class TasksFrame extends JFrame { |
|
|
|
setupQuersumme(); |
|
|
|
|
|
|
|
setupKgV(); |
|
|
|
|
|
|
|
setupRoundSum(); |
|
|
|
|
|
|
|
setupUmrechnen(); |
|
|
|
|
|
|
|
setupBmi(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void setupBmi() { |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("BMI Calculator"); |
|
|
|
JButton button = new JButton("BMI"); |
|
|
|
button.setVisible(true); |
|
|
|
button.setBounds(10, 65, 100, 30); |
|
|
|
button.setForeground(Color.WHITE); |
|
|
|
button.setBackground(Color.BLUE); |
|
|
|
|
|
|
|
JLabel height = new JLabel("Height/m"); |
|
|
|
height.setVisible(true); |
|
|
|
height.setBounds(10, 20, 60, 30); |
|
|
|
|
|
|
|
JTextField jTextField = new JTextField(); |
|
|
|
jTextField.setVisible(true); |
|
|
|
jTextField.setBounds( 10, 45, 30, 20); |
|
|
|
jTextField.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); |
|
|
|
|
|
|
|
|
|
|
|
JLabel weight = new JLabel("Weight/kg"); |
|
|
|
weight.setVisible(true); |
|
|
|
weight.setBounds(80, 20, 60, 30); |
|
|
|
|
|
|
|
JTextField textField = new JTextField(); |
|
|
|
textField.setVisible(true); |
|
|
|
textField.setBounds( 80, 45, 30, 20); |
|
|
|
textField.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); |
|
|
|
|
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setVisible(true); |
|
|
|
jLabel.setBounds(10, 90, 60, 30); |
|
|
|
|
|
|
|
|
|
|
|
jPanel.add(button); |
|
|
|
jPanel.add(jTextField); |
|
|
|
jPanel.add(height); |
|
|
|
jPanel.add(weight); |
|
|
|
jPanel.add(textField); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String text = jTextField.getText(); |
|
|
|
String text1 = textField.getText(); |
|
|
|
double val = Double.valueOf(text); |
|
|
|
double val1 = Double.valueOf(text1); |
|
|
|
double res = Double.valueOf(bmi(val, val1)); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public double bmi(double height, double weight) { |
|
|
|
|
|
|
|
return weight / (height * height); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setupUmrechnen() { |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Dezimal nach Binär"); |
|
|
|