1 / 32

CS 112 GUI

CS 112 GUI. 06 May 2008 Bilkent. Java GUI API. Containers : contain other GUI components . E.g, Window , Panel, Applet , Frame Dialog . Components : Buttons , ComboBox , List , Slider , Label etc . Helpers : Font, Color , Dimension , LayoutManager etc.

wes
Download Presentation

CS 112 GUI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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

More Related