Download presentation
Presentation is loading. Please wait.
1
CS 112 GUI 06 May 2008 Bilkent
2
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. Frame with normal window controls Optional Menu Three containers in Frame with Border Layout UI-components inside containers each with own layout
7
Layout Manager Flow Layout ◦ By default Border Layout Grid Layout Box Layout Why layout? Layouts provide flexibility in different environments with different screen resolutions
13
For X axis:
14
Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components
15
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!
16
--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
17
The tester of SmileyFace:
18
Drawing Strings, Lines, Rectangles, and Ovals …
19
Drawing arcs
20
Draw Polygons
21
Event Driven Programming - 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
28
Simple example
29
Simple example with inner class 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
30
Another inner class example Inner class also can be shortened by using anonymous inner classes(without a name),
31
Another example
32
Mouse Example
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.