Crenox

Winston Tutorial 1-2

Mar 24th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /*
  2. Links:
  3. https://stackoverflow.com/questions/9543320/how-to-position-the-form-in-the-center-screen
  4. https://www.youtube.com/watch?v=mjOicuXEvwg
  5. */
  6.  
  7. package com.samkough.main;
  8.  
  9. import java.awt.*;
  10. import javax.swing.*;
  11.  
  12. @SuppressWarnings("serial")
  13. public class FirstGui extends JFrame
  14. {
  15. private JLabel l1;
  16. private JButton b1;
  17. private JTextField tf1;
  18.  
  19. public static void main(String args[])
  20. {
  21. FirstGui frame = new FirstGui();
  22. // Terminates when you press red x button
  23. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24. frame.setSize(200, 125);
  25. frame.setVisible(true);
  26. frame.setTitle("First Gui");
  27. frame.setLocationRelativeTo(null);
  28. }
  29.  
  30. public FirstGui()
  31. {
  32. setLayout(new FlowLayout());
  33. l1 = new JLabel("Hi, I'm a label.");
  34. add(l1);
  35.  
  36. tf1 = new JTextField(15);
  37. add(tf1);
  38.  
  39. b1 = new JButton("Hey, I'm a button");
  40. add(b1);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment