Also ich hab angefangen ein Fester in einer anderen Klasse über eine Methode aufzubauen.
Soweit so gut, aber egal welche WIDTH ich einstelle das Fenster wird nie breiter als 4cm, es wird
stat dessen länger o.O WTF
- Ich hab den Code in einem Tutorial mitgeschrieben und bei dem passt alles. Tell me how … PLS
import java.awt.Canvas;
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = -1009013565482847585L;
public static final int WIDHT = 640, HEIGHT = 640;
public Game(){
new Window(WIDTH, HEIGHT, "Game", this);
}
public synchronized void start(){
}
public void run(){
}
public static void main(String[] args) {
new Game();
}
}
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
public class Window extends Canvas{
private static final long serialVersionUID = -2681461688794138902L;
public Window(int width, int height, String title, Game game){
JFrame frame = new JFrame(title);
frame.setPreferredSize(new Dimension(width, height));
frame.setMaximumSize(new Dimension(width, height));
frame.setMinimumSize(new Dimension(width, height));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.add(game);
frame.setVisible(true);
game.start();
}
}