This question already has an answer here:
- Assigning variables with dynamic names in Java 7 answers
Trying to get a better understanding of Swing and AWT with constructors, but now I have a question about constructors.
Based on whether or not the boolean maximize is true I want to set a new public boolean variable with the same value. Thing is I might need multiple JFrames but I can't have the same public variable name created if true. How do I instantiate a boolean with a name based off of a dynamic string
public void setJframe(JFrame name, boolean maximize,) {
if (maximize == true){
name.setExtendedState(name.getExtendedState()|JFrame.MAXIMIZED_BOTH);
}
else {
name.setLocationRelativeTo(null);
}
}
Extra clarification
In the if part, it would be something like if it's remotely possible. The parenthesis are meant to indicate the whole variable name and inside a reflection mixed with a string
public boolean (getField(name) + "Max") = maximize;
I'm aware compilers do things a certain way just don't eat me alive if what I put here doesn't reflect that.