diff --git a/Learning_is_keyboard/graphics/dark_mode/dark_default.png b/Learning_is_keyboard/graphics/dark_mode/dark_default.png new file mode 100644 index 0000000..d1a2d4b Binary files /dev/null and b/Learning_is_keyboard/graphics/dark_mode/dark_default.png differ diff --git a/Learning_is_keyboard/graphics/light_mode/single_keys/key_0_tilde.png b/Learning_is_keyboard/graphics/light_mode/single_keys/key_0_tilde.png new file mode 100644 index 0000000..942d85b Binary files /dev/null and b/Learning_is_keyboard/graphics/light_mode/single_keys/key_0_tilde.png differ diff --git a/Learning_is_keyboard/graphics/light_mode/single_keys/key_1_one.png b/Learning_is_keyboard/graphics/light_mode/single_keys/key_1_one.png new file mode 100644 index 0000000..1b1bdd0 Binary files /dev/null and b/Learning_is_keyboard/graphics/light_mode/single_keys/key_1_one.png differ diff --git a/Learning_is_keyboard/graphics/light_mode/single_keys/lightbluergb.txt b/Learning_is_keyboard/graphics/light_mode/single_keys/lightbluergb.txt new file mode 100644 index 0000000..0d98324 --- /dev/null +++ b/Learning_is_keyboard/graphics/light_mode/single_keys/lightbluergb.txt @@ -0,0 +1,5 @@ +172 +248 +245 + +acf8f5 \ No newline at end of file diff --git a/Learning_is_keyboard/graphics/light_mode/single_keys_afphoto/tilde.afphoto b/Learning_is_keyboard/graphics/light_mode/single_keys_afphoto/tilde.afphoto new file mode 100644 index 0000000..73e641e Binary files /dev/null and b/Learning_is_keyboard/graphics/light_mode/single_keys_afphoto/tilde.afphoto differ diff --git a/Learning_is_keyboard/src/Model/ModelCommands.java b/Learning_is_keyboard/src/Model/ModelCommands.java new file mode 100644 index 0000000..a8d04ec --- /dev/null +++ b/Learning_is_keyboard/src/Model/ModelCommands.java @@ -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); + } +} \ No newline at end of file diff --git a/Learning_is_keyboard/src/Model/MyModel.java b/Learning_is_keyboard/src/Model/MyModel.java index d8ba0cc..87f1f3a 100644 --- a/Learning_is_keyboard/src/Model/MyModel.java +++ b/Learning_is_keyboard/src/Model/MyModel.java @@ -36,11 +36,43 @@ public class MyModel extends Thread { System.out.println("Command: " + iModelCommand); switch (iModelCommand) { case (1): { - oModelData = new ModelData(RandomTextCreator.createText(300)); - qDataToMain.add(oModelData); + }break; 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; } } @@ -51,4 +83,16 @@ public class MyModel extends Thread { public void setModelCommand(int iModelCommand) { this.iModelCommand = iModelCommand; } -} + + public void setModelData(ModelData oModelData) { + this.oModelData = oModelData; + } + + public ModelData getModelData() { + return this.oModelData; + } + + public ConcurrentLinkedQueue getModelQueueToMain() { + return this.qDataToMain; + } +} \ No newline at end of file diff --git a/Learning_is_keyboard/src/Model/RandomTextCreator.java b/Learning_is_keyboard/src/Model/RandomTextCreator.java index 7fe116c..18ce077 100644 --- a/Learning_is_keyboard/src/Model/RandomTextCreator.java +++ b/Learning_is_keyboard/src/Model/RandomTextCreator.java @@ -1,6 +1,312 @@ package Model; 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) { String sReturn = ""; int iLastOption = 0; @@ -12,10 +318,10 @@ public class RandomTextCreator { iMin = 1; 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) { - iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); + iOption = randomNumber(iMin, iMax); } switch (iOption) { @@ -45,28 +351,19 @@ public class RandomTextCreator { //48-57 0-9 private static String createText0() { - //Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min - int iMin = 48; - int iMax = 57; - int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); + int iOption = randomNumber(48, 57); return String.valueOf(Character.toChars(iOption)); } //65-90 A-Z private static String createText1() { - //Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min - int iMin = 65; - int iMax = 90; - int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); + int iOption = randomNumber(65, 90); return String.valueOf(Character.toChars(iOption)); } //97-122 a-z private static String createText2() { - //Formula to calculate random value between max and min. Math.random() * (max - min + 1) + min - int iMin = 97; - int iMax = 122; - int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); + int iOption = randomNumber(97, 122); 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 private static String createText3() { 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 iMin = 0; - int iMax = 11; - int iOption = (int)(Math.random() * (iMax - iMin + 1) + iMin); + int iOption = randomNumber(0, 11); 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); + } } \ No newline at end of file diff --git a/Learning_is_keyboard/src/View/MainFrame/MyImages.java b/Learning_is_keyboard/src/View/MainFrame/MyImages.java new file mode 100644 index 0000000..02125c5 --- /dev/null +++ b/Learning_is_keyboard/src/View/MainFrame/MyImages.java @@ -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; + } +} diff --git a/Learning_is_keyboard/src/View/MainFrame/MyKeyboardPanel.java b/Learning_is_keyboard/src/View/MainFrame/MyKeyboardPanel.java deleted file mode 100644 index 9ec60bf..0000000 --- a/Learning_is_keyboard/src/View/MainFrame/MyKeyboardPanel.java +++ /dev/null @@ -1,7 +0,0 @@ -package View.MainFrame; - -import javax.swing.JPanel; - -public class MyKeyboardPanel extends JPanel { - -} diff --git a/Learning_is_keyboard/src/View/MainFrame/MyLayeredKeyboardPanel.java b/Learning_is_keyboard/src/View/MainFrame/MyLayeredKeyboardPanel.java new file mode 100644 index 0000000..39f1598 --- /dev/null +++ b/Learning_is_keyboard/src/View/MainFrame/MyLayeredKeyboardPanel.java @@ -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; + } +} \ No newline at end of file diff --git a/Learning_is_keyboard/src/View/MainFrame/MyMainFrame.java b/Learning_is_keyboard/src/View/MainFrame/MyMainFrame.java index 70e6ede..0e58ab2 100644 --- a/Learning_is_keyboard/src/View/MainFrame/MyMainFrame.java +++ b/Learning_is_keyboard/src/View/MainFrame/MyMainFrame.java @@ -1,13 +1,734 @@ package View.MainFrame; import javax.swing.JFrame; -import javax.swing.JPanel; -public class MyMainFrame extends JFrame { - JPanel[] aoPanels = new JPanel[2]; +import java.awt.GridBagLayout; +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() { - 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; + } } } diff --git a/Learning_is_keyboard/src/View/MyView.java b/Learning_is_keyboard/src/View/MyView.java index 756442b..3480d2f 100644 --- a/Learning_is_keyboard/src/View/MyView.java +++ b/Learning_is_keyboard/src/View/MyView.java @@ -12,7 +12,7 @@ public class MyView { public MyView(ModelData oModelData) { this.oModelData = oModelData; - + oMainFrame = new MyMainFrame(); } public void updateView(ModelData oModelData) {