mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Fullscreen zum GamePanelD hinzugefügt
Über boolean fullscreen einstellbar
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
package de.heatup.testing;
|
package de.heatup.testing;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
|
||||||
@@ -29,6 +33,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
|
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private static boolean pause = false;
|
private static boolean pause = false;
|
||||||
|
private boolean fullscreen = true;
|
||||||
|
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
@@ -41,18 +46,25 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
private static JPanel outerPanel;
|
private static JPanel outerPanel;
|
||||||
private static JPanel statusPanel;
|
private static JPanel statusPanel;
|
||||||
private static JPanel gamePanel;
|
private static JPanel gamePanel;
|
||||||
|
private static JPanel leftPanel;
|
||||||
|
private static JPanel rightPanel;
|
||||||
private static JPanel actionPanel;
|
private static JPanel actionPanel;
|
||||||
|
|
||||||
public GameLoopD(){
|
public GameLoopD(){
|
||||||
setTitle("HeatUP!");
|
setTitle("HeatUP!");
|
||||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
|
// For fullscreen
|
||||||
|
if ( fullscreen) {
|
||||||
|
setResizable(false);
|
||||||
|
setUndecorated(true);
|
||||||
|
}
|
||||||
|
|
||||||
outerPanel = new JPanel();
|
outerPanel = new JPanel();
|
||||||
outerPanel.setLayout(new BorderLayout());
|
outerPanel.setLayout(new BorderLayout());
|
||||||
outerPanel.setFocusable(false);
|
outerPanel.setFocusable(false);
|
||||||
|
|
||||||
statusPanel = new JPanel();
|
statusPanel = new JPanel();
|
||||||
statusPanel.setPreferredSize(new Dimension(800,80));
|
statusPanel.setPreferredSize(new Dimension(800,80));
|
||||||
statusPanel.setFocusable(true);
|
statusPanel.setFocusable(true);
|
||||||
@@ -61,13 +73,24 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
gamePanel.setLayout(null);
|
gamePanel.setLayout(null);
|
||||||
gamePanel.setPreferredSize(new Dimension(800,600));
|
gamePanel.setPreferredSize(new Dimension(800,600));
|
||||||
gamePanel.setFocusable(false);
|
gamePanel.setFocusable(false);
|
||||||
|
gamePanel.setBackground(Color.black);
|
||||||
|
|
||||||
actionPanel = new JPanel();
|
actionPanel = new JPanel();
|
||||||
actionPanel.setLayout(new GridLayout(1,1));
|
actionPanel.setLayout(new GridLayout(1,1));
|
||||||
actionPanel.setPreferredSize(new Dimension(800,80));
|
actionPanel.setPreferredSize(new Dimension(800,80));
|
||||||
actionPanel.setFocusable(true);
|
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(statusPanel,BorderLayout.NORTH);
|
||||||
|
outerPanel.add(leftPanel, BorderLayout.WEST);
|
||||||
|
outerPanel.add(rightPanel, BorderLayout.EAST);
|
||||||
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
outerPanel.add(gamePanel,BorderLayout.CENTER);
|
||||||
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
outerPanel.add(actionPanel,BorderLayout.SOUTH);
|
||||||
|
|
||||||
@@ -87,11 +110,23 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
player01 = PanelBuilder.player01;
|
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