CIS525 - Lecture#15 - October 25, 2000

CIS 525 10/25/00 today we get a Dilbert... Chapter 11 AWT window objects: 1) canvas 2) panel 3) applet 4) scroll pane 5) frame 6) dialog 7) file dialog 8) window pg 499 limitations and types 1) canvas; page 501 -cannot contain GUI controls or nested windows -not stand alone, must be embedde -should draw itself by overriding paint -no layout manager steps for creating/using canvas i) create canvas Canvas canvas = new Canvas(); ii) resize canvas canvas.resize(width, height); //1.02 or canvas.setSiz(width, height); //1.1 iii) add canvas to container add(convas); or add("center", canvas); see Circle.java and CircleTest.java page 503 see ImageLabelTest.java for image manager simulation Components: in Java 1.02 => component methods are available in any component subclass, but component itself cannot be extended in Java 1.1 => lightweight components -provide ability to make direct component subclass -in 1.02 components always rectangular and opaque -with 1.1, components become transparent see BetterCircleTest2.java page 523 for example of transparent components set preferred size and minimum size you must call super.paint() or you won't get a drawing
2) panel, page 524; -borderless window -can contain GUI controls -must be embedded inside another window purpose: => to group components => to create custom components default layout manager is FlowLayout creating and using a panel i) create panel ii) add components - p.1 add(some component) iii) add panel to default current container - container.add(p1); not using border layout panels can be opaque or transparent panel heavey = new Panel(); //this will be opaque for 'lightweight' panel: page 535 applets page 536 LightweightPanel light=new LightweightPanel();
3) scroll pane, (1.1) -borderless window holding single component too big to see at once creating and using: page 539 i) create scroll pane - scrollPane(scrollPane.SCROLLBARS_ALWAYS) .SCROLLBARS_NEVER) .SCROLLBARS_ASNEEEDED) ii) set size of scroll pane and add it
4)frames: page 541 - starting point for stand alone graphics - can be used for pop-ups in applets - can contain GUI components default layout manager is borderLayout creating and using: i) fixed size a)create frame b)add components to frame c)resize the frame d) pop-up frame ii) stretching frame a) create frame b) position frame c) add components to frame d) stretch frame e) pop-up frame
we'll continue the list next time