added key a, shift animation

This commit is contained in:
WickedJack99
2022-06-12 22:32:44 +02:00
parent af3ff4ce83
commit f40af3df83
9 changed files with 45 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -13,7 +13,7 @@ public class MyImages {
public static Image getLightKeyboardImage() { public static Image getLightKeyboardImage() {
BufferedImage oDefaultLightKeyboardBufferedImage = null; BufferedImage oDefaultLightKeyboardBufferedImage = null;
try { try {
oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/light_default.png")); oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/light_default2.png"));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -69,10 +69,6 @@ public class MyImages {
return oDefaultLightKeyboardBufferedImage.getScaledInstance(110, 76, Image.SCALE_SMOOTH); return oDefaultLightKeyboardBufferedImage.getScaledInstance(110, 76, Image.SCALE_SMOOTH);
} }
/**
* Doesn't get called since keyevent doesn't recognize if tab was pressed.
* @return
*/
public static Image getLight_Key_15_Q_Image() { public static Image getLight_Key_15_Q_Image() {
BufferedImage oDefaultLightKeyboardBufferedImage = null; BufferedImage oDefaultLightKeyboardBufferedImage = null;
try { try {
@@ -84,6 +80,17 @@ public class MyImages {
return oDefaultLightKeyboardBufferedImage.getScaledInstance(89, 87, Image.SCALE_SMOOTH); return oDefaultLightKeyboardBufferedImage.getScaledInstance(89, 87, Image.SCALE_SMOOTH);
} }
public static Image getLight_Key_41_Shift_Image() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
try {
oDefaultLightKeyboardBufferedImage = ImageIO.read(new File("Learning_is_keyboard/graphics/light_mode/single_keys/key_41_shift.png"));
} catch (IOException e) {
e.printStackTrace();
}
return oDefaultLightKeyboardBufferedImage.getScaledInstance(909, 98, Image.SCALE_SMOOTH);
}
public static Image getDarkKeyboardImage() { public static Image getDarkKeyboardImage() {
BufferedImage oDefaultDarkKeyboardBufferedImage = null; BufferedImage oDefaultDarkKeyboardBufferedImage = null;
try { try {
@@ -116,6 +123,9 @@ public class MyImages {
case (15): { case (15): {
oImageToReturn = getLight_Key_15_Q_Image(); oImageToReturn = getLight_Key_15_Q_Image();
}break; }break;
case (41): {
oImageToReturn = getLight_Key_41_Shift_Image();
}break;
} }
return oImageToReturn; return oImageToReturn;
} }

View File

@@ -8,6 +8,12 @@ import java.awt.Dimension;
public class MyLayeredKeyboardPanel extends JPanel { public class MyLayeredKeyboardPanel extends JPanel {
//Had a problem with printing multiple keys on screen.
//Because if new key is pressed, old information about other pressed key is lost.
//Because of that I use an array which contains information about all keys if they are pressed or not.
//Unfortunately the keyevent interface only detects maximum two pressed keys.
//Don't know yet if it counts for all key-listening.
//[0] == If 0 image is not painted, if 1 image is painted //[0] == If 0 image is not painted, if 1 image is painted
//[1] == x-Coordinate for image //[1] == x-Coordinate for image
//[2] == y-Coordinate for image //[2] == y-Coordinate for image
@@ -63,5 +69,9 @@ public class MyLayeredKeyboardPanel extends JPanel {
//Q Key //Q Key
aiiImages[15][1] = 156; aiiImages[15][1] = 156;
aiiImages[15][2] = 45; aiiImages[15][2] = 45;
//Shift Key
aiiImages[41][1] = 46;
aiiImages[41][2] = 150;
} }
} }

View File

@@ -386,7 +386,7 @@ public class MyMainFrame extends JFrame implements KeyListener {
//Data Link Escape //Data Link Escape
//Shift //Shift
case (16): { case (16): {
System.out.println("Shift"); oKeyboardPanel.setImage(1, 41);
}break; }break;
//Ctrl (Strg) Left / Right //Ctrl (Strg) Left / Right
case (17): { case (17): {
@@ -465,52 +465,52 @@ public class MyMainFrame extends JFrame implements KeyListener {
oKeyboardPanel.setImage(0, 5); oKeyboardPanel.setImage(0, 5);
}break; }break;
case ('5'): { case ('5'): {
System.out.println("5"); oKeyboardPanel.setImage(0, 6);
}break; }break;
case ('%'): { case ('%'): {
System.out.println("%"); oKeyboardPanel.setImage(0, 6);
}break; }break;
case ('6'): { case ('6'): {
System.out.println("6"); oKeyboardPanel.setImage(0, 7);
}break; }break;
case ('^'): { case ('^'): {
System.out.println("^"); oKeyboardPanel.setImage(0, 7);
}break; }break;
case ('7'): { case ('7'): {
System.out.println("7"); oKeyboardPanel.setImage(0, 8);
}break; }break;
case ('&'): { case ('&'): {
System.out.println("&"); oKeyboardPanel.setImage(0, 8);
}break; }break;
case ('8'): { case ('8'): {
System.out.println("8"); oKeyboardPanel.setImage(0, 9);
}break; }break;
case ('*'): { case ('*'): {
System.out.println("*"); oKeyboardPanel.setImage(0, 9);
}break; }break;
case ('9'): { case ('9'): {
System.out.println("9"); oKeyboardPanel.setImage(0, 10);
}break; }break;
case ('('): { case ('('): {
System.out.println("("); oKeyboardPanel.setImage(0, 10);
}break; }break;
case ('0'): { case ('0'): {
System.out.println("0"); oKeyboardPanel.setImage(0, 11);
}break; }break;
case (')'): { case (')'): {
System.out.println(")"); oKeyboardPanel.setImage(0, 11);
}break; }break;
case ('-'): { case ('-'): {
System.out.println("-"); oKeyboardPanel.setImage(0, 12);
}break; }break;
case ('_'): { case ('_'): {
System.out.println("_"); oKeyboardPanel.setImage(0, 12);
}break; }break;
case ('='): { case ('='): {
System.out.println("="); oKeyboardPanel.setImage(0, 13);
}break; }break;
case ('+'): { case ('+'): {
System.out.println("+"); oKeyboardPanel.setImage(0, 13);
}break; }break;
//Row 2 //Row 2
@@ -521,10 +521,10 @@ public class MyMainFrame extends JFrame implements KeyListener {
oKeyboardPanel.setImage(0, 15); oKeyboardPanel.setImage(0, 15);
}break; }break;
case ('w'): { case ('w'): {
System.out.println("w"); oKeyboardPanel.setImage(0, 16);
}break; }break;
case ('W'): { case ('W'): {
System.out.println("W"); oKeyboardPanel.setImage(0, 16);
}break; }break;
case ('e'): { case ('e'): {
System.out.println("e"); System.out.println("e");
@@ -739,7 +739,7 @@ public class MyMainFrame extends JFrame implements KeyListener {
//Data Link Escape //Data Link Escape
//Shift //Shift
case (16): { case (16): {
System.out.println("Shift"); oKeyboardPanel.setImage(0, 41);
}break; }break;
//Ctrl (Strg) Left / Right //Ctrl (Strg) Left / Right
case (17): { case (17): {