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() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
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) {
e.printStackTrace();
}
@@ -69,10 +69,6 @@ public class MyImages {
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() {
BufferedImage oDefaultLightKeyboardBufferedImage = null;
try {
@@ -84,6 +80,17 @@ public class MyImages {
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() {
BufferedImage oDefaultDarkKeyboardBufferedImage = null;
try {
@@ -116,6 +123,9 @@ public class MyImages {
case (15): {
oImageToReturn = getLight_Key_15_Q_Image();
}break;
case (41): {
oImageToReturn = getLight_Key_41_Shift_Image();
}break;
}
return oImageToReturn;
}

View File

@@ -8,6 +8,12 @@ import java.awt.Dimension;
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
//[1] == x-Coordinate for image
//[2] == y-Coordinate for image
@@ -63,5 +69,9 @@ public class MyLayeredKeyboardPanel extends JPanel {
//Q Key
aiiImages[15][1] = 156;
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
//Shift
case (16): {
System.out.println("Shift");
oKeyboardPanel.setImage(1, 41);
}break;
//Ctrl (Strg) Left / Right
case (17): {
@@ -465,52 +465,52 @@ public class MyMainFrame extends JFrame implements KeyListener {
oKeyboardPanel.setImage(0, 5);
}break;
case ('5'): {
System.out.println("5");
oKeyboardPanel.setImage(0, 6);
}break;
case ('%'): {
System.out.println("%");
oKeyboardPanel.setImage(0, 6);
}break;
case ('6'): {
System.out.println("6");
oKeyboardPanel.setImage(0, 7);
}break;
case ('^'): {
System.out.println("^");
oKeyboardPanel.setImage(0, 7);
}break;
case ('7'): {
System.out.println("7");
oKeyboardPanel.setImage(0, 8);
}break;
case ('&'): {
System.out.println("&");
oKeyboardPanel.setImage(0, 8);
}break;
case ('8'): {
System.out.println("8");
oKeyboardPanel.setImage(0, 9);
}break;
case ('*'): {
System.out.println("*");
oKeyboardPanel.setImage(0, 9);
}break;
case ('9'): {
System.out.println("9");
oKeyboardPanel.setImage(0, 10);
}break;
case ('('): {
System.out.println("(");
oKeyboardPanel.setImage(0, 10);
}break;
case ('0'): {
System.out.println("0");
oKeyboardPanel.setImage(0, 11);
}break;
case (')'): {
System.out.println(")");
oKeyboardPanel.setImage(0, 11);
}break;
case ('-'): {
System.out.println("-");
oKeyboardPanel.setImage(0, 12);
}break;
case ('_'): {
System.out.println("_");
oKeyboardPanel.setImage(0, 12);
}break;
case ('='): {
System.out.println("=");
oKeyboardPanel.setImage(0, 13);
}break;
case ('+'): {
System.out.println("+");
oKeyboardPanel.setImage(0, 13);
}break;
//Row 2
@@ -521,10 +521,10 @@ public class MyMainFrame extends JFrame implements KeyListener {
oKeyboardPanel.setImage(0, 15);
}break;
case ('w'): {
System.out.println("w");
oKeyboardPanel.setImage(0, 16);
}break;
case ('W'): {
System.out.println("W");
oKeyboardPanel.setImage(0, 16);
}break;
case ('e'): {
System.out.println("e");
@@ -739,7 +739,7 @@ public class MyMainFrame extends JFrame implements KeyListener {
//Data Link Escape
//Shift
case (16): {
System.out.println("Shift");
oKeyboardPanel.setImage(0, 41);
}break;
//Ctrl (Strg) Left / Right
case (17): {