Crenox

Winston Tutorial 3

Mar 24th, 2014
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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 ImageIcon i1;
  16. private ImageIcon i2;
  17. private JLabel l1;
  18. private JLabel l2;
  19.  
  20. public FirstGui()
  21. {
  22. setLayout(new FlowLayout());
  23.  
  24. i1 = new ImageIcon(getClass().getResource("cat.jpg"));
  25. l1 = new JLabel(i1);
  26. add(l1);
  27.  
  28. i2 = new ImageIcon(getClass().getResource("drakepls.jpeg"));
  29. l2 = new JLabel(i2);
  30. add(l2);
  31. }
  32.  
  33. public static void main(String args[])
  34. {
  35. FirstGui frame = new FirstGui();
  36.  
  37. frame.setTitle("First GUI");
  38. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  39. //frame.setSize(600, 600);
  40. frame.pack();
  41. frame.setVisible(true);
  42. frame.isOpaque();
  43. frame.setLocationRelativeTo(null);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment