https://github.com/msh-trojan/java_21_jframe_show_colors_1
Programm showing How we can represent Colors on a canvas using JFrame class and the GUI components(here we use the paint() component).
https://github.com/msh-trojan/java_21_jframe_show_colors_1
awt-gui graphics gui-components inheritance java jframe paint swing-gui
Last synced: about 1 year ago
JSON representation
Programm showing How we can represent Colors on a canvas using JFrame class and the GUI components(here we use the paint() component).
- Host: GitHub
- URL: https://github.com/msh-trojan/java_21_jframe_show_colors_1
- Owner: MSH-trojan
- Created: 2024-08-22T15:13:39.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-22T15:32:44.000Z (almost 2 years ago)
- Last Synced: 2024-08-22T17:11:56.951Z (almost 2 years ago)
- Topics: awt-gui, graphics, gui-components, inheritance, java, jframe, paint, swing-gui
- Language: Java
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java_21_JFrame_Show_Colors_1
### Some general notations:
Graphics applications typically employ many classes.
Many of these classes are part of the Abstract Windows Tools (*AWT*)
To see the wealth of classes available in Java use the website: **http://docs.oracle.com/javase/7/docs/api**
### Comments about the JFrame example:
The JFrame application *ShowColors* is a driver type class.
In the class *ShowColors*, presented in the previous 2 slides, we saw the following methods/constructor:
1 - ***main()***, which is the regular driver method for any application on your computer.
In this case its main job is to create a ShowColors object with the reference “application”.
This will call the constructor with no parameters.
A secondary job is to provide the feature “X” on the top right corner of the frame created, which if clicked will close the frame.
2 - The constructor ***ShowColors()*** contains 3 calls to JFrame methods: *super()*, passes to the JFrame constructor a text which will appear on the frame title bar, *setSize()* gives
the width and the height of the frame, and *show()*.
3 - The Graphics method *paint()* is overwritten in class *ShowColors*.
Class Graphics is above class JFrame in the inheritance tree of Java Development Kit.
4 - The Graphics methods drawString() and fillRect() use x,y coordinates.