From 4d0f9a10ba0e241798bbf67088070e3c5ed564a0 Mon Sep 17 00:00:00 2001 From: zhe Date: Fri, 19 Nov 2021 12:37:20 +0100 Subject: [PATCH] Problem mit Button und Label aufgehoben --- out/production/Tetris/Tetris/Board.class | Bin 2726 -> 2726 bytes out/production/Tetris/Tetris/GameGui.class | Bin 1426 -> 2374 bytes src/Tetris/Board.java | 8 ++++---- src/Tetris/GameGui.java | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/out/production/Tetris/Tetris/Board.class b/out/production/Tetris/Tetris/Board.class index e993e505cfaede826bc702fd1bf58a38a511fe2a..a3df1af0d80d01d7a798a95ab7dd6e0b7c09a348 100644 GIT binary patch delta 64 zcmZ1`x=eJ#0ya(+hH3^Qh9(B%$t&4js+u#fGFUJOGgvZ6G1xGuGS~v;?0}>_gC~O{ QLne@w&tS88JNtVk0LA(ZO#lD@ delta 64 zcmZ1`x=eJ#0ya)%hH3^wh9(B1$t&4js+uvdGMF<6GgvT4F<3LGGT1N}G1vm39fK!> R14AZ|pU+^uc{}@iCIG~44L|?@ diff --git a/out/production/Tetris/Tetris/GameGui.class b/out/production/Tetris/Tetris/GameGui.class index 5b67cdb30fdbc0cf6c640daa4c487d1edee4d3d5..29f231723177503676d40900318792e4857c3bd6 100644 GIT binary patch literal 2374 zcmZuzTW}Lq82+|RyXmsMg|<++6$DHhN}y;}3Mwt66w*>@ZB0>elbp5->2BFQNmhYQBW~!rrk*eN}q!29^1;ghUJbJ znVcvGl-mj_CxtmN>5?nENb{s^IB5kn@nPXQW;WU_`7SEP9b-x;Xo#OMW{lI(?5t@` zL=VNJlj#|ONmS1(O^Se$larpU;;)MUgd9r<#rw@D$eS74d+yx*YP^u(D5eTT5jp# z!#rC0CY=_E&~6OEYdS%OkAl(HS}o-@z9*D=#^W6sXG zIzGflIzGlZwoC@|^xd|T7LISh_8c&>G`xT-oaFgIp2u0oCoPM$V%*4O+@6e`6-TCpW4N4U zPF~o{U8luSku}fww_YGTCM(h?9Wk?}cN5kS-os)pZf0F!2@c4Hl3c_LQI3|Vy$l*0 zaVjUWgf^AS_F1E*m9}TSD|ZYVdEL;3g`Hs7w@~#v}F0H1Z@>t2OA&dUv2XP(*X09#`r*3b-$i zHAPUjR_Yj!vo&h-U+0Xhc6&VVIgRtc9Tc4Bz*&*ucwjBd%f-uH$}ugU$F3TW}L$ z{DM~eiZ=Yl=ll8{6?OqKb+gN-cI`AEO@hdxLKDkZZ<2*pCD3Tqk~K++OxJ zhFi4iLpkGqi$gffJkRoKj+3fj{PWE1Fne5u0UYsr&iN=K1ymKWm2m7VDOUcPkiU+C V94DE8?i*qdPm)t`lxrD={s#$sPB8!g delta 741 zcmZ9KOH&g;6otReVKWw~(gFL2`zaBX=Tu(YhHKDW>9)A!yp)n5{CDoS5}ef$LUanGTFUYkCL0KHL8 z(C;w7NkdQBoQ`nD!RBm~80T!xN4Q}4pv^@ShYSoGxMbk6&4@#_DHLPWWUfRQbA(8X zaYcA7pDjLCy#Ddc>knjRn`u!bmfRQadU|y&zw#(OKIN|DmTj(TCb(vET{Fp)<_0(a zSB@0iCpm>RlPebTtD0t}HHSIkm4nH}8D_*LpQp zlND|o8*88QdaU&lNpamE|2QPLkNqeP2n%pf_@RGzqvWLN_L)q-9hI1AksC*aea8|7 zlu}!$GJ(t%!HJHzdR66^?;W8Jgng`389S4RY!ThWNtNE?bR@J-WlDB&^)nuL>9fZW z%csi3pikVykWWG`S4-iVO=?X_R;^FnpKW5V)Oou-S*u__m4X%GtP(9Q8)>DJHp#a$ zOp2>?urV#E1&;BME}oHQgKm*P-HsWNri5u$McgS?qoVEFwLBmiC8yCcF`24<{%>#d YE}@r*yj@dH?+B$qw=l(V!2mtK0chKIO#lD@ 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) {