mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:09:44 +02:00
Fullscreen zum GamePanelD hinzugefügt
Über boolean fullscreen einstellbar
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package de.heatup.testing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
|
||||
@@ -29,6 +33,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
|
||||
private boolean running = false;
|
||||
private static boolean pause = false;
|
||||
private boolean fullscreen = true;
|
||||
|
||||
private Thread thread;
|
||||
|
||||
@@ -41,6 +46,8 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
private static JPanel outerPanel;
|
||||
private static JPanel statusPanel;
|
||||
private static JPanel gamePanel;
|
||||
private static JPanel leftPanel;
|
||||
private static JPanel rightPanel;
|
||||
private static JPanel actionPanel;
|
||||
|
||||
public GameLoopD(){
|
||||
@@ -48,6 +55,11 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setResizable(false);
|
||||
|
||||
// For fullscreen
|
||||
if ( fullscreen) {
|
||||
setResizable(false);
|
||||
setUndecorated(true);
|
||||
}
|
||||
|
||||
outerPanel = new JPanel();
|
||||
outerPanel.setLayout(new BorderLayout());
|
||||
@@ -61,13 +73,24 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
gamePanel.setLayout(null);
|
||||
gamePanel.setPreferredSize(new Dimension(800,600));
|
||||
gamePanel.setFocusable(false);
|
||||
gamePanel.setBackground(Color.black);
|
||||
|
||||
actionPanel = new JPanel();
|
||||
actionPanel.setLayout(new GridLayout(1,1));
|
||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||
actionPanel.setFocusable(true);
|
||||
|
||||
leftPanel = new JPanel();
|
||||
leftPanel.setLayout(null);
|
||||
leftPanel.setBackground(Color.black);
|
||||
|
||||
rightPanel = new JPanel();
|
||||
rightPanel.setLayout(null);
|
||||
rightPanel.setBackground(Color.black);
|
||||
|
||||
outerPanel.add(statusPanel,BorderLayout.NORTH);
|
||||
outerPanel.add(leftPanel, BorderLayout.WEST);
|
||||
outerPanel.add(rightPanel, BorderLayout.EAST);
|
||||
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
||||
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
||||
|
||||
@@ -87,11 +110,23 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
player01 = PanelBuilder.player01;
|
||||
|
||||
|
||||
actionPanel.setVisible(true);
|
||||
outerPanel.setVisible(true);
|
||||
statusPanel.setVisible(true);
|
||||
gamePanel.setVisible(true);
|
||||
|
||||
//leftPanel.setPreferredSize(new Dimension((this.getWidth()-gamePanel.getWidth()),10));
|
||||
|
||||
outerPanel.setVisible(true);
|
||||
gamePanel.setVisible(true);
|
||||
actionPanel.setVisible(true);
|
||||
statusPanel.setVisible(true);
|
||||
|
||||
// For fullscreen
|
||||
if ( fullscreen ) {
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice gd = ge.getDefaultScreenDevice();
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
gd.setFullScreenWindow(this);
|
||||
leftPanel.setPreferredSize(new Dimension(((gd.getDisplayMode().getWidth() - (int)gamePanel.getPreferredSize().getWidth())/2), 0));
|
||||
rightPanel.setPreferredSize(new Dimension(((gd.getDisplayMode().getWidth() - (int)gamePanel.getPreferredSize().getWidth())/2), 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user