diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java new file mode 100644 index 0000000..cbb1f2e --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java @@ -0,0 +1,48 @@ +package de.heatup.ui.actionPanel; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; + +import javax.swing.*; +import javax.swing.border.LineBorder; + +public class ActionControl { + private Smashing smashing; + private Keysequence keysequence; + private JPanel panel; + private JLabel comp; + + public void setPanel(JPanel newPanel){ + panel = newPanel; + } + + public void setAction(String s){ + + if(s.equals("smashing")){ + smashing = new Smashing(); + String tmp= "Bitte die Taste "+smashing.getKey()+" so schnell wie möglich drücken"; + comp = new JLabel(tmp); + comp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16)); + comp.setBorder(new LineBorder(Color.BLACK, 1)); + comp.setSize(100,10); + panel.add(comp); + panel.setVisible(false); + panel.setVisible(true); + }else{ + keysequence = new Keysequence(); + String tmp="Bitte diese Tastenkombination "+keysequence.getKeySequence()[0]+" "+keysequence.getKeySequence()[1]+" "+keysequence.getKeySequence()[2]+" "+keysequence.getKeySequence()[3]+" "+" so schnell wie möglich drücken"; + comp = new JLabel(tmp); + comp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16)); + comp.setBorder(new LineBorder(Color.BLACK, 1)); + comp.setSize(100,10); + panel.add(comp); + panel.setVisible(false); + panel.setVisible(true); + + } + } + public void wishPanel(){ + comp.setVisible(false); + } +} diff --git a/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java b/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java new file mode 100644 index 0000000..f5408d2 --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java @@ -0,0 +1,32 @@ +package de.heatup.ui.actionPanel; + +import java.util.Random; + +public class Keysequence { + char[] key_sq; + Random rdm; + public Keysequence(){ + rdm = new Random(); + key_sq=new char[4]; + } + + public char[] getKeySequence(){ + for(int i=0;i<4;i++){ + switch(rdm.nextInt(4)+1){ + case 1: + key_sq[i]='Q'; + break; + case 2: + key_sq[i]='W'; + break; + case 3: + key_sq[i]='E'; + break; + case 4: + key_sq[i]='R'; + break; + } + } + return key_sq; + } +} diff --git a/HeatUp/src/de/heatup/ui/actionPanel/Smashing.java b/HeatUp/src/de/heatup/ui/actionPanel/Smashing.java new file mode 100644 index 0000000..ca21c2b --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/Smashing.java @@ -0,0 +1,29 @@ +package de.heatup.ui.actionPanel; + +import java.util.Random; + +public class Smashing { + char key; + Random rdm; + + public Smashing(){ + rdm = new Random(); + } + public char getKey(){ + switch(rdm.nextInt(4)+1){ + case 1: + key='Q'; + break; + case 2: + key='W'; + break; + case 3: + key='E'; + break; + case 4: + key='R'; + break; + } + return key; + } +}