Button auf Gui

This commit is contained in:
zhe 2021-11-15 11:31:01 +01:00
parent 2215dc0ba7
commit 1839154769
3 changed files with 27 additions and 6 deletions

View File

@ -61,5 +61,4 @@ public class Board extends JPanel
}
}

View File

@ -1,21 +1,43 @@
package Tetris;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
import java.awt.*;
public class GameGui {
public static final int width= 500, height =650;
private Board board;
private JFrame window;
private JFrame frame;
public GameGui(){
window = new JFrame("Tetris");
frame = new JFrame("Tetris");
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder(450, 30, 100, 30));
JButton button1 = new JButton("Start");
JButton button2 = new JButton("Pause");
panel.setLayout(new GridLayout(0,1));
panel.add(button1);
panel.add(button2);
/*
window.add(panel, BorderLayout.EAST);
frame.add(window,BorderLayout.WEST);
window.setSize(width,height);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
window.setResizable(false);
window.setVisible(true);
board = new Board();
window.add(board);
*/
frame.add(panel,BorderLayout.EAST);
frame.setSize(width,height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setVisible(true);
board = new Board();
frame.add(board,BorderLayout.CENTER);
}
public static void main(String [] args)
{