1
'da InterrupedException gerektiren bir yöntemi nasıl çağırırım Bir düğmeye basabilmeyi ve Java 2d kullanarak küçük bir oyun oluşturmayı istiyorum.JButton ActionListner
: oluşturmak yönteminden kodudur i try/catch kullanmaya çalıştık ama buradaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
game.create();/***is a new window with a small 2d game,
the 'create' method requires and InterruptedException to be thrown.***/
}
});
(çünkü sanırım oluşturmak yönteminde ise döngü) sonsuz döngüye takılıyor
public void create() throws InterruptedException {
JFrame frame = new JFrame("Mini Tennis");
GameMain gamemain = new GameMain();
frame.add(gamemain);
frame.setSize(350, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
while (true) {
gamemain.move();
gamemain.repaint();
Thread.sleep(10);
}
}
evet mükemmel teşekkür ederim! – tamalon
Yardım etmekten mutluluk duyuyorum! –