diff --git a/out/production/Tetris/Tetris/Board.class b/out/production/Tetris/Tetris/Board.class index e993e50..a3df1af 100644 Binary files a/out/production/Tetris/Tetris/Board.class and b/out/production/Tetris/Tetris/Board.class differ diff --git a/out/production/Tetris/Tetris/GameGui.class b/out/production/Tetris/Tetris/GameGui.class index 5b67cdb..29f2317 100644 Binary files a/out/production/Tetris/Tetris/GameGui.class and b/out/production/Tetris/Tetris/GameGui.class differ diff --git a/src/Tetris/Board.java b/src/Tetris/Board.java index 49dd7ce..b6274ee 100644 --- a/src/Tetris/Board.java +++ b/src/Tetris/Board.java @@ -32,6 +32,7 @@ public class Board extends JPanel implements KeyListener private int delayTime = normal; public Board() { + loop = new Timer(delay, new ActionListener() { int n = 0; @@ -64,7 +65,6 @@ public class Board extends JPanel implements KeyListener g.fillRect(col*BLOCK_SIZE+x*BLOCK_SIZE,row*BLOCK_SIZE+y*BLOCK_SIZE,BLOCK_SIZE,BLOCK_SIZE); } } - } for (int row = 0; row < BOARD_HEIGHT+1; row++) { @@ -83,9 +83,9 @@ public class Board extends JPanel implements KeyListener @Override public void keyPressed(KeyEvent e) { - if(e.getKeyChar() == KeyEvent.VK_SPACE){ - delayTime=fast; - } + if(e.getKeyChar() == KeyEvent.VK_SPACE){ + delayTime=fast; + } } @Override diff --git a/src/Tetris/GameGui.java b/src/Tetris/GameGui.java index 55a5363..a90d4e2 100644 --- a/src/Tetris/GameGui.java +++ b/src/Tetris/GameGui.java @@ -9,10 +9,10 @@ public class GameGui { //Zhe Wang-Holkenbrink public GameGui(){ - + frame = new JFrame("Tetris"); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createMatteBorder(400, 10, 10, 10,Color.black)); -/* + //Label JLabel label = new JLabel(" Ihr Name:"); panel.add(label); @@ -29,14 +29,13 @@ public class GameGui { button1.setPreferredSize( new Dimension(150,50)); JButton button2 = new JButton("Pause"); JButton button3 = new JButton("Score"); - + //Button untereinander panel.setLayout(new GridLayout(0,1)); panel.setBackground(Color.LIGHT_GRAY); panel.add(button1); panel.add(button2); panel.add(button3); -*/ - frame = new JFrame("Tetris"); + frame.add(panel,BorderLayout.EAST); frame.setSize(width,height); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -45,6 +44,7 @@ public class GameGui { board = new Board(); frame.addKeyListener(board); frame.add(board,BorderLayout.CENTER); + frame.requestFocusInWindow(); } public static void main(String [] args) {