i want to set the size of the frame with the WIDTH and the HEIGHT declared in the enum in
setSize(dimension.getValue(), dimension.getValue());
but when i made a test i receive in output not the enum values but the enum cardinal orders in this case {1,2}. how i have to change my code to return the correct values?
public enum Dimension {
WIDTH(700), HEIGHT(400);
private final int value;
private Dimension(int value) {
this.value = value;
}
public int getValue(){
return value;
}
}
public class MainFrame extends JFrame {
private Dimension dimension;
public static void main(String[] args) {
final MainFrame mainFrame = new MainFrame();
mainFrame.setVisible(true);
}
public MainFrame() {
initGameFrame();
}
private void initGameFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(dimension.getValue(), dimension.getValue());
add(gamePanel);
setResizable(false);
setUndecorated(true);
pack();
setLocationRelativeTo(null);
}
}
dimension?null.