-
Notifications
You must be signed in to change notification settings - Fork 3
/
Window.java
30 lines (25 loc) · 1.04 KB
/
Window.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dev.hause.perry;
import javax.swing.*;
import java.awt.*;
/**
* @author hausemasterissue, perry
* Started 11/16/2021.
* code taken from shrodingers cat (stackoverflow) https://stackoverflow.com/questions/4716372/java-how-do-i-close-a-jframe-while-opening-another-one
*/
public class Window {
public static void main(String[] args) {
// make a new jframe with your title
JFrame frame = new JFrame("your title here");
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// make the text that it will display on the window
JLabel text = new JLabel("your text here.", SwingConstants.CENTER);
// the dimensions of the window
text.setPreferredSize(new Dimension(600, 100));
// which part of the window to put the text on
frame.getContentPane().add(text, BorderLayout.CENTER);
// actually make the frame visible to the user
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
}