Advertisement
Monty374

Name 1

Dec 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. package name1;
  2.  
  3. import javax.swing.*;
  4. import javax.swing.JOptionPane;
  5.  
  6. public class Name1 {
  7.  
  8. static String LABEL_TEXT = JOptionPane.showInputDialog("Enter your name.");
  9. JFrame frame;
  10. JPanel contentPane;
  11. JLabel label;
  12.  
  13. public Name1(){
  14.  
  15. frame = new JFrame("Name");
  16. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  17.  
  18. contentPane = new JPanel();
  19.  
  20. label = new JLabel(LABEL_TEXT);
  21. contentPane.add(label);
  22.  
  23. frame.setContentPane(contentPane);
  24.  
  25. frame.pack();
  26. frame.setVisible(true);
  27. }
  28.  
  29. private static void runGUI() {
  30. JFrame.setDefaultLookAndFeelDecorated(true);
  31.  
  32. Name1 name = new Name1();
  33. }
  34.  
  35.  
  36. public static void main(String[] args) {
  37.  
  38.  
  39. javax.swing.SwingUtilities.invokeLater(new Runnable() {
  40. public void run() {
  41. runGUI();
  42. }
  43. });
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement