Question may be different than what you expected, but I'm creating a utility function for JFrames to make it easier for future me.
public void setJframe(String title, int w,int h, JFrame name, Boolean maximize){
name.setSize(w, h);
name.setTitle(title);
if (maximize == true) {
name.setExtendedState(name.getExtendedState()|JFrame.MAXIMIZED_BOTH);
} else {
name.setLocationRelativeTo(null);
}
}
I want the ability to name the JFrame as I type in the parameters. At the moment, when I type in a string it simply spits out an error saying I can't use a string? I want "name" to be like a string variable where I can type in a string value and have the object be named that.
Edit: Need to make the question more clear...
PackageName.setJframe("Title of the Frame", 500, 800, f, false);
Returns this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
f cannot be resolved
f cannot be resolved
at gui.GuiMain.guiSet(GuiMain.java:17)
at urAPackage.Main.main(Main.java:8)
Eclipse says method f is not applicable to constructor
See Question&Answers more detail:os