Created
November 3, 2015 04:34
-
-
Save DenWav/2c4f5991c464227ca492 to your computer and use it in GitHub Desktop.
wat.jpg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Position getPosition(JLabel label) { | |
// This method is proof I am an idiot | |
String text = ""; | |
Class<BoardGUI> clazz = BoardGUI.class; | |
Field[] fields = clazz.getDeclaredFields(); | |
for (Field field : fields) { | |
if (field.getDeclaringClass() == JLabel.class) { | |
try { | |
if (field.get(this) == label) { | |
text = field.getName(); | |
} | |
} catch (IllegalAccessException ignored) {/*won't happen*/} | |
} | |
} | |
int x = Integer.parseInt(text.substring(3, 4)); | |
int y = Integer.parseInt(text.substring(4, 5)); | |
return new Position(x, y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment