|
|
@ -17,13 +17,13 @@ public class TasksFrame extends JFrame { |
|
|
|
super("Unsere kleinen Tasks"); |
|
|
|
|
|
|
|
setVisible(true); |
|
|
|
setBounds(810,200, 300, 600); |
|
|
|
setPreferredSize(new Dimension(300, 600)); |
|
|
|
setBounds(810,200, 400, 600); |
|
|
|
setPreferredSize(new Dimension(400, 600)); |
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
setResizable(false); |
|
|
|
|
|
|
|
JPanel root = new JPanel(); |
|
|
|
root.setBounds(0, 0, 300, 600); |
|
|
|
root.setBounds(0, 0, 400, 600); |
|
|
|
root.setVisible(true); |
|
|
|
|
|
|
|
setContentPane(root); |
|
|
@ -34,7 +34,7 @@ public class TasksFrame extends JFrame { |
|
|
|
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); |
|
|
|
|
|
|
|
jScrollPane = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
|
|
jScrollPane.setPreferredSize(new Dimension(300, 600)); |
|
|
|
jScrollPane.setPreferredSize(new Dimension(400, 600)); |
|
|
|
root.add(jScrollPane); |
|
|
|
|
|
|
|
} |
|
|
@ -51,7 +51,7 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
JLabel jLabel = new JLabel(header); |
|
|
|
jLabel.setVisible(true); |
|
|
|
jLabel.setBounds(3, 3, 160, 20); |
|
|
|
jLabel.setBounds(3, 3, 300, 20); |
|
|
|
|
|
|
|
panel.add(jLabel); |
|
|
|
|
|
|
@ -66,6 +66,8 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
setupDiff(); |
|
|
|
|
|
|
|
setupArea(); |
|
|
|
|
|
|
|
setupSumFromTo(); |
|
|
|
|
|
|
|
setup5ModList(1, 20); |
|
|
@ -207,6 +209,64 @@ public class TasksFrame extends JFrame { |
|
|
|
return a-b; |
|
|
|
} |
|
|
|
|
|
|
|
public void setupArea() |
|
|
|
{ |
|
|
|
JPanel jPanel = setupPanel("Area and perimeter of a Rectangle:"); |
|
|
|
|
|
|
|
JLabel jL1 = new JLabel(); |
|
|
|
jL1.setText("Side a:"); |
|
|
|
jL1.setVisible(true); |
|
|
|
jL1.setBounds(0,20,50,30); |
|
|
|
|
|
|
|
JLabel jL2 = new JLabel(); |
|
|
|
jL2.setText("Side b:"); |
|
|
|
jL2.setVisible(true); |
|
|
|
jL2.setBounds(0,40,50,30); |
|
|
|
|
|
|
|
JTextField a = new JTextField(); |
|
|
|
a.setVisible(true); |
|
|
|
a.setBounds(50,25,30,20); |
|
|
|
|
|
|
|
JTextField b = new JTextField(); |
|
|
|
b.setVisible(true); |
|
|
|
b.setBounds(50,45,30,20); |
|
|
|
|
|
|
|
JButton area = new JButton("Calculate area"); |
|
|
|
area.setVisible(true); |
|
|
|
area.setBounds(0, 80, 180,30); |
|
|
|
|
|
|
|
JTextField areaRes = new JTextField(); |
|
|
|
areaRes.setBounds(200,80,30,20 ); |
|
|
|
areaRes.setVisible(true); |
|
|
|
|
|
|
|
area.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 = calcArea(val_a, val_b); |
|
|
|
areaRes.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
jPanel.add(jL1); |
|
|
|
jPanel.add(jL2); |
|
|
|
jPanel.add(a); |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(area); |
|
|
|
jPanel.add(areaRes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public int calcArea(int a, int b) |
|
|
|
{ |
|
|
|
int area = a * b; |
|
|
|
return area; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setupSumFromTo(){ |
|
|
|
|
|
|
@ -294,4 +354,6 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
return sum; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |