|
|
@ -18,13 +18,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); |
|
|
@ -35,7 +35,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); |
|
|
|
|
|
|
|
} |
|
|
@ -52,7 +52,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); |
|
|
|
|
|
|
@ -67,6 +67,8 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
setupDiff(); |
|
|
|
|
|
|
|
setupArea(); |
|
|
|
|
|
|
|
setupSumFromTo(); |
|
|
|
|
|
|
|
setup5ModList(1, 20); |
|
|
@ -118,6 +120,12 @@ public class TasksFrame extends JFrame { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int calcMod(int n, int x) |
|
|
|
{ |
|
|
|
int rest = n % x; |
|
|
|
return rest; |
|
|
|
} |
|
|
|
|
|
|
|
private void setupEulerschePhiFunk() { |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Eulersche Phi Funktion"); |
|
|
@ -311,6 +319,92 @@ 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); |
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
int area = a * b; |
|
|
|
return area; |
|
|
|
} |
|
|
|
|
|
|
|
public int calcPerimeter(int a, int b) |
|
|
|
{ |
|
|
|
int perimeter = 2 * (a+b); |
|
|
|
return perimeter; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setupSumFromTo(){ |
|
|
|
|
|
|
@ -347,6 +441,7 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(result); |
|
|
|
jPanel.add(sumFromTo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public int sumCalc(int from, int to) { |
|
|
@ -398,4 +493,6 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
return sum; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |