Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- public class lol2 extends JFrame
- {
- // Creating the components + global variables
- //Creating the imageicon array
- JButton DealButton = new JButton ("Deal");
- ImageIcon[] ImageArray = new ImageIcon[52];
- JLabel picture = new JLabel();
- //Creating the constructor for the class
- public lol2()
- {
- // Create the window
- super("Combo Box");
- setSize(400,350);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //Set background Colour to custom RGB value
- setBackground(new Color(0, 139, 69));
- // Load the array of images
- for(int i=0;i<52;i++){
- ImageArray[i] = new ImageIcon("resources/images/cards/"+i+".gif");
- }
- Container content = getContentPane();
- content.add(picture);
- //setContentPane(content);
- setContentPane(content);
- picture.setIcon(ImageArray[(int) Math.round(Math.random()*(ImageArray.length-1))]);
- setVisible(true);
- }
- public static void main (String[] args)
- {
- //Creating an instance of my class
- new lol2();
- }
- }
Add Comment
Please, Sign In to add comment