|
|
@ -321,6 +321,28 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(area); |
|
|
|
jPanel.add(areaRes); |
|
|
|
|
|
|
|
JButton perimeter = new JButton("Calculate perimeter"); |
|
|
|
perimeter.setVisible(true); |
|
|
|
perimeter.setBounds(0, 110, 180,30); |
|
|
|
|
|
|
|
JTextField perimeterRes = new JTextField(); |
|
|
|
perimeterRes.setBounds(200,110,30,20 ); |
|
|
|
perimeterRes.setVisible(true); |
|
|
|
perimeter.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); |
|
|
|
Integer res = calcPerimeter(val_a, val_b); |
|
|
|
perimeterRes.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
jPanel.add(perimeterRes); |
|
|
|
jPanel.add(perimeter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public int calcArea(int a, int b) |
|
|
@ -329,6 +351,13 @@ public class TasksFrame extends JFrame { |
|
|
|
return area; |
|
|
|
} |
|
|
|
|
|
|
|
public int calcPerimeter(int a, int b) |
|
|
|
{ |
|
|
|
int perimeter = 2 * (a+b); |
|
|
|
return perimeter; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setupSumFromTo(){ |
|
|
|
|
|
|
@ -365,6 +394,7 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(result); |
|
|
|
jPanel.add(sumFromTo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public int sumCalc(int from, int to) { |
|
|
|