10-AWT-Components

10-AWT-Components - 2006 Marty Hall AWT Components: Simple...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
2 JSP, Servlet, Struts, JSF & Java 5 Training: http://courses.coreservlets.com © 2006 Marty Hall AWT Components: Simple User Interfaces 3 JSP, Servlet, Struts, JSF & Java 5 Training: http://courses.coreservlets.com © 2006 Marty Hall For live Java training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, AJAX, Java 5, etc. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 J2EE training: http://courses.coreservlets.com Agenda Basic AWT windows Canvas, Panel, Frame, Dialog Creating lightweight components Closing frames Using object serialization to save components to disk Basic AWT user interface controls Button, checkbox, radio button, list box, scrollbars Processing events in GUI controls 5 J2EE training: http://courses.coreservlets.com Windows and Layout Management Containers Most windows are a Container that can hold other windows or GUI components. Canvas is the major exception. Layout Managers Containers have a LayoutManager that automatically sizes and positions components that are in the window You can change the behavior of the layout manager or disable it completely. Details in next lecture. Events Windows and components can receive mouse and keyboard events, just as in previous lecture.
Background image of page 2
6 J2EE training: http://courses.coreservlets.com Windows and Layout Management (Continued) Drawing in Windows To draw into a window, make a subclass with its own paint method Having one window draw into another window is not usually recommended Popup Windows Some windows ( Frame and Dialog ) have their own title bar and border and can be placed at arbitrary locations on the screen Other windows ( Canvas an Panel ) are embedded into existing windows only 7 J2EE training: http://courses.coreservlets.com Canvas Class Major Purposes A drawing area A custom Component that does not need to contain any other Component (e.g. an image button) Default Layout Manager - None Canvas cannot contain any other Components Creating and Using Create the Canvas Canvas canvas = new Canvas(); Or, since you typically create a subclass of Canvas that has customized drawing via its paint method: SpecializedCanvas canvas = new SpecializedCanvas();
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 J2EE training: http://courses.coreservlets.com Canvas (Continued) Creating and Using, cont. Size the Canvas canvas. setSize (width, height); Add the Canvas to the current Window add(canvas); or depending on the layout manager you can position the Canvas add (canvas, BorderLayout. Region_Name ); If you first create a separate window (e.g. a Panel), then put the Canvas in the window using something like someWindow.add(canvas); 9 J2EE training: http://courses.coreservlets.com Canvas Example import java.awt.*; /** A Circle component built using a Canvas. */ public class Circle
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 36

10-AWT-Components - 2006 Marty Hall AWT Components: Simple...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online