Browse Source

refactoring: Add Buttons to a new Panel instead of the Frame

master
Leon Montag 2 years ago
parent
commit
c3e00a4cfc
  1. 14
      src/main/java/Gui/gui.java

14
src/main/java/Gui/gui.java

@ -1,11 +1,15 @@
package Gui; package Gui;
import java.awt.GridBagLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel;
public class gui { public class gui {
JFrame jf; JFrame jf;
JButton StartBtn, CloseBtn; JButton StartBtn, CloseBtn;
JPanel Panel;
public static int width = 800, height = 600; public static int width = 800, height = 600;
@ -18,10 +22,16 @@ public class gui {
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
StartBtn = new JButton("Starte Spiel"); StartBtn = new JButton("Starte Spiel");
StartBtn.setSize(300,100); StartBtn.setSize(300,100);
jf.add(StartBtn);
CloseBtn = new JButton("Schlieen"); CloseBtn = new JButton("Schlieen");
CloseBtn.setSize(300,100); CloseBtn.setSize(300,100);
jf.add(CloseBtn);
Panel = new JPanel();
Panel.setSize(width,height);
Panel.setLayout(new GridBagLayout());
Panel.add(StartBtn);
Panel.add(CloseBtn);
jf.add(Panel);
Panel.setVisible(true);
} }
} }
Loading…
Cancel
Save