butto width

This commit is contained in:
zhe 2021-11-15 15:47:45 +01:00
parent 7af2cf0739
commit 626f2124ea
5 changed files with 12 additions and 12 deletions

View File

@ -13,8 +13,6 @@ public class Board extends JPanel
public static final int BOARD_HEIGHT=20; public static final int BOARD_HEIGHT=20;
public static final int BLOCK_SIZE=30; public static final int BLOCK_SIZE=30;
public static final int BOARDRIGHT_WIDTH=15;
public static final int BOARDRIGHT_HEIGHT=5;
private Timer loop; private Timer loop;
private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT]; private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
private Color[] [] shape ={ private Color[] [] shape ={

View File

@ -2,26 +2,30 @@ package Tetris;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
public class GameGui { public class GameGui {
public static final int width= 500, height =650; public static final int width= 500, height =650;
private Board board; private Board board;
private Board board2;
private JFrame frame; private JFrame frame;
public GameGui(){ public GameGui(){
frame = new JFrame("Tetris");
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(450, 50, 50, 50,Color.black)); panel.setBorder(BorderFactory.createMatteBorder(450, 10, 20, 10,Color.black));
JButton button1 = new JButton("Start");
JButton button2 = new JButton("Pause");
JLabel label = new JLabel("Name: ",JLabel.LEFT);
label.setBounds(100,100,50,30);
JButton button1 = new JButton("Start");
button1.setPreferredSize( new Dimension(150,150));
JButton button2 = new JButton("Pause");
JButton button3 = new JButton("Score");
panel.setLayout(new GridLayout(0,1)); panel.setLayout(new GridLayout(0,1));
panel.setBackground(Color.DARK_GRAY); panel.setBackground(Color.gray);
panel.add(label);
panel.add(button1); panel.add(button1);
panel.add(button2); panel.add(button2);
panel.add(button3);
/* /*
window.add(panel, BorderLayout.EAST); window.add(panel, BorderLayout.EAST);
frame.add(window,BorderLayout.WEST); frame.add(window,BorderLayout.WEST);
@ -33,7 +37,7 @@ public class GameGui {
board = new Board(); board = new Board();
window.add(board); window.add(board);
*/ */
frame = new JFrame("Tetris");
frame.add(panel,BorderLayout.EAST); frame.add(panel,BorderLayout.EAST);
frame.setSize(width,height); frame.setSize(width,height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -41,8 +45,6 @@ public class GameGui {
frame.setVisible(true); frame.setVisible(true);
board = new Board(); board = new Board();
frame.add(board,BorderLayout.CENTER); frame.add(board,BorderLayout.CENTER);
board2 = new Board();
frame.add(board2,BorderLayout.EAST);
} }
public static void main(String [] args) public static void main(String [] args)
{ {