package awtExtExamples; /* * * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. Please refer to the file "copyright.html" * for further important copyright and licensing information. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ // // Note only two classes are used from the java.awt package // import java.awt.BorderLayout; import java.awt.Event; import sysExt.* ; import awtExt.* ; /** * A test of a Container with BorderLayout. */ public class BorderTest extends Frame { public BorderTest() { super("BorderTest"); try { // // Create callback for button.. // methodRef mr = Callback.newRef( this, "buttonMethod" ) ; setLayout(new BorderLayout(5, 5)); // // Add the buttons to the border layout object. // Note that all button points to the same callback, // ie. on a button press, buttonMethod() will be called back. // add( "North", new Button("North", mr)); add( "Center", new Button("Center", mr)); add( "South", new Button("South", mr)); add( "West", new Button("West", mr)); add( "East", new Button("East", mr)); resize( 300, 300 ) ; move(200, 100); pack(); show(); } catch( Exception e ) { System.out.println( "Exception..." ); e.printStackTrace() ; } } //-------------------------------------------------- // The called back method. Invoked whenever // there is a button pressed. Prints out label // of the button. // public void buttonMethod(CallbackInfo cbi) { System.out.println("Button pressed: " + (String)cbi.what ); return; } public static void main(String args[]) { BorderTest b = new BorderTest(); } }