added keylisteners, some pictures, RandomTextCreator-Class, something for displaying the pressed keys

This commit is contained in:
WickedJack99
2022-06-06 14:58:37 +02:00
parent 0b9b861f22
commit e7df7a60d9
13 changed files with 1253 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -0,0 +1,5 @@
172
248
245
acf8f5

View File

@@ -0,0 +1,24 @@
package Model;
import java.util.concurrent.ConcurrentLinkedQueue;
public class ModelCommands {
public static void exercise1(MyModel oModel) {
ModelData oModelData = new ModelData(RandomTextCreator.lesson1(300));
oModel.setModelData(oModelData);
oModel.getModelQueueToMain().add(oModelData);
}
public static void exercise2(MyModel oModel) {
ModelData oModelData = new ModelData(RandomTextCreator.lesson2(300));
oModel.setModelData(oModelData);
oModel.getModelQueueToMain().add(oModelData);
}
public static void exercise34(MyModel oModel) {
ModelData oModelData = new ModelData(RandomTextCreator.createText(300));
oModel.setModelData(oModelData);
oModel.getModelQueueToMain().add(oModelData);
}
}

View File

@@ -36,11 +36,43 @@ public class MyModel extends Thread {
System.out.println("Command: " + iModelCommand); System.out.println("Command: " + iModelCommand);
switch (iModelCommand) { switch (iModelCommand) {
case (1): { case (1): {
oModelData = new ModelData(RandomTextCreator.createText(300));
qDataToMain.add(oModelData);
}break; }break;
case (2): { case (2): {
}break;
case (3): {
}break;
case (4): {
}break;
case (5): {
}break;
case (6): {
}break;
case (7): {
}break;
case (8): {
}break;
case (9): {
}break;
case (10): {
}break;
case (11): {
}break;
case (34): {
ModelCommands.exercise34(this);
}break;
case (35): {
}break; }break;
} }
} }
@@ -51,4 +83,16 @@ public class MyModel extends Thread {
public void setModelCommand(int iModelCommand) { public void setModelCommand(int iModelCommand) {
this.iModelCommand = iModelCommand; this.iModelCommand = iModelCommand;
} }
public void setModelData(ModelData oModelData) {
this.oModelData = oModelData;
}
public ModelData getModelData() {
return this.oModelData;
}
public ConcurrentLinkedQueue<ModelData> getModelQueueToMain() {
return this.qDataToMain;
}
} }

View File

