import java.applet.*; import java.awt.*; public class frames extends Applet { Frame window = new Frame("This is the Frame's Title Bar!"); Button btn = new Button("Create a new Frame"); public void init() { add(new Label("Hit this button to")); add(btn); add(new Label(".")); add(new Label("The new Frame is independent of the applet.")); add(new Label("You can maximize and minimize it by using")); add(new Label("the buttons on the top right or the control icon.")); add(new Label("on the top left. You will not be able to close it.")); add(new Label("You must use the applet's button to do that.")); add(new Label("In order to handle Frame events you need to ")); add(new Label("create a separate class for it.")); window.setLayout(new FlowLayout()); window.add(new Label("This is the Frame.")); window.add(new Label("You can resize it, move it")); window.add(new Label("and perform other Windows operations.")); } public boolean action(Event evt, Object whatAction) { if((evt.target instanceof Button)) { String buttonLabel = (String) whatAction; if (buttonLabel == "Destroy the Frame") { window.hide(); window.dispose(); btn.setLabel("Create a new Frame"); return true; } if (buttonLabel == "Create a new Frame") { window.resize(300,200); window.show(); btn.setLabel("Destroy the Frame"); return true; } } return false; } }