package awtExtExamples ; import java.awt.*; import awtExt.CallbackInfo ; public class CardPanel extends Panel { Panel create(LayoutManager layout) { Panel p = new Panel(); p.setLayout(layout); try { p.add("North", new awtExt.Button("one" , this, "buttonMethod" )); p.add("West", new awtExt.Button("two" , this, "buttonMethod" )); p.add("South", new awtExt.Button("three", this, "buttonMethod" )); p.add("East", new awtExt.Button("four" , this, "buttonMethod" )); p.add("Center", new awtExt.Button("five" , this, "buttonMethod" )); } catch( Exception e ) { e.printStackTrace() ; } ; return p; } CardPanel() { setLayout(new CardLayout()); add("one", create(new FlowLayout())); add("two", create(new BorderLayout())); add("three", create(new GridLayout(2, 2))); add("four", create(new BorderLayout(10, 10))); add("five", create(new FlowLayout(FlowLayout.LEFT, 10, 10))); add("six", create(new GridLayout(2, 2, 10, 10))); } public Dimension preferredSize() { return new Dimension(200, 100); } //--------------------------------------- // Call back method for button object. The label // of the button is the argument to pass to CardLayout.show().. // public void buttonMethod( CallbackInfo cbi ) { ((CardLayout)getLayout()).show(this,(String)cbi.what); } }