@@ -1,6 +1,312 @@
package Model; package Model;
public class RandomTextCreator { public class RandomTextCreator {
//1. dfjk
//2. asl;
//3. asdf jkl;
//4. ei
//5. gh
//6. c,
//7. asdfg hjkl; ei gh c,
//8. ASDFG HJKL: EI GH C<
//9. asdfg hjkl; ei gh c, ASDFG HJKL: EI GH C<
//10. ru
//11. vm
//12. ty
//13. ru vm ty
//14. RU VM TY
//15. ru vm ty RU VM TY
//16. bn
//17. wo
//18. x./
//19. bn wo x./
//20. BN WO X>?
//21. bn wo x./ BN WO X>?
//22. qp
//23. z\'
//24. \[]
//25. {}
//26. qp z\' \[] {}
//27. QP Z|" -= _+
//28. qp z\' \[] {} QP Z|" -= _+
/**
* dfjk
* 100 102 106 107
* @param iTextLength
* @return
*/
public static String lesson1(int iTextLength) {
String sReturn = "";
int[] aiLetters = {100, 102, 106, 107};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* asl;
* 97 115 108 59
* @param iTextLength
* @return
*/
public static String lesson2(int iTextLength) {
String sReturn = "";
int[] aiLetters = {97, 115, 108, 59};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* asdf jkl;
* 97 115 100 102 106 107 108 59
* @param iTextLength
* @return
*/
public static String lesson3(int iTextLength) {
String sReturn = "";
int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ei
* 101 105
* @param iTextLength
* @return
*/
public static String lesson4(int iTextLength) {
String sReturn = "";
int[] aiLetters = {101, 105};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* gh
* 103 104
* @param iTextLength
* @return
*/
public static String lesson5(int iTextLength) {
String sReturn = "";
int[] aiLetters = {103, 104};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* c,
* 99 44
* @param iTextLength
* @return
*/
public static String lesson6(int iTextLength) {
String sReturn = "";
int[] aiLetters = {99, 44};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* asdf jkl; ei gh c,
* 97 115 100 102 106 107 108 59 101 105 103 104 99 44
* @param iTextLength
* @return
*/
public static String lesson7(int iTextLength) {
String sReturn = "";
int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59, 101, 105, 103, 104, 99, 44};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ASDF JKL: EI GH C<
* 65 83 68 70 74 75 76 58 69 73 71 72 67 60
* @param iTextLength
* @return
*/
public static String lesson8(int iTextLength) {
String sReturn = "";
int[] aiLetters = {65, 83, 68, 70, 74, 75, 76, 58, 69, 73, 71, 72, 67, 60};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* asdf jkl; ei gh c, ASDF JKL: EI GH C<
* 97 115 100 102 106 107 108 59 101 105 103 104 99 44 65 83 68 70 74 75 76 58 69 73 71 72 67 60
* @param iTextLength
* @return
*/
public static String lesson9(int iTextLength) {
String sReturn = "";
int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59, 101, 105, 103, 104, 99, 44, 65, 83, 68, 70, 74, 75, 76, 58, 69, 73, 71, 72, 67, 60};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ru
* 114 117
* @param iTextLength
* @return
*/
public static String lesson10(int iTextLength) {
String sReturn = "";
int[] aiLetters = {114, 117};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* vm
* 118 109
* @param iTextLength
* @return
*/
public static String lesson11(int iTextLength) {
String sReturn = "";
int[] aiLetters = {118, 109};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ty
* 116 121
* @param iTextLength
* @return
*/
public static String lesson12(int iTextLength) {
String sReturn = "";
int[] aiLetters = {116, 121};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ru vm ty
* 114 117 118 109 116 121
* @param iTextLength
* @return
*/
public static String lesson13(int iTextLength) {
String sReturn = "";
int[] aiLetters = {114, 117, 118, 109, 116, 121};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* RU VM TY
* 82 85 86 77 84 89
* @param iTextLength
* @return
*/
public static String lesson14(int iTextLength) {
String sReturn = "";
int[] aiLetters = {82, 85, 86, 77, 84, 89};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* ru vm ty RU VM TY
* 114 117 118 109 116 121 82 85 86 77 84 89
* @param iTextLength
* @return
*/
public static String lesson15(int iTextLength) {
String sReturn = "";
int[] aiLetters = {114, 117, 118, 109, 116, 121, 82, 85, 86, 77, 84, 89};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* bn
* 98 110
* @param iTextLength
* @return
*/
public static String lesson16(int iTextLength) {
String sReturn = "";
int[] aiLetters = {98, 110};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* wo
* 119 111
* @param iTextLength
* @return
*/
public static String lesson17(int iTextLength) {
String sReturn = "";
int[] aiLetters = {119, 111};
for (int i = 0; i < iTextLength; i++) {
int iOption = randomNumber(0, aiLetters.length - 1);
sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
}
return sReturn;
}
/**
* Creates random Text with
* @param iTextLength
*/
public static String createText(int iTextLength) { public static String createText(int iTextLength) {
String sReturn = ""; String sReturn = "";
int iLastOption = 0; int iLastOption = 0;
@@ -12,10 +318,10 @@ public class RandomTextCreator {
iMin = 1; iMin = 1;
iMax = 2; iMax = 2;
} }
//Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min
int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); int iOption = randomNumber(iMin, iMax);
while (iOption == iLastOption) { while (iOption == iLastOption) {
iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); iOption = randomNumber(iMin, iMax);
} }
switch (iOption) { switch (iOption) {
@@ -45,28 +351,19 @@ public class RandomTextCreator {
//48-57 0-9 //48-57 0-9
private static String createText0() { private static String createText0() {
//Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min int iOption = randomNumber(48, 57);
int iMin = 48;
int iMax = 57;
int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin);
return String.valueOf(Character.toChars(iOption)); return String.valueOf(Character.toChars(iOption));
} }
//65-90 A-Z //65-90 A-Z
private static String createText1() { private static String createText1() {
//Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min int iOption = randomNumber(65, 90);
int iMin = 65;
int iMax = 90;
int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin);
return String.valueOf(Character.toChars(iOption)); return String.valueOf(Character.toChars(iOption));
} }
//97-122 a-z //97-122 a-z
private static String createText2() { private static String createText2() {
//Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min int iOption = randomNumber(97, 122);
int iMin = 97;
int iMax = 122;
int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin);
return String.valueOf(Character.toChars(iOption)); return String.valueOf(Character.toChars(iOption));
} }
@@ -74,10 +371,17 @@ public class RandomTextCreator {
//63 33 40 41 61 43 44 45 91 93 123 125 //63 33 40 41 61 43 44 45 91 93 123 125
private static String createText3() { private static String createText3() {
int [] aiOptions = {63, 33, 40, 41, 61, 43, 44, 45, 91, 93, 123, 125}; int [] aiOptions = {63, 33, 40, 41, 61, 43, 44, 45, 91, 93, 123, 125};
//Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min int iOption = randomNumber(0, 11);
int iMin = 0;
int iMax = 11;
int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin);
return String.valueOf(Character.toChars(aiOptions[iOption])); return String.valueOf(Character.toChars(aiOptions[iOption]));
} }
/**
* Creates random Number in range of iMin and iMax
* @param iMin
* @param iMax
* @return
*/
private static int randomNumber(int iMin, int iMax) {
return (int)(Math.random() * (iMax - iMin + 1) + iMin);
}
} }

View File

@@ -0,0 +1,72 @@
package View.MainFrame;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MyImages {
public static Image getLightKeyboardImage() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
try {
oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/light_default.png"));
} catch (IOException e) {
e.printStackTrace();
}
return oDefaultLightKeyboardBufferedImage.getScaledInstance(1000, 329, Image.SCALE_SMOOTH);
}
public static Image getLight_Key_0_Tilde_Image() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
try {
oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/single_keys/key_0_tilde.png"));
} catch (IOException e) {
e.printStackTrace();
}
return oDefaultLightKeyboardBufferedImage.getScaledInstance(74, 62, Image.SCALE_SMOOTH);
}
public static Image getLight_Key_1_One_Image() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
try {
oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/single_keys/key_1_one.png"));
} catch (IOException e) {
e.printStackTrace();
}
return oDefaultLightKeyboardBufferedImage.getScaledInstance(69, 62, Image.SCALE_SMOOTH);
}
public static Image getDarkKeyboardImage() {
BufferedImage oDefaultDarkKeyboardBufferedImage = null;
try {
oDefaultDarkKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/dark_mode/dark_default.png"));
} catch (IOException e) {
e.printStackTrace();
}
return oDefaultDarkKeyboardBufferedImage.getScaledInstance(1000, 329, Image.SCALE_SMOOTH);
}
public static Image getImage(int i) {
Image oImageToReturn = getLightKeyboardImage();
switch (i) {
case (0): {
oImageToReturn = getLightKeyboardImage();
}break;
case (1): {
oImageToReturn = getLight_Key_0_Tilde_Image();
}break;
case (2): {
oImageToReturn = getLight_Key_1_One_Image();
}break;
}
return oImageToReturn;
}
}

View File

@@ -1,7 +0,0 @@
package View.MainFrame;
import javax.swing.JPanel;
public class MyKeyboardPanel extends JPanel {
}

View File

@@ -0,0 +1,55 @@
package View.MainFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Dimension;
public class MyLayeredKeyboardPanel extends JPanel {
//[0] == If 0 image is not painted, if 1 image is painted
//[1] == x-Coordinate for image
//[2] == y-Coordinate for image
private int[][] aiiImages = new int[62][3];
private int iTheme = 0;
public MyLayeredKeyboardPanel() {
this.setPreferredSize(new Dimension(1000, 500));
initImagePositions();
}
@Override
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
for (int i = 0; i < aiiImages.length; i++) {
if (aiiImages[i][0] == 1) {
g2D.drawImage(MyImages.getImage(i), aiiImages[i][1], aiiImages[i][2], null);
}
}
}
public void setImage(int iSet, int iIndex) {
aiiImages[iIndex][0] = iSet;
}
public void setTheme(int i) {
iTheme = i;
}
private void initImagePositions() {
//Background
aiiImages[0][0] = 1;
aiiImages[0][1] = aiiImages[0][2] = 0;
//` / ~ Key
aiiImages[1][1] = 80;
aiiImages[1][2] = 1;
//1 / ! Key
aiiImages[2][1] = 142;
aiiImages[2][2] = 0;
}
}

View File

@@ -1,13 +1,734 @@
package View.MainFrame; package View.MainFrame;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel;
public class MyMainFrame extends JFrame { import java.awt.GridBagLayout;
JPanel[] aoPanels = new JPanel[2]; import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class MyMainFrame extends JFrame implements KeyListener {
private MyLayeredKeyboardPanel oKeyboardPanel;
private String sApplicationTitle = "Learning is KEYboard";
public MyMainFrame() { public MyMainFrame() {
aoPanels[0] = new JPanel();
aoPanels[1] = new JPanel(); this.setTitle(sApplicationTitle);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(true);
this.setSize(1000,500);
this.setVisible(true);
this.setLayout(new GridBagLayout());
this.setLocationRelativeTo(null);
this.addKeyListener(this);
oKeyboardPanel = new MyLayeredKeyboardPanel();
GridBagConstraints oConstraint = new GridBagConstraints();
oConstraint.anchor = GridBagConstraints.NORTHWEST;
oConstraint.weightx = 1;
oConstraint.weighty = 1;
oConstraint.gridx = 0;
oConstraint.gridy = 0;
oConstraint.insets = new Insets(0,0,0,0);
this.add(oKeyboardPanel, oConstraint);
this.pack();
oKeyboardPanel.repaint();
}
@Override
public void keyTyped(KeyEvent e) {
//Invoked when a key is typed. Uses KeyChar, char output
}
@Override
public void keyPressed(KeyEvent e) {
//Invoked when a physical key is pressed down. Uses KeyCode, int output
switch (e.getKeyChar()) {
//Row 1
case ('`'): {
oKeyboardPanel.setImage(1, 1);
oKeyboardPanel.repaint();
}break;
case ('~'): {
System.out.println("~");
}break;
case ('1'): {
oKeyboardPanel.setImage(1, 2);
oKeyboardPanel.repaint();
}break;
case ('!'): {
System.out.println("!");
}break;
case ('2'): {
System.out.println("2");
}break;
case ('@'): {
System.out.println("@");
}break;
case ('3'): {
System.out.println("3");
}break;
case ('#'): {
System.out.println("#");
}break;
case ('4'): {
System.out.println("4");
}break;
case ('$'): {
System.out.println("$");
}break;
case ('5'): {
System.out.println("5");
}break;
case ('%'): {
System.out.println("%");
}break;
case ('6'): {
System.out.println("6");
}break;
case ('^'): {
System.out.println("^");
}break;
case ('7'): {
System.out.println("7");
}break;
case ('&'): {
System.out.println("&");
}break;
case ('8'): {
System.out.println("8");
}break;
case ('*'): {
System.out.println("*");
}break;
case ('9'): {
System.out.println("9");
}break;
case ('('): {
System.out.println("(");
}break;
case ('0'): {
System.out.println("0");
}break;
case (')'): {
System.out.println(")");
}break;
case ('-'): {
System.out.println("-");
}break;
case ('_'): {
System.out.println("_");
}break;
case ('='): {
System.out.println("=");
}break;
case ('+'): {
System.out.println("+");
}break;
//Row 2
case ('q'): {
System.out.println("q");
}break;
case ('Q'): {
System.out.println("Q");
}break;
case ('w'): {
System.out.println("w");
}break;
case ('W'): {
System.out.println("W");
}break;
case ('e'): {
System.out.println("e");
}break;
case ('E'): {
System.out.println("E");
}break;
case ('r'): {
System.out.println("r");
}break;
case ('R'): {
System.out.println("R");
}break;
case ('t'): {
System.out.println("t");
}break;
case ('T'): {
System.out.println("T");
}break;
case ('y'): {
System.out.println("y");
}break;
case ('Y'): {
System.out.println("Y");
}break;
case ('u'): {
System.out.println("u");
}break;
case ('U'): {
System.out.println("U");
}break;
case ('i'): {
System.out.println("i");
}break;
case ('I'): {
System.out.println("I");
}break;
case ('o'): {
System.out.println("o");
}break;
case ('O'): {
System.out.println("O");
}break;
case ('p'): {
System.out.println("p");
}break;
case ('P'): {
System.out.println("P");
}break;
case ('['): {
System.out.println("[");
}break;
case ('{'): {
System.out.println("{");
}break;
case (']'): {
System.out.println("]");
}break;
case ('}'): {
System.out.println("}");
}break;
//Row 3
case ('a'): {
System.out.println("a");
}break;
case ('A'): {
System.out.println("A");
}break;
case ('s'): {
System.out.println("s");
}break;
case ('S'): {
System.out.println("S");
}break;
case ('d'): {
System.out.println("d");
}break;
case ('D'): {
System.out.println("D");
}break;
case ('f'): {
System.out.println("f");
}break;
case ('F'): {
System.out.println("F");
}break;
case ('g'): {
System.out.println("g");
}break;
case ('G'): {
System.out.println("G");
}break;
case ('h'): {
System.out.println("h");
}break;
case ('H'): {
System.out.println("H");
}break;
case ('j'): {
System.out.println("j");
}break;
case ('J'): {
System.out.println("J");
}break;
case ('k'): {
System.out.println("k");
}break;
case ('K'): {
System.out.println("K");
}break;
case ('l'): {
System.out.println("l");
}break;
case ('L'): {
System.out.println("L");
}break;
case (';'): {
System.out.println(";");
}break;
case (':'): {
System.out.println(":");
}break;
case ('\''): {
System.out.println("'");
}break;
case ('"'): {
System.out.println("\"");
}break;
case ('\\'): {
System.out.println("\\");
}break;
case ('|'): {
System.out.println("|");
}break;
//Row 4
case ('z'): {
System.out.println("z");
}break;
case ('Z'): {
System.out.println("Z");
}break;
case ('x'): {
System.out.println("x");
}break;
case ('X'): {
System.out.println("X");
}break;
case ('c'): {
System.out.println("c");
}break;
case ('C'): {
System.out.println("C");
}break;
case ('v'): {
System.out.println("v");
}break;
case ('V'): {
System.out.println("V");
}break;
case ('b'): {
System.out.println("b");
}break;
case ('B'): {
System.out.println("B");
}break;
case ('n'): {
System.out.println("n");
}break;
case ('N'): {
System.out.println("N");
}break;
case ('m'): {
System.out.println("m");
}break;
case ('M'): {
System.out.println("M");
}break;
case (','): {
System.out.println(",");
}break;
case ('<'): {
System.out.println("<");
}break;
case ('.'): {
System.out.println(".");
}break;
case ('>'): {
System.out.println(">");
}break;
case ('/'): {
System.out.println("/");
}break;
case ('?'): {
System.out.println("?");
}break;
}
switch (e.getKeyCode()) {
//Backspace
//<--
case (8): {
System.out.println("Backspace");
}break;
//Line feed
// |
//<--
case (10): {
System.out.println("Line feed");
}break;
//Data Link Escape
//Shift
case (16): {
System.out.println("Shift");
}break;
//Ctrl (Strg) Left / Right
case (17): {
System.out.println("Strg");
}break;
//Alt / Alt Gr
case (18): {
System.out.println("Alt");
}break;
//Space
case (32): {
System.out.println("Space");
}break;
//Windows Key Left / Right
case (524): {
System.out.println("Windows Key");
}break;
//Options
case (525): {
System.out.println("Options");
}break;
default:
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
//Called whenever a button is released
switch (e.getKeyChar()) {
//Row 1
case ('`'): {
oKeyboardPanel.setImage(0, 1);
oKeyboardPanel.repaint();
}break;
case ('~'): {
System.out.println("~");
}break;
case ('1'): {
oKeyboardPanel.setImage(0, 2);
oKeyboardPanel.repaint();
}break;
case ('!'): {
System.out.println("!");
}break;
case ('2'): {
System.out.println("2");
}break;
case ('@'): {
System.out.println("@");
}break;
case ('3'): {
System.out.println("3");
}break;
case ('#'): {
System.out.println("#");
}break;
case ('4'): {
System.out.println("4");
}break;
case ('$'): {
System.out.println("$");
}break;
case ('5'): {
System.out.println("5");
}break;
case ('%'): {
System.out.println("%");
}break;
case ('6'): {
System.out.println("6");
}break;
case ('^'): {
System.out.println("^");
}break;
case ('7'): {
System.out.println("7");
}break;
case ('&'): {
System.out.println("&");
}break;
case ('8'): {
System.out.println("8");
}break;
case ('*'): {
System.out.println("*");
}break;
case ('9'): {
System.out.println("9");
}break;
case ('('): {
System.out.println("(");
}break;
case ('0'): {
System.out.println("0");
}break;
case (')'): {
System.out.println(")");
}break;
case ('-'): {
System.out.println("-");
}break;
case ('_'): {
System.out.println("_");
}break;
case ('='): {
System.out.println("=");
}break;
case ('+'): {
System.out.println("+");
}break;
//Row 2
case ('q'): {
System.out.println("q");
}break;
case ('Q'): {
System.out.println("Q");
}break;
case ('w'): {
System.out.println("w");
}break;
case ('W'): {
System.out.println("W");
}break;
case ('e'): {
System.out.println("e");
}break;
case ('E'): {
System.out.println("E");
}break;
case ('r'): {
System.out.println("r");
}break;
case ('R'): {
System.out.println("R");
}break;
case ('t'): {
System.out.println("t");
}break;
case ('T'): {
System.out.println("T");
}break;
case ('y'): {
System.out.println("y");
}break;
case ('Y'): {
System.out.println("Y");
}break;
case ('u'): {
System.out.println("u");
}break;
case ('U'): {
System.out.println("U");
}break;
case ('i'): {
System.out.println("i");
}break;
case ('I'): {
System.out.println("I");
}break;
case ('o'): {
System.out.println("o");
}break;
case ('O'): {
System.out.println("O");
}break;
case ('p'): {
System.out.println("p");
}break;
case ('P'): {
System.out.println("P");
}break;
case ('['): {
System.out.println("[");
}break;
case ('{'): {
System.out.println("{");
}break;
case (']'): {
System.out.println("]");
}break;
case ('}'): {
System.out.println("}");
}break;
//Row 3
case ('a'): {
System.out.println("a");
}break;
case ('A'): {
System.out.println("A");
}break;
case ('s'): {
System.out.println("s");
}break;
case ('S'): {
System.out.println("S");
}break;
case ('d'): {
System.out.println("d");
}break;
case ('D'): {
System.out.println("D");
}break;
case ('f'): {
System.out.println("f");
}break;
case ('F'): {
System.out.println("F");
}break;
case ('g'): {
System.out.println("g");
}break;
case ('G'): {
System.out.println("G");
}break;
case ('h'): {
System.out.println("h");
}break;
case ('H'): {
System.out.println("H");
}break;
case ('j'): {
System.out.println("j");
}break;
case ('J'): {
System.out.println("J");
}break;
case ('k'): {
System.out.println("k");
}break;
case ('K'): {
System.out.println("K");
}break;
case ('l'): {
System.out.println("l");
}break;
case ('L'): {
System.out.println("L");
}break;
case (';'): {
System.out.println(";");
}break;
case (':'): {
System.out.println(":");
}break;
case ('\''): {
System.out.println("'");
}break;
case ('"'): {
System.out.println("\"");
}break;
case ('\\'): {
System.out.println("\\");
}break;
case ('|'): {
System.out.println("|");
}break;
//Row 4
case ('z'): {
System.out.println("z");
}break;
case ('Z'): {
System.out.println("Z");
}break;
case ('x'): {
System.out.println("x");
}break;
case ('X'): {
System.out.println("X");
}break;
case ('c'): {
System.out.println("c");
}break;
case ('C'): {
System.out.println("C");
}break;
case ('v'): {
System.out.println("v");
}break;
case ('V'): {
System.out.println("V");
}break;
case ('b'): {
System.out.println("b");
}break;
case ('B'): {
System.out.println("B");
}break;
case ('n'): {
System.out.println("n");
}break;
case ('N'): {
System.out.println("N");
}break;
case ('m'): {
System.out.println("m");
}break;
case ('M'): {
System.out.println("M");
}break;
case (','): {
System.out.println(",");
}break;
case ('<'): {
System.out.println("<");
}break;
case ('.'): {
System.out.println(".");
}break;
case ('>'): {
System.out.println(">");
}break;
case ('/'): {
System.out.println("/");
}break;
case ('?'): {
System.out.println("?");
}break;
}
switch (e.getKeyCode()) {
//Backspace
//<--
case (8): {
System.out.println("Backspace");
}break;
//Line feed
// |
//<--
case (10): {
System.out.println("Line feed");
}break;
//Data Link Escape
//Shift
case (16): {
System.out.println("Shift");
}break;
//Ctrl (Strg) Left / Right
case (17): {
System.out.println("Strg");
}break;
//Alt / Alt Gr
case (18): {
System.out.println("Alt");
}break;
//Space
case (32): {
System.out.println("Space");
}break;
//Windows Key Left / Right
case (524): {
System.out.println("Windows Key");
}break;
//Options
case (525): {
System.out.println("Options");
}break;
default:
break;
}
} }
} }

View File

@@ -12,7 +12,7 @@ public class MyView {
public MyView(ModelData oModelData) { public MyView(ModelData oModelData) {
this.oModelData = oModelData; this.oModelData = oModelData;
oMainFrame = new MyMainFrame();
} }
public void updateView(ModelData oModelData) { public void updateView(ModelData oModelData) {