Guest User

Untitled

a guest
Jan 12th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4.  
  5.  
  6. public class lol2 extends JFrame
  7. {
  8. // Creating the components + global variables
  9.  
  10. //Creating the imageicon array
  11. JButton DealButton = new JButton ("Deal");
  12. ImageIcon[] ImageArray = new ImageIcon[52];
  13. JLabel picture = new JLabel();
  14.  
  15.  
  16. //Creating the constructor for the class
  17. public lol2()
  18. {
  19.  
  20. // Create the window
  21. super("Combo Box");
  22. setSize(400,350);
  23. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24. //Set background Colour to custom RGB value
  25. setBackground(new Color(0, 139, 69));
  26.  
  27.  
  28.  
  29. // Load the array of images
  30. for(int i=0;i<52;i++){
  31. ImageArray[i] = new ImageIcon("resources/images/cards/"+i+".gif");
  32. }
  33.  
  34. Container content = getContentPane();
  35.  
  36. content.add(picture);
  37.  
  38. //setContentPane(content);
  39. setContentPane(content);
  40.  
  41.  
  42. picture.setIcon(ImageArray[(int) Math.round(Math.random()*(ImageArray.length-1))]);
  43.  
  44.  
  45.  
  46.  
  47. setVisible(true);
  48. }
  49.  
  50.  
  51.  
  52.  
  53. public static void main (String[] args)
  54. {
  55. //Creating an instance of my class
  56. new lol2();
  57. }
  58.  
  59. }
Add Comment
Please, Sign In to add comment