package examples; import ise.java.awt.*; import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*; /** * Another example of KappaLayout showing a dialog that has always been * difficult to do nicely -- getting the buttons to center on the lists vertically * is a hassle and getting the lists to be the same width and height is similarly * difficult. Perhaps most difficult is centering the bottom buttons. KappaLayout * makes this easy. */ public class KappaLayoutApplet3 extends Applet { Frame f; public void init() { // set up a Frame f = new Frame("KappaLayout Applet"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f.hide(); f.dispose(); } }); KappaLayout ll = new KappaLayout(); Panel p = new Panel(); p.setLayout(ll); /* Design: 012 0L L L = Labels 1C C C = List, span 6 rows 2C C 3CBC B = Button, -> 4CBC B = Button, <- 5C C 6C C 7PPP P = Panel w/Buttons, span 3 columns */ p.add("0,0,,1,7,w,2", new Label("Pick something from this list:")); p.add("2,0,,1,7,w,2", new Label("Selected items:")); p.add("0,1,,6,,wh,5", new java.awt.List(10)); p.add("2,1,,6,,wh,5", new java.awt.List(10)); p.add("1,3", new Button("->")); p.add("1,4", new Button("<-")); ll.makeColumnsSameWidth(0,2); KappaLayout kl = new KappaLayout(); Panel button_panel = new Panel(); button_panel.setLayout(kl); button_panel.add("0,1,,,,w", new Button("OK")); button_panel.add("1,1,,,,w", new Button("Cancel")); kl.makeColumnsSameWidth(0,1); p.add("0,7,3,1", button_panel); f.add(p); f.pack(); } public void start() { f.show(); } }