gt: 			if (close()) doclose();
context: package jagoclient;
  
  import jagoclient.board.GoFrame;
  import jagoclient.dialogs.ColorEdit;
  import jagoclient.dialogs.FunctionKeyEdit;
  import jagoclient.dialogs.GetFontSize;
  import jagoclient.dialogs.GetParameter;
  import jagoclient.dialogs.Help;
  import jagoclient.gmp.GMPConnection;
  import jagoclient.gui.ButtonAction;
  import jagoclient.gui.CheckboxMenuItemAction;
  import jagoclient.gui.CloseDialog;
  import jagoclient.gui.CloseFrame;
  import jagoclient.gui.GrayTextField;
  import jagoclient.gui.IntField;
  import jagoclient.gui.MenuItemAction;
  import jagoclient.gui.MyLabel;
  import jagoclient.gui.MyMenu;
  import jagoclient.gui.MyPanel;
  import jagoclient.gui.Panel3D;
  import jagoclient.partner.Server;
  import jagoclient.sound.JagoSound;
  
  import java.awt.BorderLayout;
  import java.awt.Checkbox;
  import java.awt.CheckboxMenuItem;
  import java.awt.Color;
  import java.awt.Frame;
  import java.awt.GridLayout;
  import java.awt.Menu;
  import java.awt.MenuBar;
  import java.awt.MenuItem;
  import java.util.Locale;
  
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  /**
   * Get the port for the partner server.
   */
  
  class GetPort extends GetParameter
  {
  	MainFrame GCF;
  
  	public GetPort (MainFrame gcf, int port)
  	{
  		super(gcf, Global.resourceString("Server_Port"), Global
  			.resourceString("Port"), gcf, true, "port");
  		set("" + port);
  		GCF = gcf;
  		setVisible(true);
  	}
  
  	@Override
  	public boolean tell (Object o, String S)
  	{
  		int port = 6970;
  		try
  		{
  			port = Integer.parseInt(S);
  			Global.setParameter("serverport", port);
  		}
  		catch (NumberFormatException ex)
  		{}
  		return true;
  	}
  }
  
  
  /**
   * Get some advanced options.
   */
  
  class AdvancedOptionsEdit extends CloseDialog
  {
  	Checkbox Pack, SetIcon, UseSystemViewer, UseSystemLister, UseConfirmation,
  		WhoWindow, GamesWindow, KoRule;
  
  	/**
  	 * Initialize all dialog items. The main layout is a Nx1 grid with check
  	 * boxes.
  	 */
  	public AdvancedOptionsEdit (Frame f)
  	{
  		super(f, Global.resourceString("Advanced_Options"), true);
  		setLayout(new BorderLayout());
  		JPanel p = new MyPanel();
  		p.setLayout(new GridLayout(0, 1));
  		p.add(UseConfirmation = new Checkbox(Global
  			.resourceString("Confirmations")));
  		UseConfirmation.setState(Global.getParameter("confirmations", true));
  		UseConfirmation.setFont(Global.SansSerif);
  		p.add(KoRule = new Checkbox(Global.resourceString("Obey_Ko_Rule")));
  		KoRule.setState(Global.getParameter("korule", true));
  		KoRule.setFont(Global.SansSerif);
  		p
  			.add(WhoWindow = new Checkbox(Global
  				.resourceString("Show_Who_Window")));
  		WhoWindow.setState(Global.getParameter("whowindow", true));
  		WhoWindow.setFont(Global.SansSerif);
  		p.add(GamesWindow = new Checkbox(Global
  			.resourceString("Show_Games_Window")));
  		GamesWindow.setState(Global.getParameter("gameswindow", true));
  		GamesWindow.setFont(Global.SansSerif);
  		p.add(Pack = new Checkbox(Global
  			.resourceString("Pack_some_of_the_dialogs")));
  		Pack.setState(Global.getParameter("pack", true));
  		Pack.setFont(Global.SansSerif);
  		p.add(SetIcon = new Checkbox(Global
  			.resourceString("Set_own_icon__buggy_in_windows__")));
  		SetIcon.setState(Global.getParameter("icons", false));
  		SetIcon.setFont(Global.SansSerif);
  		p.add(UseSystemViewer = new Checkbox(Global
  			.resourceString("Use_AWT_TextArea")));
  		UseSystemViewer.setState(Global.getParameter("systemviewer", false));
  		UseSystemViewer.setFont(Global.SansSerif);
  		p.add(UseSystemLister = new Checkbox(Global
  			.resourceString("Use_AWT_List")));
  		UseSystemLister.setState(Global.getParameter("systemlister", false));
  		UseSystemLister.setFont(Global.SansSerif);
  		add("Center", new Panel3D(p));
  		JPanel ps = new MyPanel();
  		ps.add(new ButtonAction(this, Global.resourceString("OK")));
  		ps.add(new ButtonAction(this, Global.resourceString("Cancel")));
  		ps.add(new MyLabel(" "));
  		ps.add(new ButtonAction(this, Global.resourceString("Help")));
  		add("South", new Panel3D(ps));
  		Global.setpacked(this, "advancedoptionsedit", 300, 150, f);
  		show();
  	}
  
  	@Override
  	public void doAction (String o)
  	{
  		if (o.equals(Global.resourceString("OK")))
  		{
  			setVisible(false);
  			dispose();
  			Global.setParameter("pack", Pack.getState());
  			Global.setParameter("icons", SetIcon.getState());
  			Global.setParameter("systemviewer", UseSystemViewer.getState());
  			Global.setParameter("systemlister", UseSystemLister.getState());
  			Global.setParameter("confirmations", UseConfirmation.getState());
  			Global.setParameter("whowindow", WhoWindow.getState());
  			Global.setParameter("gameswindow", GamesWindow.getState());
  			Global.setParameter("korule", KoRule.getState());
  		}
  		else if (o.equals(Global.resourceString("Cancel")))
  		{
  			setVisible(false);
  			dispose();
  		}
  		else if (o.equals(Global.resourceString("Help")))
  		{
  			new Help("advanced");
  		}
  	}
  }
  
  
  /**
   * Get the name for the partner client.
   */
  
  class YourNameQuestion extends GetParameter
  {
  	public YourNameQuestion (MainFrame gcf)
  	{
  		super(gcf, Global.resourceString("Name"), Global
  			.resourceString("Your_Name"), gcf, true, "yourname");
  		set(Global.getParameter("yourname", "Your Name"));
  		show();
  	}
  
  	@Override
  	public boolean tell (Object o, String S)
  	{
  		if ( !S.equals("")) Global.setParameter("yourname", S);
  		return true;
  	}
  }
  
  
  /**
   * Get the languate locale
   */
  
  class GetLanguage extends GetParameter
  {
  	public boolean done = false;
  
  	public GetLanguage (MainFrame gcf)
  	{
  		super(gcf, "Your Locale (leave empty for default)", "Language", gcf,
  			true, "language");
  		String S = "Your Locale";
  		String T = Global.resourceString(S);
  		if ( !S.equals(T)) Prompt.setText(T + " (" + S + ")");
  		set(Locale.getDefault().toString());
  		setVisible(true);
  	}
  
  	@Override
  	public boolean tell (Object o, String S)
  	{
  		Global.setParameter("language", S);
  		done = true;
  		return true;
  	}
  }
  
  
  /**
   * Get IP name of the relay server, if used.
   */
  
  class GetRelayServer extends CloseDialog
  {
  	JTextField Server;
  	IntField Port;
  
  	public GetRelayServer (Frame F)
  	{
  		super(F, Global.resourceString("Relay_Server"), true);
  		JPanel p = new MyPanel();
  		p.setLayout(new GridLayout(0, 2));
  		p.add(new MyLabel(Global.resourceString("Server")));
  		p.add(Server = new GrayTextField());
  		Server.setText(Global.getParameter("relayserver", "localhost"));
  		p.add(new MyLabel(Global.resourceString("Port")));
  		p.add(Port = new IntField(this, Global.resourceString("Port"), Global
  			.getParameter("relayport", 6971)));
  		add("Center", new Panel3D(p));
  		JPanel bp = new MyPanel();
  		bp.add(new ButtonAction(this, Global.resourceString("OK")));
  		bp.add(new ButtonAction(this, Global.resourceString("Cancel")));
  		bp.add(new MyLabel(" "));
  		bp.add(new ButtonAction(this, Global.resourceString("Help")));
  		add("South", new Panel3D(bp));
  		Global.setpacked(this, "getrelay", 300, 200, F);
  		validate();
  		setVisible(true);
  	}
  
  	@Override
  	public void doAction (String o)
  	{
  		Global.notewindow(this, "getrelay");
  		if (Global.resourceString("OK").equals(o))
  		{
  			Global.setParameter("relayserver", Server.getText());
  			Global.setParameter("relayport", Port.value());
  			setVisible(false);
  			dispose();
  		}
  		else if (Global.resourceString("Cancel").equals(o))
  		{
  			setVisible(false);
  			dispose();
  		}
  		else if (o.equals(Global.resourceString("Help")))
  		{
  			new Help("relayserver");
  		}
  		else super.doAction(o);
  	}
  }
  
  
  /**
   * Get the background color.
   */
  
  class BackgroundColorEdit extends ColorEdit
  {
  	public BackgroundColorEdit (Frame f, String s, Color c)
  	{
  		super(f, s, c, false);
  		setVisible(true);
  	}
  
  	@Override
  	public void addbutton (MyPanel p)
  	{
  		p.add(new ButtonAction(this, Global.resourceString("System")));
  	}
  
  	@Override
  	public void tell (Color C)
  	{
  		Global.setParameter("color.background", C);
  		Global.setParameter("color.control", C);
  		Global.makeColors();
  	}
  
  	@Override
  	public void doAction (String o)
  	{
  		if (o.equals(Global.resourceString("System")))
  		{
  			Global.removeParameter("color.control");
  			Global.removeParameter("color.background");
  			Global.makeColors();
  			super.doAction(Global.resourceString("OK"));
  		}
  		else super.doAction(o);
  	}
  }
  
  
  /**
   * The MainFrame contains menus to edit some options, get help and set some
   * things. A card layout with the server and partner connections is added to
   * this frame later.
   */
  
  public class MainFrame extends CloseFrame
  {
  	CheckboxMenuItem StartPublicServer, TimerInTitle, BigTimer,
  		ExtraInformation, ExtraSendField, DoSound, SimpleSound, BeepOnly,
  		Warning, RelayCheck, Automatic, EveryMove, FineBoard, Navigation;
  	MenuItem StartServer;
  	public Server S = null;
  
  	public MainFrame (String c)
  	{
  		super(c + " " + Global.resourceString("Version"));
  		seticon("ijago.gif");
  		boolean constrainedapplet = c.equals(Global
  			.resourceString("Jago_Applet"));
  		// Menu :
  		MenuBar menu = new MenuBar();
  		setMenuBar(menu);
  		// Actions
  		Menu local = new MyMenu(Global.resourceString("Actions"));
  		local
  			.add(new MenuItemAction(this, Global.resourceString("Local_Board")));
  		local.addSeparator();
  		local.add(new MenuItemAction(this, Global.resourceString("Play_Go")));
  		local.addSeparator();
  		local.add(new MenuItemAction(this, Global.resourceString("Close")));
  		menu.add(local);
  		// Server Options
  		Menu soptions = new MyMenu(Global.resourceString("Go_Server"));
  		if ( !Global.isApplet())
  		{
  			soptions.add(Automatic = new CheckboxMenuItemAction(this, Global
  				.resourceString("Automatic_Login")));
  			Automatic.setState(Global.getParameter("automatic", true));
  			soptions.addSeparator();
  		}
  		soptions.add(new MenuItemAction(this, Global.resourceString("Filter")));
  		soptions.add(new MenuItemAction(this, Global
  			.resourceString("Function_Keys")));
  		menu.add(soptions);
  		// Partner Options
  		if ( !constrainedapplet)
  		{
  			Menu poptions = new MyMenu(Global.resourceString("Partner"));
  			poptions.add(StartServer = new MenuItemAction(this, Global
  				.resourceString("Start_Server")));
  			poptions.add(new MenuItemAction(this, Global
  				.resourceString("Server_Port")));
  			poptions.add(new MenuItemAction(this, Global
  				.resourceString("Your_Name")));
  			poptions.add(StartPublicServer = new CheckboxMenuItemAction(this,
  				Global.resourceString("Public")));
  			StartPublicServer.setState(Global
  				.getParameter("publicserver", true));
  			menu.add(poptions);
  		}
  		// Options
  		Menu options = new MyMenu(Global.resourceString("Options"));
  		Menu bo = new MyMenu(Global.resourceString("Board_Options"));
  		bo.add(Navigation = new CheckboxMenuItemAction(this, Global
  			.resourceString("Navigation_Tree")));
  		Navigation.setState(Global.getParameter("shownavigationtree", true));
  		bo.add(TimerInTitle = new CheckboxMenuItemAction(this, Global
  			.resourceString("Timer_in_Title")));
  		TimerInTitle.setState(Global.getParameter("timerintitle", true));
  		bo.add(BigTimer = new CheckboxMenuItemAction(this, Global
  			.resourceString("Big_Timer")));
  		BigTimer.setState(Global.getParameter("bigtimer", true));
  		bo.add(ExtraInformation = new CheckboxMenuItemAction(this, Global
  			.resourceString("Extra_Information")));
  		ExtraInformation
  			.setState(Global.getParameter("extrainformation", true));
  		bo.add(ExtraSendField = new CheckboxMenuItemAction(this, Global
  			.resourceString("Extra_Send_Field")));
  		ExtraSendField.setState(Global.getParameter("extrasendfield", true));
  		bo.add(FineBoard = new CheckboxMenuItemAction(this, Global
  			.resourceString("Fine_Board")));
  		FineBoard.setState(Global.getParameter("fineboard", true));
  		options.add(bo);
  		options.add(new MenuItemAction(this, Global
  			.resourceString("Advanced_Options")));
  		options.addSeparator();
  		Menu fonts = new MyMenu(Global.resourceString("Fonts"));
  		fonts
  			.add(new MenuItemAction(this, Global.resourceString("Board_Font")));
  		fonts
  			.add(new MenuItemAction(this, Global.resourceString("Fixed_Font")));
  		fonts.add(new MenuItemAction(this, Global.resourceString("Big_Font")));
  		fonts
  			.add(new MenuItemAction(this, Global.resourceString("Normal_Font")));
  		options.add(fonts);
  		options.add(new MenuItemAction(this, Global
  			.resourceString("Background_Color")));
  		options.addSeparator();
  		options.add(DoSound = new CheckboxMenuItemAction(this, Global
  			.resourceString("Sound_on")));
  		DoSound.setState( !Global.getParameter("nosound", true));
  		options.add(BeepOnly = new CheckboxMenuItemAction(this, Global
  			.resourceString("Beep_only")));
  		BeepOnly.setState(Global.getParameter("beep", true));
  		Menu sound = new MyMenu(Global.resourceString("Sound_Options"));
  		sound.add(SimpleSound = new CheckboxMenuItemAction(this, Global
  			.resourceString("Simple_sound")));
  		SimpleSound.setState(Global.getParameter("simplesound", true));
  		sound.add(EveryMove = new CheckboxMenuItemAction(this, Global
  			.resourceString("Every_move")));
  		EveryMove.setState(Global.getParameter("sound.everymove", true));
  		sound.add(Warning = new CheckboxMenuItemAction(this, Global
  			.resourceString("Timeout_warning")));
  		Warning.setState(Global.getParameter("warning", true));
  		sound
  			.add(new MenuItemAction(this, Global.resourceString("Test_Sound")));
  		options.add(sound);
  		options.addSeparator();
  		options.add(RelayCheck = new CheckboxMenuItemAction(this, Global
  			.resourceString("Use_Relay")));
  		RelayCheck.setState(Global.getParameter("userelay", false));
  		options.add(new MenuItemAction(this, Global
  			.resourceString("Relay_Server")));
  		options.addSeparator();
  		options.add(new MenuItemAction(this, Global
  			.resourceString("Set_Language")));
  		options.add(new MenuItemAction(this, "Close and Use English",
  			"CloseEnglish"));
  		menu.add(options);
  		// Help
  		Menu help = new MyMenu(Global.resourceString("Help"));
  		help.add(new MenuItemAction(this, Global.resourceString("About_Jago")));
  		help.add(new MenuItemAction(this, Global.resourceString("Overview")));
  		help.addSeparator();
  		help.add(new MenuItemAction(this, Global
  			.resourceString("Using_Windows")));
  		help.add(new MenuItemAction(this, Global
  			.resourceString("Configuring_Connections")));
  		help.add(new MenuItemAction(this, Global
  			.resourceString("Partner_Connections")));
  		help
  			.add(new MenuItemAction(this, Global.resourceString("About_Sounds")));
  		help.add(new MenuItemAction(this, Global
  			.resourceString("About_Smart_Go_Format_SGF")));
  		help
  			.add(new MenuItemAction(this, Global.resourceString("About_Filter")));
  		help.add(new MenuItemAction(this, Global
  			.resourceString("About_Function_Keys")));
  		help.add(new MenuItemAction(this, Global
  			.resourceString("Overcoming_Firewalls")));
  		help
  			.add(new MenuItemAction(this, Global.resourceString("Play_Go_Help")));
  		help.addSeparator();
  		help.add(new MenuItemAction(this, Global.resourceString("About_Help")));
  		help.addSeparator();
  		help.add(new MenuItemAction(this, Global
  			.resourceString("On_line_Version_Information")));
  		menu.setHelpMenu(help);
  		pack();
  		Global.setwindow(this, "mainframe", 300, 300);
  	}
  
  	@Override
  	public boolean close ()
  	{
  		if (Global.getParameter("confirmations", true))
  		{
  			CloseMainQuestion CMQ = new CloseMainQuestion(this);
  			if (CMQ.Result) doclose();
  			return false;
  		}
  		else
  		{
  			doclose();
  			return false;
  		}
  	}
  
  	@Override
  	public void doclose ()
  	{
  		Global.notewindow(this, "mainframe");
  		super.doclose();
  		Global.writeparameter(".go.cfg");
  		if (S != null) S.close();
  		if ( !Global.isApplet()) System.exit(0);
  	}
  
  	@Override
  	public void doAction (String o)
  	{
  		if ("CloseEnglish".equals(o))
  		{
  			Global.setParameter("language", "en");
  