Drawing tool
- In a main operation, create then display a window called "OS" which location is at (200,100) and size is (300,200).
javax.swing.JFrame OS = new javax.swing.JFrame("OS");
OS.setLocation(200,100);
OS.setSize(300,200);
OS.setVisible(true);
- By using "inheritance" and by overloading the default constructor, adapt the code such as the main can be simplified to:
new OS();
- To exit the program, add in the default constructor the following statement then by using
Eclipse
IDE implements the required operations to correct the code. Next, find the correct position where to add a System.exit(0)
.
this.addWindowListener(new java.awt.event.WindowListener() {});
- Next, find the statement to exit the application when pressing the key
'q'
.
To proceed, you can use the KeyEvent.getKeyChar()
operation.
- Now a) make the window
undecorated
and b) make it "full screen" with:
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.setFullScreenWindow(this);
- By overloading the
paint(Graphics g)
draw a circle on the screen.
- Next a) create a class
Circle
with a paint
operation, b) add an attribute c:Circle
to the application, and c) rewrite the paint
operation to display the circle.
- Adapt the application to display the circle at the mouse's click location.
- Change the circle to a list of circles and add circles on each click.
- Extend the application such as: by pressing
'a'
will add circles and pressing 's'
will select a circle - a selected circle will be in another color.
To proceed, you can add a selected
attribute to circles with two operations: select(x,y)
that changes the attribute depending on a click location and unselect
to reset the attribute.
- Adapt the application such as the circles' list is "persistent".
- Create an executable
jar
for the application (that contains source code).
source
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented