694 Graphical User Interface Components: Part 1 (Dedicated web hosting) Chapter
694 Graphical User Interface Components: Part 1 Chapter 12 27 // set up leftButton and register listener 28 leftButton = new JButton( “Left” ); 29 30 leftButton.addActionListener( 31 32 // anonymous inner class 33 new ActionListener() { 34 35 // process leftButton event 36 public void actionPerformed( ActionEvent event ) 37 { 38 layout.setAlignment( FlowLayout.LEFT ); 39 40 // re-align attached components 41 layout.layoutContainer( container ); 42 } 43 44 } // end anonymous inner class 45 46 ); // end call to addActionListener 47 48 container.add( leftButton ); 49 50 // set up centerButton and register listener 51 centerButton = new JButton( “Center” ); 52 53 centerButton.addActionListener( 54 55 // anonymous inner class 56 new ActionListener() { 57 58 // process centerButton event 59 public void actionPerformed( ActionEvent event ) 60 { 61 layout.setAlignment( FlowLayout.CENTER ); 62 63 // re-align attached components 64 layout.layoutContainer( container ); 65 } 66 } 67 ); 68 69 container.add( centerButton ); 70 71 // set up rightButton and register listener 72 rightButton = new JButton( “Right” ); 73 74 rightButton.addActionListener( 75 76 // anonymous inner class 77 new ActionListener() { 78 Fig. 12.24 Program that demonstrates components in FlowLayout(part 2 of 3). Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01