






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In the course of the Introduction to Jave Programming, we study the basic syntax and the basic program in java. In these lecture slides the key points are: Guis, Make Windows, Put Stuff in Windows, Sequential, Event Driven, Sequential Programming, Beginning, Time, Exceptions, Program
Typology: Slides
1 / 11
This page cannot be seen from the preview
Don't miss anything!
Docsity.com
Previously we used JLabels to hold text We can also use JLabel to hold an image:
To do some more advanced drawing, we will have to extend JFrame (to override methods): Then we need to override the paint() method: DrawCircle is just an example name Docsity.com
Java normally updates your GUI automatically Sometimes you need to update manually: repaint - redraw the whole window pack - resize the window revalidate - layout is redone (in case you removed any objects) If your window seems to not be correct (or not updating) try running one/all of theseDocsity.com
We have seen how to detect when you click the mouse, so let's use that to draw! To do this we need to make a MouseListener:
The JColorChooser is a pre-built class that allows you to choose a color (from a GUI) To run the GUI, use showDialog() (returns Color): (See: RainbowMouseDraw.java) associated window title of color GUI initial color selected Docsity.com
You can also use the Graphics class to draw a more customizable String than JLabel To do need to simply call drawString(): Can also change Font with: (See: DrawStringExample.java) starting x pixel starting y pixel point size Docsity.com