package code;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class FileChooser extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JTextField filename = new JTextField(), dir = new JTextField();

	private JButton open = new JButton("Open"), save = new JButton("Save");
	private JButton pass = new JButton("Pass");

	public FileChooser() {
	       try {
	            UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
	        } catch(Exception e) {
	            e.printStackTrace();
	        }
	       
	    JFrame frame = new JFrame();   
		JPanel p = new JPanel();
		
		p.add(filename);
		p.add(dir);
		p.add(open);
		p.add(save);
		p.add(pass);
		open.addActionListener(new OpenL());
		save.addActionListener(new SaveL());
		pass.addActionListener(new PassT());
		
		
		Container cp = getContentPane();
		cp.add(p, BorderLayout.SOUTH);
		
		dir.setEditable(false);
		filename.setEditable(false);
		//p.setLayout(new GridLayout(2, 1));
		cp.add(p, BorderLayout.SOUTH);
		
		
		frame.add(p);
		p.setVisible(true);
		frame.pack();
		frame.setVisible(true);
	}

	public class OpenL implements ActionListener {
		
		public void actionPerformed(ActionEvent e) {
			
			JFileChooser c = new JFileChooser();
				int value = c.showOpenDialog(FileChooser.this);
				if (value == JFileChooser.APPROVE_OPTION) {
					filename.setText(c.getSelectedFile().getName());
					dir.setText(c.getCurrentDirectory().toString());
				}
				if (value == JFileChooser.CANCEL_OPTION) {
					filename.setText("You pressed cancel");
					dir.setText("");
				}
				c.setVisible(true);
		}
	}

	public class SaveL implements ActionListener {
		
		public void actionPerformed(ActionEvent e) {
			
			JFileChooser c = new JFileChooser();
			int value = c.showSaveDialog(FileChooser.this);
			if (value == JFileChooser.APPROVE_OPTION) {
				filename.setText(c.getSelectedFile().getName());
				dir.setText(c.getCurrentDirectory().toString());
			}
			if (value == JFileChooser.CANCEL_OPTION) {
			}
			c.setVisible(true);
		}
	}

	public static void main(String[] args) {
		run(new FileChooser(), 250, 110);
	}

	public static void run(JFrame frame, int width, int height) {
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(width, height);
		frame.setVisible(true);
	}
	public class PassT implements ActionListener {
		
		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(null, "You have passed your turn", "Turn", JOptionPane.PLAIN_MESSAGE);
	}
	}

}


@@ -392,16 +392,70 @@
 ger;%0D%0A%0D%0A
+import code.base.Scrabble;%0D%0Aimport code.base.Tile;%0D%0A%0D%0A
 public c
@@ -762,30 +762,118 @@
 );%0D%0A
-%0D%0A%09public FileChooser(
+%09private BoardFrame _bf;%0D%0A%09private Scrabble _scrabble;%0D%0A%0D%0A%09public FileChooser(Scrabble scrabble, BoardFrame bf
 ) %7B%0D
@@ -1127,24 +1127,62 @@
  JPanel();%0D%0A
+%09%09_scrabble = scrabble;%0D%0A%09%09_bf = bf;%0D%0A
 %09%09%0D%0A%09%09p.add(
@@ -1574,35 +1574,35 @@
 p, BorderLayout.
-SOU
+NOR
 TH);%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09
@@ -2668,94 +2668,8 @@
 %0D%0A%0D%0A
-%09public static void main(String%5B%5D args) %7B%0D%0A%09%09run(new FileChooser(), 250, 110);%0D%0A%09%7D%0D%0A%0D%0A
 %09pub
@@ -2849,16 +2849,19 @@
 );%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public 
@@ -2953,16 +2953,316 @@
 t e) %7B%0D%0A
+%09%09%09PlayerFrame temp = _bf.getPlayerFrame(0);%0D%0A%09%09%09for(int i=0; i%3C12; i++)%7B%0D%0A%09%09%09%09if(temp.getPlayerSpace(i)==null)%7B%0D%0A%09%09%09%09%09Tile t = _scrabble.getInv().removeRandomTile();%0D%0A%09%09%09%09%09temp.getPlayerSpace(i).setText(Character.toString(t.getChar()));%0D%0A%09%09%09%09%09temp.getPlayerSpace(i).setCurrentTile(t);%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A
 %09%09%09JOpti
@@ -3323,43 +3323,8 @@
 urn%22
-, %22Turn%22, JOptionPane.PLAIN_MESSAGE
 );%0D%0A
@@ -3336,10 +3336,8 @@
 %7D%0D%0A%0D%0A%7D%0D%0A
-%0D%0A

Update FileChooser.java