I need to create a frame that contains three labels
---> Each label should display a card images named 1.png . . . 54.png stored in some directory.
---> All three cards must be distinct and selected randomly!(which i have no idea how to code this)
I tried my best and this is what i. . .i did :-
---> Each label should display a card images named 1.png . . . 54.png stored in some directory.
---> All three cards must be distinct and selected randomly!(which i have no idea how to code this)
I tried my best and this is what i. . .i did :-
import javax.swing.*;
import java.awt.*;
public class CardSelector extends JFrame{
private ImageIcon card = new ImageIcon("c:/book/image/"+(1+(int)(Math.random()*55)));
public CardSelector(){
for(int i=0;i<3;i++)
add(new JLabel(card));
}
public static void main(String[] args){
CardSelector frame = new CardSelector();
frame.setTitle("Tic Tac Toe");
frame.setSize(350, 350);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}