From adc41bb9d8650384d5a35df01b8dede4db8f4b1f Mon Sep 17 00:00:00 2001 From: Hauch IT Date: Mon, 8 Jul 2019 01:16:46 +0200 Subject: [PATCH] Tage Script umgestellt von Eugens Quiz Idee --- .idea/workspace.xml | 106 ++++++++++++++++++++++++-------------------- src/Tage_D.java | 105 ++++++++++++++++++++++--------------------- 2 files changed, 113 insertions(+), 98 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b60c703..43a527e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,13 +3,6 @@ - - - - - - - @@ -27,25 +20,19 @@ - - + + - - + + + + + - - - - - - - - - @@ -59,6 +46,7 @@ pa. contantPane + this. this. @@ -82,10 +70,9 @@ - @@ -122,6 +109,7 @@ + - + - - @@ -269,35 +257,49 @@ - - + - + - - + + - + - + @@ -319,7 +321,8 @@ - @@ -359,27 +362,36 @@ - + - - + + - + - - + + + + + + + + - - + + - - + + + + + diff --git a/src/Tage_D.java b/src/Tage_D.java index 5979005..9c8d482 100644 --- a/src/Tage_D.java +++ b/src/Tage_D.java @@ -1,9 +1,9 @@ -import java.awt.JobAttributes; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; import javax.swing.*; -public class Tage_D { +public class Tage_D extends JFrame { JFrame fr = null; JPanel Panele = null; @@ -22,6 +22,7 @@ public class Tage_D { JTextField j2 = null; JTextField j3 = null; JTextField j4 = null; + JTextField j5 = null; JMenuItem menuItem1 = null; JMenuItem menuItem2 = null; @@ -34,62 +35,39 @@ public class Tage_D { public Tage_D() { - this.fr = new JFrame("GUI"); - this.fr.setSize(300, 900); + fr = new JFrame("GUI"); + fr.setSize(350, 700); + fr.setLayout(new FlowLayout()); - this.Panele = new JPanel(); - this.fr.setContentPane(this.Panele); + Panele = new JPanel(); + fr.setContentPane(Panele); - this.bar = new JMenuBar(); - this.fr.setJMenuBar(bar); - this.mF = new JMenu("File"); - this.mH = new JMenu("Help"); - this.bar.add(mF); - this.bar.add(mH); + bar = new JMenuBar(); + fr.setJMenuBar(bar); + mF = new JMenu("File"); + mH = new JMenu("Help"); + bar.add(mF); + bar.add(mH); - this.menuItem1 = new JMenuItem("Exit"); this.mF.add(menuItem1); - this.menuItem2 = new JMenuItem("Info"); this.mH.add(menuItem2); + menuItem1 = new JMenuItem("Exit"); mF.add(menuItem1); + menuItem2 = new JMenuItem("Info"); mH.add(menuItem2); - this.label4= new JLabel("Ein Tool der CI!."); this.Panele.add(label4); - this.label5= new JLabel("Wollen Sie erfahren, Wie viel Zeit bleibt dir in deinem Leben noch?"); - this.Panele.add(label5); - this.label1 = new JLabel("Wie ist Ihr Name?"); this.Panele.add(label1); + j1 = new JTextField("Ein Tool der CI"); j1.setEditable(false); j1.setSize(450,30); ; Panele.add(j1); + j2 = new JTextField("Tools von Daniel Hauch"); j2.setEditable(false); Panele.add(j2); j2.setSize(450,30); Panele.add(j2); + j3 = new JTextField("Wie ist Ihr Name?"); j3.setEditable(true); Panele.add(j2); j3.setSize(450,30); Panele.add(j3); - this.j1 = new JTextField("", 20); - this.Panele.add(j1); - this.j1.setSize(160,20);; - this.label2 = new JLabel("Wie alt sind Sie?"); - this.Panele.add(label2); - this.j2 = new JTextField("", 20); - this.Panele.add(j2); - this.j2.setSize(160,20); + button1 = new JButton("Erfahren"); Panele.add(button1); - this.label3 = new JLabel("Was machen Sie beruflich?"); - this.Panele.add(label3); - this.j3 = new JTextField("", 20); - this.Panele.add(j3); + j4 = new JTextField("Sie sterben in ___ Jahren!"); Panele.add(j4); - this.button1 = new JButton("Erfahren"); - this.Panele.add(button1); - - this.j4 = new JTextField("Sie sterben in ___ Jahren!"); - this.Panele.add(j4); - - this.label6 = new JLabel("Die Wahrheit ist schwer zu ertragen."); - this.Panele.add(label6); - - this.label7 = new JLabel("ich hab eine Lösung für dich!"); - this.Panele.add(label7); ButtonGroup buttonGroup = new ButtonGroup(); JRadioButton hzeit = new JRadioButton("Hochzeit"); hzeit.setBounds(100, 170, 100, 20); - buttonGroup.add(hzeit); - this.Panele.add(hzeit); + buttonGroup.add(hzeit); this.Panele.add(hzeit); JRadioButton gtag = new JRadioButton("Geburtstag"); gtag.setBounds(250, 170, 100, 20); - buttonGroup.add(gtag); - this.Panele.add(gtag); + buttonGroup.add(gtag); this.Panele.add(gtag); JLabel auswahl = new JLabel("Ihre Auswahl:"); auswahl.setBounds(10, 200, 100, 20); @@ -111,21 +89,46 @@ public class Tage_D { }); - this.fr.setVisible(true); + gtag.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ie) { + text1.setText("FEMALE"); + } + }); + this.fr.setVisible(true); + this.fr.setAlwaysOnTop(true); + DerHandler handler = new DerHandler(); + menuItem1.addActionListener(handler); + gtag.addActionListener(handler); + hzeit.addActionListener(handler); } // Action Listener - private class ActionListener1 implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + private class DerHandler implements ActionListener { + @Override + public void actionPerformed(ActionEvent event) { - System.exit(0); - } + String string = ""; +/* + if(event.getSource()=hzeit) + string=String.format("Name: %s", event.getActionCommand()); + + else if(event.getSource()==gtag) + string=String.format("passwortFeld2: %s", event.getActionCommand()); + + JOptionPane.showMessageDialog(null, string); } + + + + } + + */ + } +} public static void main(String[] args) { Tage_D gb = new Tage_D();