CI 2019 von Daniel, Eugen und Michael
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.4 KiB

  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import javax.swing.JOptionPane;
  5. import javax.swing.*;
  6. import java.awt.event.WindowAdapter;
  7. import java.awt.event.WindowEvent;
  8. import java.util.Random;
  9. public class Tage_D extends JFrame {
  10. Icon icon1,icon2,icon3;
  11. JLabel bild1,bild2,bild3;
  12. JFrame fr = null;
  13. JPanel Panele = null;
  14. JButton button1 = null;
  15. JTextField j1 = null;
  16. JTextField j2 = null;
  17. JTextField j3 = null;
  18. JTextField j4 = null;
  19. JTextField j5 = null;
  20. JTextField j6 = null;
  21. JMenuItem menuItem1 = null;
  22. JMenuItem menuItem2 = null;
  23. JMenuBar bar =null;
  24. JMenu mF= null;
  25. JMenu mH = null;
  26. JMenu mI = null;
  27. public Tage_D() {
  28. fr = new JFrame("Coutinius Integration SS 2019");
  29. fr.setSize(500,500);
  30. fr.setFont(new Font("Helvetica", Font.PLAIN, 12));
  31. fr.setLayout(new FlowLayout());
  32. Panele = new JPanel();
  33. fr.setContentPane(Panele);
  34. bar = new JMenuBar();
  35. fr.setJMenuBar(bar);
  36. mF = new JMenu("File");
  37. mH = new JMenu("Help");
  38. mI = new JMenu("Info");
  39. bar.add(mF);
  40. bar.add(mH);
  41. bar.add(mI);
  42. menuItem1 = new JMenuItem("Exit"); mF.add(menuItem1);
  43. menuItem2 = new JMenuItem("Über"); mI.add(menuItem2);
  44. menuItem2.addActionListener(new ActionListener() {
  45. public void actionPerformed(ActionEvent ie) {
  46. try {
  47. JOptionPane.showMessageDialog(fr, "Tools entwickelt für CI 2019 Copyright by DEM Consulting");
  48. }catch (Exception ex) {
  49. JOptionPane.showMessageDialog(null, "Fehler");
  50. }
  51. }
  52. });
  53. this.fr.addWindowListener(new WindowAdapter() {
  54. public void windowClosing(WindowEvent e) {
  55. System.exit(-1);
  56. }
  57. });
  58. fr.setContentPane(Panele);
  59. /*
  60. icon1 = new ImageIcon(getClass().getResource("bild1.jpg")); bild1 = new JLabel(icon1); fr.add(icon1);
  61. icon2 = new ImageIcon(getClass().getResource("bild2.jpg")); bild2 = new JLabel(icon2); fr.add(icon2);
  62. icon3 = new ImageIcon(getClass().getResource("bild3.gif")); bild3 = new JLabel(icon3); fr.add(icon3);
  63. */
  64. j1 = new JTextField("Tools von Daniel Hauch"); j1.setEditable(false); j1.setSize(450,30); ; Panele.add(j1);
  65. j2 = new JTextField("Geben Sie hier jeweils nach Auswahl: Geburtsjahr, Hohchzeitsjahr, aktuelles Jahr ein!"); j2.setEditable(false); Panele.add(j2); j2.setSize(450,30); Panele.add(j2);
  66. j3 = new JTextField("Bsp. 1966"); j3.setEditable(true); Panele.add(j2); j3.setSize(450,30); Panele.add(j3);
  67. j4 = new JTextField("Hier erfahren Sie Ergebnisse aus Ihrer Auswahl"); Panele.add(j4);
  68. ButtonGroup buttonGroup = new ButtonGroup();
  69. JButton szeit= new JButton("Sterbezeitpunkt Erfahren");
  70. szeit.setBounds(100, 170, 100, 20);
  71. buttonGroup.add(szeit); Panele.add(szeit);
  72. szeit.addActionListener(new ActionListener() {
  73. public void actionPerformed(ActionEvent ie) {
  74. Random randomGenerator = new Random();
  75. int randomInt = randomGenerator.nextInt(50) + 1;
  76. int zahl = Integer.parseInt(j3.getText());
  77. int zufall = zahl + randomInt;
  78. String resultat = new String("Sie werden im Jahr: "+zufall+" möglicherweise sterben!");
  79. j4.setText(resultat);
  80. }
  81. });
  82. JButton gtag = new JButton("zufälliges Alter ausrechnen");
  83. gtag.setBounds(250, 170, 100, 20);
  84. buttonGroup.add(gtag); Panele.add(gtag);
  85. gtag.addActionListener(new ActionListener() {
  86. public void actionPerformed(ActionEvent ie) {
  87. Random randomGenerator = new Random();
  88. int randomInt = randomGenerator.nextInt(50) + 1;
  89. int zahl = Integer.parseInt(j3.getText());
  90. int zufall = zahl + randomInt;
  91. String resultat = new String("Sie werden in "+zufall+" Jahren möglicherweise sterben!");
  92. j4.setText(resultat);
  93. }
  94. });
  95. final JTextField text1 = new JTextField("");
  96. text1.setBounds(100, 200, 300, 20);
  97. Panele.add(text1);
  98. fr.setVisible(true);
  99. fr.setAlwaysOnTop(true);
  100. fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  101. }
  102. }