/***************************************************************************** StackTest.java An applet to demonstrate & test StackLayout.java bruce.miller@nist.gov (NIST is a part of the US Government; software is therefore not subject to copyright) ******************************************************************************/ package test; import java.applet.*; import java.awt.*; import gui.*; public class StackTest extends Applet { public void init() { Frame frame = new MyFrame(); Panel p; TextArea t; Color color = Color.darkGray; frame.setLayout(new StackLayout(StackLayout.VERTICAL)); frame.add(new Label("StackLayout Demo & Tester")) .setFont(new Font("Helvetica",Font.BOLD,14)); p = addHPanel(frame); p.add("Left",new Button("Left")); p.add("Wide",new Label("A Wide label going on and on and on and on and on and on and on and on and on and on and on")); p.add("Right",new Button("Right")); frame.add("Fill",t = new TextArea()); t.appendText("This is a Fill'ed Text Area.\n" + "With some text in it.\nIt is stretchy"); frame.add("Center",new Label("Below is an hrule")); frame.add("Wide Height=3 Flush",new Canvas()).setBackground(color); frame.add("Wide Tall*2",t = new TextArea()); t.appendText("This is another Text Area,\n" + "with some text in it.\n" + "It's height is filled with weight 2"); frame.add("Wide",new Button("A wide Button")); frame.add("Wide Height=3 Flush",new Canvas()).setBackground(color); frame.add("Center",new Label("Ugly, but shows placement")); p = addHPanel(frame); p.add("Left",new Button("Left")); p.add("Left",new Button("Left, too")); p.add("Right",new Button("Right")); p = addHPanel(frame); p.add("Left",new Button("Left")); p.add("Center",new Button("Center")); p.add("Center",new Button("Center,too")); p.add("Right",new Button("Right")); p = addHPanel(frame); p.add("Left",new Button("Left")); p.add("Center",new Button("Center")); p.add("Left",new Button("Left!!")); p.add("Right",new Button("Right")); p = addHPanel(frame); p.add("Left",new Button("Left")); p.add("Center",new Button("Center")); p.add("Right",new Button("Right")); p.add("Right",new Button("Right, too")); frame.add("Wide Height=3 Flush",new Canvas()).setBackground(color); p = addHPanel(frame); p.add("Left",new Label("Horizontal panel w/50pixel Strut")); p.add("Left Width=3 Height=50 Flush",new Canvas()).setBackground(color); p.add("Top",new Button("Top")); p.add("Center",new Button("Center")); p.add("Bottom",new Button("Bottom")); p.add("Tall",new Button("Tall")); frame.pack(); frame.show(); } Panel addHPanel(Frame f) { Panel p = new Panel(); p.setLayout(new StackLayout(StackLayout.HORIZONTAL)); f.add("Wide Flush",p); return p; } } class MyFrame extends Frame { public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY) { dispose(); return true; } return false; } }