This commit is contained in:
James Seibel
2023-11-08 19:41:05 -06:00
4 changed files with 32 additions and 5 deletions
@@ -51,8 +51,8 @@ public abstract class AbstractScreen
/** Called every time the window gets re-sized */
public void onResize() { }
;
/** What happens when the user closes the screen */
/** What happens when the user closes the screen */
public void onClose() { }
// ---------- Random stuff that might be needed later on ---------- //
@@ -21,8 +21,10 @@ package com.seibel.distanthorizons.core.config.gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class ConfigScreen extends JFrame
public class ConfigScreen extends JComponent
{
public ConfigScreen()
@@ -33,6 +35,8 @@ public class ConfigScreen extends JFrame
constraints.weightx = 0.5;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.insets = new Insets(10, 10, 0, 10);
add(new JLabel("Hello World!"), constraints);
}
@@ -40,8 +44,12 @@ public class ConfigScreen extends JFrame
public static void main(String[] args)
{
SwingUtilities.invokeLater(() -> {
JFrame frame = new ConfigScreen();
JFrame frame = new JFrame();
frame.add(new ConfigScreen());
frame.setSize(300, 200);
frame.setLocationRelativeTo(null); // Makes the window open at the center of the screen
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
});
@@ -39,7 +39,7 @@ import static org.lwjgl.system.macosx.ObjCRuntime.*;
// which is licensed under https://www.lwjgl.org/license
/**
* Some utils for embeding awt and swing items into lwjgl windows
* Some utils for embedding awt and swing items into lwjgl windows
*
* @author Ran
* @author coolGi
@@ -23,6 +23,8 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/**
*
@@ -52,6 +54,23 @@ public class JavaScreenHandlerScreen extends AbstractScreen
frame.add(jComponent);
JavaScreenHandlerScreen thiss = this;
frame.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent keyEvent)
{
System.out.println("Key pressed code=" + keyEvent.getKeyCode() + ", char=" + keyEvent.getKeyChar());
if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE)
thiss.close = true;
}
@Override
public void keyTyped(KeyEvent keyEvent) { }
@Override
public void keyReleased(KeyEvent keyEvent) { }
});
if (firstRun)
{
EmbeddedFrameUtil.embeddedFrameSetBounds(frame, 0, 0, this.width, this.height);