Skip to content

Instantly share code, notes, and snippets.

@ababup1192
Created April 7, 2020 13:32
Show Gist options
  • Save ababup1192/d33a4db942b9e25021240dfeed2eb77c to your computer and use it in GitHub Desktop.
Save ababup1192/d33a4db942b9e25021240dfeed2eb77c to your computer and use it in GitHub Desktop.
swing hello
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