//12.5 import java.awt.*; import java.util.*; import javax.swing.*; import javax.swing.border.LineBorder; public class Test extends JFrame { public static void main(String[] args) { LineBorder lb = new LineBorder(Color.black,2); Test t1 = new Test(); t1.setLayout(new GridLayout(3,3)); ImageIcon j = new ImageIcon("pic/j.jpg"); ImageIcon q = new ImageIcon("pic/q.jpg"); t1.setSize(300,300); for(int i =0;i<9;i++){ switch((int)Math.round(Math.random()*2)) { case 0:t1.add(new JLabel()); break; case 1:t1.add(new JLabel(j)); break; case 2:t1.add(new JLabel(q)); break; } } t1.setDefaultCloseOperation(EXIT_ON_CLOSE); t1.setLocationRelativeTo(null); t1.setVisible(true); } }