Skip to content

Instantly share code, notes, and snippets.

@shah-smit
Created September 27, 2016 12:10
Show Gist options
  • Save shah-smit/e43b3b29e63d2b61d078b47be2481bab to your computer and use it in GitHub Desktop.
Save shah-smit/e43b3b29e63d2b61d078b47be2481bab to your computer and use it in GitHub Desktop.
A simple GUI with one panel contained in a frame
import java.awt.*;
import javax.swing.*;
public class SimpleFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame frame = new JFrame("A simple Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setBackground(Color.white);
panel.setPreferredSize(new Dimension(250,75));
JLabel label1 = new JLabel("Binary and Conversation");
JLabel label2 = new JLabel("1 and 2 conv");
panel.add(label1);
panel.add(label2);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment