package galasoftLB.pCommTest; import java.awt.*; import java.applet.*; import galasoftLB.api.pGSUtils.GSObjectComm; public class CommTest extends Applet { Button buttonSubmit = new Button( "Submit" ); Button buttonReset = new Button( "Reset" ); TextField theTextField = new TextField( 20 ); String myName; String myPartnerName; boolean hasBeenAdded = false; public CommTest() { } public void init() { myName = this.getParameter( "name" ); myPartnerName = this.getParameter( "TheOtherAppletName" ); this.add( theTextField ); this.add( buttonSubmit ); this.add( buttonReset ); this.setBackground( Color.white ); } public void start() { System.out.println( "starting " + myName ); GSObjectComm.enableOutputOnConsole( true ); GSObjectComm.init(); try { GSObjectComm.addObject( myName, this ); hasBeenAdded = true; } catch ( Exception ex ) { ex.printStackTrace(); hasBeenAdded = false; } } public void stop() { if ( hasBeenAdded ) { GSObjectComm.removeObject( myName ); } } public boolean action( Event theEvent, Object arg ) { if ( theEvent.target == buttonSubmit ) { buttonSubmitAction(); return true; } else { if ( theEvent.target == buttonReset ) { buttonResetAction(); return true; } } return false; } private void buttonSubmitAction() { CommTest theOtherOne = (CommTest) GSObjectComm.getObject( myPartnerName ); theOtherOne.submitText( theTextField.getText() ); } private void buttonResetAction() { theTextField.setText( "" ); } public void submitText( String theNewText ) { theTextField.setText( theNewText ); } }