I have read posts on this, so I'm aware about how static variables should be avoided, they are not object oriented, they're like globals etc.
But here's my question, hopefully it's not a repeat: I have some private class variables that many methods use and passing around would be tedious. The class I'm talking about is my main program, so the only instance of it will be the instance that the JVM creates.
In this case does it make any difference if these variables are static or not ? (Perhaps if a user opens my application multiple times and I make the variables static, they would share the variables and mix each other up?)
I'd like to use statics because want to access these variables from inside enums. Thanks
Here's the code for the enum part:
enum Buttons {
OPEN_BUTTON("Open file...",false),
CHANGE_FONT_BUTTON("Change font",false),
DECOR_BUTTON("Decor font",true),
EDITOR_BUTTON("Open editor",false),
ALPHABET_BUTTON("Open alphabet browser",false),
CTEST_BUTTON("Start consonant test",false),
TESTTYPE_BUTTON("Select test type...",false),
TEST_BUTTON("Start word test",false),
QUIT_BUTTON("Quit", false);
private ButtonBase button;
Buttons(String title, boolean toggle) {
if (toggle) button = ToggleButtonBuilder.create().prefWidth(200).prefHeight(35).text(title).build();
else button = ButtonBuilder.create().prefWidth(200).prefHeight(35).text(title).build();}
void onClick(EventHandler<MouseEvent> eh) {button.setOnMouseClicked(eh);}
ButtonBase getBase() {return button;}
boolean toggled() { return ((ToggleButton)button).isSelected(); }
void setToggle(boolean on) {((ToggleButton) button).setSelected(on); }
void enable() {button.setDisable(false);}
void disable() {button.setDisable(true);}
void setText(String text) { button.setText(text);}
void clicked() {
// this is where i'd like to have the event handlers...