/**
* Kandata
* Copyright (C) 2003. Yoshinori Watanabe
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package hello.client;

import java.awt.event.*;
import javax.swing.*;
import kandata.client.*;
import kandata.*;

/** クライアントアプリケーション */
public class HelloClient extends JFrame implements KandataClient {

	KandataConnector connector;
	JLabel label = new JLabel("ここにサーバ側から受信した文字が表示されます。");

	public HelloClient() {
		super("Kandata-Hello");
		this.getContentPane().add(label);
		this.setSize(300,100);
		this.setVisible(true);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				try {
					connector.disconnect();
				} catch (Exception ex) { ex.printStackTrace(); }
				System.exit(0);
			}
		});
	}

	/** クライアントアプリケーションを開始する. */
	public void init(KandataConnector connector) {
		this.connector = connector;
		try {
			String message = (String) connector.invoke("getMessage", null);
			label.setText(message);
		} catch (Exception ex) { ex.printStackTrace(); }
	}
}
