add selectable timeout
All checks were successful
/ Build & Publish (push) Successful in 47s

This commit is contained in:
Daniella 2024-06-25 07:22:57 +02:00
parent 7ec3cf005b
commit 7ea476fd08
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 7 additions and 5 deletions

View file

@ -13,6 +13,7 @@ public class CBWindow extends JFrame implements WindowListener {
final Lock openLock = new Lock(true); final Lock openLock = new Lock(true);
final ClientBoot parent; final ClientBoot parent;
final int timeout;
final Stack<List<CBCallbackContainer>> options = new Stack<>(); final Stack<List<CBCallbackContainer>> options = new Stack<>();
{ {
@ -21,9 +22,10 @@ public class CBWindow extends JFrame implements WindowListener {
int selected = 0; int selected = 0;
Lock justRanSomething = new Lock(); Lock justRanSomething = new Lock();
public CBWindow(String name, ClientBoot parent) { public CBWindow(String name, ClientBoot parent, int timeout) {
super(); super();
this.parent = parent; this.parent = parent;
this.timeout = timeout;
add(new RootComponent()); add(new RootComponent());
getContentPane().setBackground(new Color(0x303030)); getContentPane().setBackground(new Color(0x303030));
setSize(600, 400); setSize(600, 400);
@ -79,7 +81,7 @@ public class CBWindow extends JFrame implements WindowListener {
@Override @Override
public void windowOpened(WindowEvent e) { public void windowOpened(WindowEvent e) {
openLock.lock(3000); openLock.lock(timeout);
} }
@Override @Override

View file

@ -8,7 +8,7 @@ import java.util.List;
public class ClientBoot { public class ClientBoot {
public static void main(String[] args) { public static void main(String[] args) {
new ClientBoot("ClientBoot Test") new ClientBoot("ClientBoot Test", 4000)
.option("Print something", x -> x.newScreen() .option("Print something", x -> x.newScreen()
.label("Here, you can print stuff!") .label("Here, you can print stuff!")
.option("Hello!", x1 -> System.out.println("Hello!")) .option("Hello!", x1 -> System.out.println("Hello!"))
@ -23,8 +23,8 @@ public class ClientBoot {
private final CBWindow window; private final CBWindow window;
public final TCN data = new TCN(); public final TCN data = new TCN();
public ClientBoot(String name) { public ClientBoot(String name, int timeout) {
window = new CBWindow(name, this); window = new CBWindow(name, this, timeout);
} }
public ClientBoot newScreen() { public ClientBoot newScreen() {