Программирование на языке Java

Frame



Frame

Frame - это как раз то, что обычно и считают окном на рабочей поверхности экрана. У объекта Frame есть строка с заголовком, управляющие элементы для изменения размера и линейка меню. Для того, чтобы вывести/спрятать изображение объекта Frame, нужно использовать методы show и hide. Ниже приведен пример апплета, который показывает объект Frame с содержащимся в нем компонентом TextArea. /* <applet code = "FrameDemo" width=200 height=200> </applet> */ import java.awt.*; import java.applet.*; public class FrameDemo extends Applet { public void init() { int width = Integer.parseInt(getParameter("width")); int height = Integer.parseInt(getParameter("height")); String val = "There are two ways of constructing " + "a software design.\n" + "One way is to make it so simple\n" + "that there are obviously no deficiencies.\n" + "And the other way is to make it so complicated" + "that there are no obvious deficiencies.\n\n" + "C.A.R. Hoare\n\n"; TextArea text = new TextArea(val, 80, 40); Frame f = new Frame("Demo Frame"); f.setSize(width, height); f.add("Center", text); f.show(); } }



Содержание раздела