import javax.swing.UnsupportedLookAndFeelException;
public class Main
{
public static void main(String[] args)
throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
{
Core window = new Core("GAME1", 0, 0, true, true);
}
}
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
public class Core extends JFrame implements ActionListener
{
private final String Game_Title;
private int Window_Width;
private int Window_Height;
private boolean isVisible;
private boolean isResizeable;
public Core(String Game_Title, int Window_Width, int Window_Height,
boolean isVisible, boolean isResizeable) throws ClassNotFoundException,
InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
{
this.Game_Title = Game_Title;
this.Window_Width = Window_Height;
this.Window_Height = Window_Height;
this.isResizeable = isResizeable;
this.isVisible = isVisible;
//Create JFrame
JFrame window = new JFrame(Game_Title);
window.setSize(Window_Width, Window_Height);
window.setResizable(isResizeable);
window.setExtendedState(JFrame.MAXIMIZED_BOTH);
window.setVisible(isVisible);
window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
window.addKeyListener(new Key_Listener()); // Adding the Key_Listener to the window
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(window); // make the window full screen
}
@Override
public void actionPerformed(ActionEvent e)
{
//For Buttons and other interface stuff
}
// KEY LISTENER:
public class Key_Listener implements KeyListener
{
// 112 - F1
// 113 - F2
// 114 - F3
// 115 - F4
// 27 - ESC
private char character;
private int KeyPressed;
@Override
public void keyTyped(KeyEvent e)
{
}
@Override
public void keyPressed(KeyEvent e)
{
this.character = e.getKeyChar();
this.KeyPressed = e.getKeyCode();
System.out.println(character + "::" + KeyPressed);
if(this.KeyPressed == 112)
{
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
}
else if (this.KeyPressed == 113)
{
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
}
else if (this.KeyPressed == 114)
{
System.out.println("F3");
}
}
public int returnPressedKey()
{
return this.KeyPressed;
}
@Override
public void keyReleased(KeyEvent e)
{
}
}
}
JFrame window = new JFrame(Game_Title); // <- this window