I am trying to update my look and feel without any errors, but I can't figure out what I am doing wrong.
This is my Window class:
public class Window extends JFrame {
private static final long serialVersionUID = 1L;
public Window() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new MigLayout());
setExtendedState(JFrame.MAXIMIZED_BOTH);
setMinimumSize(new Dimension(600, 700));
setVisible(true);
setContentPane(new JPanel() {
private static final long serialVersionUID = 1L;
public void paintComponent(Graphics g) {
g.drawImage(new ImageIcon("start.jpg").getImage(), 0, 0, getWidth(),
getHeight(), this);
}
});
}
}
And this is my main where I update the UI (Look and Feel)
public class Main {
public static void main(String[] args) {
Window.setDefaultLookAndFeelDecorated(true);
try {
UIManager.setLookAndFeel(new SubstanceGraphiteLookAndFeel());
}
catch (UnsupportedLookAndFeelException e) {}
Window window = new Window();
}
}
The console says my error comes from this line: Window window = new Window();
Then this line: setContentPane(new JPanel() {
But if I delete the whole setContentPane bloc, the error then points to the constructor.
Any help would be appreciated. Thank you!