Copy&Paste's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
2 (0 per day)
Joined:
02-April 13
Profile Views:
165
Last Active:
User is offline Jan 12 2014 09:10 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Copy&Paste has not set their status

Posts I've Made

  1. In Topic: TicTacToe Board Using Swing GUI components

    Posted 21 Apr 2013

    I did a bit more reading and came up with my answer on my own. here's the code if any are curious...
    import java.awt.GridLayout;
    import java.awt.LayoutManager;
    
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    
    // import necessary classes and interfaces
    
    
    public class TicTacToeBoard extends JFrame
    {
    
    	private static LayoutManager manager = new GridLayout(3,3);
    
    	/**
    	 * @param args
    	 */
    	
    	TicTacToeBoard()
    	{
    		setLayout(manager);
    		
    		for (int i = 0; i < 3; i ++)
    			for (int k = 0; k < 3; k ++)
    				add(new JLabel(randomIcon()));
    	}
    
    	private ImageIcon randomIcon() {
    		// TODO Auto-generated method stub
    		double r = Math.random();
    		
    		ImageIcon icon;
    		
    		if (r - 0.5 < 0)
    			icon = new ImageIcon("x.gif");
    		else
    			icon = new ImageIcon("o.gif");
    		return icon;
    	}
    
    	public static void main(String[] args) 
    	{
    		TicTacToeBoard frame = new TicTacToeBoard();
    		
    		frame.setTitle("Tic-Tac-Toe!");
    		frame.pack();
    		frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		frame.setLocationRelativeTo(null);
    		frame.setVisible(true);
    	}
    }
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Copy&Paste hasn't added any friends yet.

Comments

Copy&Paste has no profile comments yet. Why not say hello?