forked from egoing/java1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorldGUIApp.java
More file actions
21 lines (20 loc) · 832 Bytes
/
HelloWorldGUIApp.java
File metadata and controls
21 lines (20 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Toolkit;
public class HelloWorldGUIApp{
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("HelloWorld GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(800, 300));
JLabel label = new JLabel("Hello World!!", SwingConstants.RIGHT);
frame.getContentPane().add(label);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(dim.width/2-400/2, dim.height/2-300/2);
frame.pack();
frame.setVisible(true);
}
});
}
}