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.

159 lines
5.3 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. import java.util.Date;
  10. public class Tage_D extends JFrame {
  11. Icon icon1,icon2,icon3;
  12. JLabel bild1,bild2,bild3;
  13. JFrame fr = null;
  14. JPanel Panele = null;
  15. JTextField j1 = null;
  16. JTextField j2 = null;
  17. JTextField j3 = null;
  18. JTextField j4 = null;
  19. JMenuItem menuItem1 = null;
  20. JMenuItem menuItem2 = null;
  21. JMenuItem menuItem3 = null;
  22. JMenuBar bar =null;
  23. JMenu mF= null;
  24. JMenu mH = null;
  25. JMenu mI = null;
  26. public Tage_D() {
  27. fr = new JFrame("Coutinius Integration SS 2019");
  28. fr.setSize(1920,1080);
  29. fr.setFont(new Font("Helvetica", Font.PLAIN, 12));
  30. fr.setLayout(new FlowLayout());
  31. Panele = new JPanel();
  32. fr.setContentPane(Panele);
  33. bar = new JMenuBar();
  34. fr.setJMenuBar(bar);
  35. mF = new JMenu("File");
  36. mH = new JMenu("Help");
  37. mI = new JMenu("Info");
  38. bar.add(mF);
  39. bar.add(mH);
  40. bar.add(mI);
  41. menuItem1 = new JMenuItem("Hauptprogramm"); mF.add(menuItem1);
  42. menuItem2 = new JMenuItem("Exit"); mF.add(menuItem2);
  43. menuItem3 = new JMenuItem("Über"); mI.add(menuItem3);
  44. menuItem1.addActionListener(new ActionListener() {
  45. public void actionPerformed(ActionEvent ie) {
  46. try {
  47. JOptionPane.showMessageDialog(fr, "Wir wechseln zum Hauptprogramm");
  48. Main mn = new Main();
  49. fr.setVisible((false));
  50. Panele.setVisible(false);
  51. mn.fr.setVisible(true);
  52. //System.exit(0);
  53. }catch (Exception ex) {
  54. JOptionPane.showMessageDialog(null, "Fehler");
  55. }
  56. }
  57. });
  58. menuItem2.addActionListener(new ActionListener() {
  59. public void actionPerformed(ActionEvent ie) {
  60. try {
  61. System.exit(-1);
  62. }catch (Exception ex) {
  63. JOptionPane.showMessageDialog(null, "Fehler");
  64. }
  65. }
  66. });
  67. menuItem3.addActionListener(new ActionListener() {
  68. public void actionPerformed(ActionEvent ie) {
  69. try {
  70. JOptionPane.showMessageDialog(fr, "Tools entwickelt für CI 2019 Copyright by DEM Consulting");
  71. }catch (Exception ex) {
  72. JOptionPane.showMessageDialog(null, "Fehler");
  73. }
  74. }
  75. });
  76. this.fr.addWindowListener(new WindowAdapter() {
  77. public void windowClosing(WindowEvent e) {
  78. System.exit(-1);
  79. }
  80. });
  81. Date datum=new Date();
  82. int year=datum.getYear() + 1900;
  83. j1 = new JTextField("Tools von Daniel Hauch",10); j1.setEditable(false); j1.setSize(450,30); ; bar.add(j1);
  84. j2 = new JTextField("Geben Sie hier jeweils nach Auswahl: Geburtsjahr, Hohchzeitsjahr, aktuelles Jahr ein! Bsp. 1969",50); j2.setEditable(false); Panele.add(j2); j2.setSize(450,30); Panele.add(j2);
  85. j3 = new JTextField("1969",10); j3.setEditable(true); Panele.add(j2); j3.setSize(450,30); Panele.add(j3);
  86. ButtonGroup buttonGroup = new ButtonGroup();
  87. JButton szeit= new JButton("Sterbezeitpunkt Erfahren");
  88. szeit.setBounds(100, 170, 100, 20);
  89. buttonGroup.add(szeit); Panele.add(szeit);
  90. szeit.addActionListener(new ActionListener() {
  91. public void actionPerformed(ActionEvent ie) {
  92. int ergebnis, zufall, zahl, i;
  93. zahl = Integer.parseInt(j3.getText());
  94. zufall= gibZufall(zahl);
  95. while(zufall<=year){
  96. // System.out.println(zufall);
  97. zufall = gibZufall(zahl);
  98. }
  99. String resultat = new String("Sie werden im Jahre "+zufall+" möglicherweise sterben!");
  100. j4.setText(resultat);
  101. }
  102. });
  103. JButton htag = new JButton("Silber-Gold-Diamant ausrechnen");
  104. htag.setBounds(250, 170, 100, 20);
  105. buttonGroup.add(htag); Panele.add(htag);
  106. htag.addActionListener(new ActionListener() {
  107. public void actionPerformed(ActionEvent ie) {
  108. int diamant, gold, silber, zufall, zahl, i;
  109. zahl = Integer.parseInt(j3.getText());
  110. diamant=zahl+60;
  111. gold=zahl+50;
  112. silber=zahl+25;
  113. String resultat = new String("Sie werden im Jahr "+silber+" Ihre Silberhochzeit, im Jahr "+gold+" Ihre Goldene Hochzeit und im Jahr "+diamant+" Diamanten Hochzeit feiern.");
  114. j4.setText(resultat);
  115. }
  116. });
  117. j4 = new JTextField("Hier erfahren Sie Ergebnisse aus Ihrer Auswahl",80); Panele.add(j4);
  118. fr.setVisible(true);
  119. fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  120. }
  121. //Methode gibt eine ganze Zahl (int) zurück
  122. public static int gibZufall (int zahl) {
  123. Random randomGenerator = new Random();
  124. int randomInt = randomGenerator.nextInt(115) + 1;
  125. int zufall = zahl + randomInt;
  126. return zufall;
  127. }
  128. }