I started a new project, all the code is right (I think) and no window is appearing. There are no compilation errors, whenever I run the program nothing happens.
import javax.swing.*;
import java.awt.*;
public class Frame extends JFrame{
public static String title = "Tower Defense";
public static Dimension size = new Dimension(700, 550);
public static void main(String args[]){
Frame frame = new Frame();
}
public Frame() {
setTitle(title);
setSize(size);
setResizable(false);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void init(){
setVisible(true);
}
}
You never call
init()method. How can your frame be visible?Just change your
mainmethod to: