Created
April 7, 2020 13:32
-
-
Save ababup1192/d33a4db942b9e25021240dfeed2eb77c to your computer and use it in GitHub Desktop.
swing hello
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.abab; | |
import javax.swing.*; | |
import java.awt.*; | |
public class Main { | |
public static void main(String[] args) { | |
JFrame frame = new JFrame("Hello label"); | |
frame.setSize(300, 200); | |
frame.setLocationRelativeTo(null); | |
JLabel label = new JLabel(); | |
label.setText("Hello world!"); | |
JPanel panel = new JPanel(); | |
panel.add(label); | |
Container contentPane = frame.getContentPane(); | |
contentPane.add(panel, BorderLayout.CENTER); | |
frame.setContentPane(panel); | |
frame.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment