The title bar only shows after I click run, the frame is not working.... Here is my code I have no ideas what is going on! Can someone help me?
import java.awt.Canvas;
import javax.swing.JFrame;
public class Display extends Canvas implements Runnable {
private static final long serialVersionUID = 1L;
public static final int WIDTH = 800;
public static final int HEIGH = 600;
public static String TITLE = "3D Game";
private Thread thread;
private boolean running = false;
private void start(){
if(running) return;
running = true;
thread = new Thread();
thread.start();
System.out.println("Working");
}
private void stop(){
if(!running)
return;
running = false;
try{
thread.join();
}catch (Exception e){
e.printStackTrace();
System.exit(0);
}
}
public void run(){
while(running){
}
}
public static void main(String[] args){
Display game = new Display();
JFrame frame = new JFrame();
frame.add(game);
//frame.pack();
frame.setTitle(TITLE);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH,HEIGHT);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
game.start();
}
}