package com.wiley.compbooks.brose.chapter8.roomBooking;

import java.awt.*;
import java.awt.event.*;
import org.omg.CORBA.*;
import com.wiley.compbooks.brose.chapter8.roomBooking.RoomPackage.*;

public class ClientApplication
    extends Frame
    implements WindowListener 
{
    
    private static RoomBookingClient client;

    /** constructor */
    ClientApplication() {
        super( "Room Booking System" );
        addWindowListener( this );
        setSize( 350, 250 );
    }

    public void windowActivated(WindowEvent e) {}
    public void windowClosed(WindowEvent e) 
    {
	System.exit(0);
    }
    public void windowClosing(WindowEvent e) {}
    public void windowDeactivated(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}
    public void windowIconified(WindowEvent e) {}
    public void windowOpened(WindowEvent e) {}

    /** override to reposition frame (for appearances sake only) */
    public synchronized void setVisible(boolean vis) 
    {
        if(vis == true) {
            setLocation(50, 50);
        }
            super.setVisible(vis);
    }

    public static void main(String args[]) 
    {
        // create an object of its own class
        ClientApplication gui =
            new ClientApplication();

        gui.setVisible(true);

        // create a RoomBookingClient object -
        // using the application constructor
        client = new RoomBookingClient();

        // initialise the GUI
        client.init_GUI( gui );

        // initialise the Naming Service
        client.init_from_ns();

        // view existing bookings
        client.view();
    }
}
