CS 112 GUI - PowerPoint PPT Presentation

cs 112 gui n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CS 112 GUI PowerPoint Presentation
play fullscreen
1 / 32
CS 112 GUI
172 Views
Download Presentation
wes
Download Presentation

CS 112 GUI

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CS 112 GUI 06 May 2008 Bilkent

  2. Java GUI API • Containers: • containother GUI components. E.g, Window, Panel, Applet, FrameDialog. • Components: • Buttons, ComboBox, List, Slider, Labeletc. • Helpers: • Font, Color, Dimension, LayoutManageretc. Frame with normal window controls Optional Menu Three containers in Frame with Border Layout UI-components inside containers each with own layout

  3. LayoutManager • Flow Layout • By default • Border Layout • Grid Layout • Box Layout • Why layout? Layouts provideflexibility in different environments with different screen resolutions

  4. For X axis:

  5. Graphics • Previously, we have seen GUI components, their relationships, containers, layout managers. • Now we will see how to paint graphics on GUI components

  6. In this example if you resize the frame, line disappears, so how can we avoid this problem and display line permanently? -by inheriting Jlabel to draw line!

  7. --The paintComponent method is invoked, whenever a component is first displayed or redisplayed! --To draw things on component you first declare a class that extends a swing GUI and override paintComponent method

  8. The tester of SmileyFace:

  9. DrawingStrings, Lines, Rectangles, andOvals

  10. Drawingarcs

  11. DrawPolygons

  12. EventDrivenProgramming - In ED programming, code is executed when an event occurs • The program interacts with user and the events drive its execution. • Event is defined as a signal to the program that something has happened. • The component which an event is generated is called source object or source component. E.g., button

  13. Simpleexample

  14. Simpleexamplewithinnerclass Inner class is declared when it is only used by outer class And inner class can use the reference data and methods in outer class

  15. Anotherinnerclassexample Inner class also can be shortened by using anonymous inner classes(without a name),

  16. Anotherexample

  17. Mouse Example