Exercise13_7 - if (status == 0) { add(new JLabel(cross)); }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Danielle Green */ import java.awt.*; import javax.swing.*; public class Exercise13_7 extends JFrame { ImageIcon cross = new ImageIcon("c:\\book\\image\\x.gif"); ImageIcon not = new ImageIcon("c:\\book\\image\\o.gif"); public Exercise13_7() { setLayout(new GridLayout(3, 3)); for (int i = 1; i <= 9; i++) { int status = (int) (Math.random() * 3);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (status == 0) { add(new JLabel(cross)); } else if (status == 1) { add(new JLabel(not)); } else { add(new JLabel()); } } } public static void main(String args) { JFrame frame = new Exercise13_7(); frame.setTitle(&quot;Exercise13_7&quot;); frame.setSize(300, 300); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }...
View Full Document

Ask a homework question - tutors are online