home *** CD-ROM | disk | FTP | other *** search
- Save Format v2.0(1)
- @begin Form "Form2"
- Exported 0;
- Abstract 0;
- Interface 0;
- PackageName "";
-
- @begin Object "powersoft.jcm.ui.Applet"
- Font "Dialog-Plain-8";
- ControlScope "Private";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "Java Chat";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- @begin Event "powersoft.jcm.event.Create"
- GencodeSrcLine 168;
- FunctionName "Form2_Create";
- @end;
- @begin Event "powersoft.jcm.event.Destroy"
- GencodeSrcLine 175;
- FunctionName "Form2_Destroy";
- @end;
- @begin UserFunction "Form2(powersoft.jcm.ui.AWTAppletEx applet)"
- Compiler 1;
- GencodeSrcLine 163;
- FunctionName "Form2::Form2(powersoft.jcm.ui.AWTAppletEx applet)";
- @end;
- ResID 102;
- DesignName Form2;
- TabIndex 0;
- DesignRect 153,134,263,231;
- @end;
-
- @begin Object "powersoft.jcm.net.Socket"
- Asynchronous "1";
- @begin Event "powersoft.jcm.event.SocketConnect"
- GencodeSrcLine 185;
- FunctionName "socket_1_SocketConnect";
- @end;
- @begin Event "powersoft.jcm.event.SocketDataArrival"
- GencodeSrcLine 192;
- FunctionName "socket_1_SocketDataArrival";
- @end;
- @begin Event "powersoft.jcm.event.SocketError"
- GencodeSrcLine 221;
- FunctionName "socket_1_SocketError";
- @end;
- @begin Event "powersoft.jcm.event.SocketHostResolved"
- GencodeSrcLine 232;
- FunctionName "socket_1_SocketHostResolved";
- @end;
- @begin Event "powersoft.jcm.event.SocketSendComplete"
- GencodeSrcLine 240;
- FunctionName "socket_1_SocketSendComplete";
- @end;
- ResID 100;
- DesignName socket_1;
- TabIndex 0;
- DesignRect 240,5,19,17;
- @end;
-
- @begin Object "powersoft.jcm.ui.Label"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "S&erver:";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 101;
- DesignName label_1;
- TabIndex 1;
- DesignRect 5,5,40,15;
- @end;
-
- @begin Object "powersoft.jcm.ui.TextBox"
- Font "<Inherited>";
- PasswordCharacter "0";
- BackColor "Color.white";
- ForeColor "Color.black";
- Text "";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 102;
- DesignName textb_1;
- TabIndex 2;
- DesignRect 5,20,145,15;
- @end;
-
- @begin Object "powersoft.jcm.ui.CommandButton"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "&Connect";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- @begin Event "powersoft.jcm.event.Click"
- GencodeSrcLine 247;
- FunctionName "cb_1_Click";
- @end;
- ResID 103;
- DesignName cb_1;
- TabIndex 3;
- DesignRect 155,20,40,14;
- @end;
-
- @begin Object "powersoft.jcm.ui.CommandButton"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "&Disconnect";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- @begin Event "powersoft.jcm.event.Click"
- GencodeSrcLine 261;
- FunctionName "cb_2_Click";
- @end;
- ResID 104;
- DesignName cb_2;
- TabIndex 4;
- DesignRect 200,20,45,14;
- @end;
-
- @begin Object "powersoft.jcm.ui.ListBox"
- Font "<Inherited>";
- Sort "0";
- DataTrackRow "0";
- DataBindAsLookup "0";
- DataLookupSource "NULL";
- DataLookupColumns "";
- BackColor "Color.white";
- ForeColor "Color.black";
- Text "";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 105;
- DesignName lb_1;
- TabIndex 5;
- DesignRect 5,55,200,75;
- @begin ComponentData "lb_1"
- @end;
- @end;
-
- @begin Object "powersoft.jcm.ui.Label"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "&Log:";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 106;
- DesignName label_2;
- TabIndex 6;
- DesignRect 5,40,30,15;
- @end;
-
- @begin Object "powersoft.jcm.ui.CommandButton"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "C&lear";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- @begin Event "powersoft.jcm.event.Click"
- GencodeSrcLine 270;
- FunctionName "cb_3_Click";
- @end;
- ResID 107;
- DesignName cb_3;
- TabIndex 7;
- DesignRect 210,55,40,14;
- @end;
-
- @begin Object "powersoft.jcm.ui.TextBox"
- WTextBoxMultiLine 1;
- Font "<Inherited>";
- PasswordCharacter "0";
- BackColor "Color.white";
- ForeColor "Color.black";
- Text "";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 108;
- DesignName textb_2;
- TabIndex 8;
- DesignRect 5,150,200,50;
- @end;
-
- @begin Object "powersoft.jcm.ui.Label"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "&Message:";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- ResID 109;
- DesignName label_3;
- TabIndex 9;
- DesignRect 5,135,45,15;
- @end;
-
- @begin Object "powersoft.jcm.ui.CommandButton"
- Font "<Inherited>";
- BackColor "Color.lightGray";
- ForeColor "Color.black";
- Text "&Send";
- Visible "1";
- DataSource "NULL";
- DataColumns "";
- BoundControl "0";
- @begin Event "powersoft.jcm.event.Click"
- GencodeSrcLine 277;
- FunctionName "cb_4_Click";
- @end;
- ResID 110;
- DesignName cb_4;
- TabIndex 10;
- DesignRect 210,150,40,14;
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- // add your custom import statements here
-
- @end-code;
- GencodeSrcLine 16;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- private final int MAX_BUFFER_SIZE = 512;
-
- private int _line_number;
- private int _lines_to_send;
-
- private int _recv_buffer_index = 0;
- private byte[] _recv_buffer = new byte[ MAX_BUFFER_SIZE ];
-
- @end-code;
- GencodeSrcLine 317;
- @end;
-
- @begin-code BaseClassList
-
- extends powersoft.jcm.ui.Applet
-
- @end-code;
-
- @begin-code GeneratedClassContents
-
-
- @end-code;
-
- @begin-code Code "Form2::Form2(powersoft.jcm.ui.AWTAppletEx applet)"
-
- public @CLASSNAME@(powersoft.jcm.ui.AWTAppletEx applet)
- {
- super(applet);
- }
-
- @end-code;
-
- @begin-code Code "Form2_Create"
-
- public boolean Form2_Create(powersoft.jcm.event.CreateEvent event)
- {
- textb_1.setText( socket_1.getLocalHostName() );
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "Form2_Destroy"
-
- public boolean Form2_Destroy(powersoft.jcm.event.DestroyEvent event)
- {
- if ( socket_1.getType() ==
- powersoft.jcm.net.Socket.SockSTREAM ) {
- socket_1.close();
- }
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "socket_1_SocketConnect"
-
- public boolean socket_1_SocketConnect(powersoft.jcm.event.SocketConnectEvent event)
- {
- lb_1.add( "Connected." );
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "socket_1_SocketDataArrival"
-
- public boolean socket_1_SocketDataArrival(powersoft.jcm.event.SocketDataArrivalEvent event)
- {
- int bytes_read;
- byte[] buffer = new byte[ MAX_BUFFER_SIZE ];
- byte b;
- String line;
-
- //lb_1.add( "Data arrival " + event.getBytesReceived() );
- bytes_read = socket_1.receive( buffer, event.getBytesReceived() );
- if ( bytes_read < 0 ) {
- lb_1.add( "*** Receive error!" );
- } else {
- for ( int i = 0; i < bytes_read; i += 1 ) {
- b = buffer[i];
- if ( b == '\n' ) {
- _recv_buffer[ _recv_buffer_index ] = 0;
- line = new String( _recv_buffer, 0, 0, _recv_buffer_index );
- lb_1.add( line );
- _recv_buffer_index = 0;
- } else if ( b == 0 ) {
- } else {
- _recv_buffer[ _recv_buffer_index++ ] = b;
- }
- }
- }
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "socket_1_SocketError"
-
- public boolean socket_1_SocketError(powersoft.jcm.event.SocketErrorEvent event)
- {
- byte error = event.getError();
-
- if ( error != powersoft.jcm.net.Socket.SockEIsCreated ) {
- lb_1.add( "*** Socket Error: " + error );
- }
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "socket_1_SocketHostResolved"
-
- public boolean socket_1_SocketHostResolved(powersoft.jcm.event.SocketHostResolvedEvent event)
- {
- lb_1.add( "Host resolved. Connecting..." );
- socket_1.connect();
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "socket_1_SocketSendComplete"
-
- public boolean socket_1_SocketSendComplete(powersoft.jcm.event.SocketSendCompleteEvent event)
- {
- textb_2.setText( "" );
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "cb_1_Click"
-
- public boolean cb_1_Click(powersoft.jcm.event.ClickEvent event)
- {
- String host = textb_1.getText();
-
- socket_1.create( powersoft.jcm.net.Socket.SockSTREAM );
- if ( socket_1.getRemotePort() != 1777 ) {
- socket_1.setRemotePort( 1777 );
- }
- socket_1.setRemoteHostName( host );
- lb_1.add( "Looking up " + host );
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "cb_2_Click"
-
- public boolean cb_2_Click(powersoft.jcm.event.ClickEvent event)
- {
- if ( socket_1.close() ) {
- lb_1.add( "Connection closed." );
- }
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "cb_3_Click"
-
- public boolean cb_3_Click(powersoft.jcm.event.ClickEvent event)
- {
- lb_1.deleteAll();
-
- return false;
- }
-
- @end-code;
-
- @begin-code Code "cb_4_Click"
-
- public boolean cb_4_Click(powersoft.jcm.event.ClickEvent event)
- {
- byte[] buffer = new byte[ MAX_BUFFER_SIZE ];
- int len;
- String msg;
-
- _line_number = 0;
- _lines_to_send = textb_2.getLineCount();
- //if ( _line_number < _lines_to_send ) {
- msg = textb_2.getText();
- // There is no getText( int ) method for TextBox
- // right now; for now
- // extract _line_number line from msg
- len = msg.length();
- msg = msg + "\n";
- len += 1;
- msg.getBytes( 0, len, buffer, 0 );
- socket_1.send( buffer, len );
- //}
-
- return false;
- }
-
- @end-code;
- @end;
-