All pastes #821265 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-18 00:35 UTC
rendered paste body
import javax.swing.*;       
import java.awt.*;
import java.util.*;

public class Mem extends JFrame
{
	static final long serialVersionUID = 1L;
	
    private JButton but[]=new JButton[16];
    private JTextField text[]=new JTextField [16];
    
    public Mem()
    {
        int mem[]=new int[16];
        int d=0, y=7, z=0;
        
        for (int x=0; x<16; x++)
        {
        	z++;
        	if (x<8)
        		mem[x]=z;
        	else
        		mem[x]=0;
        }
        
        for (int x=0; x<8; x++)
        {
            Random rand=new Random();
            
            while (!(but[x].equals(0)))
            {
            d=rand.nextInt(8);
            but[x]=new JButton ("" +mem[d]);
            }
            
            while (!(but[y].equals(0)))
            {
            y=rand.nextInt(8)+8;
            but[y]=new JButton (""+mem[d]);
            }
        }
        
        
        for (int x=0; x<16; x++)
        {
            text[x]=new JTextField (""+x);
        }
        
        FlowLayout layout = new FlowLayout ();
        
        Container mainWindow = getContentPane();
        mainWindow.setLayout (layout);        
        
        for (int x=0; x<16; x++)
        {
            mainWindow.add(but[x]);
            mainWindow.add(text[x]);
        }
        
        
        for (int x=0; x<16; x++)
        {
            but[x].addActionListener(new butButton (this, x));
        }
                
        addWindowListener(new GenWindowList());
        
    }
    
    public void guess ()
    {
        
    }
    
    public static void main (String [] args)
    {
        
        
            JFrame frm = new Mem ();
            frm.setSize ( 100, 300 );
            frm.setVisible(true);
    }
}