First off all, I know questiones like this has been asked before, but no answers seem to fix my problem.
I am working on a little game, and for some reason java returns an IllegalStateException whenever I try to create a new bufferstrategy. I am adding the game to a JFrame, but the exception is still thrown, here is the code for adding to the JFrame:
JFrame frame;
public Window(int x, int y, int width, int height, String title, boolean focus, Main game) throws IOException {
frame = new JFrame();
frame.setLocation(x, y);
frame.setSize(new Dimension(width, height));
frame.setTitle(title);
frame.add(game);
game.start();
frame.setAutoRequestFocus(focus);
frame.setFocusable(true);
frame.setVisible(true);
}
And here is the code for creating the window (located in the Main class):
window = new Window(x, y, WIDTH, HEIGHT, "Title", true, this);