Java Reference
In-Depth Information
Exercises
2.1
What happens if you click on the 'close' button of one of the windows? Explain
the observed behaviour. Then remove the line.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
from the constructor of SimpleFrame . Add the following code at the begin-
ning of the main -method in class SimpleFrameDriver :
int k=0;
while ( true ){
System.out.println("SimpleFrameDriver: Still running! "+k);
k++;
}
This will print lines to the console as long as the application is running. Then
compile and start the application and click on the 'close' buttons of the win-
dows. Observe what has changed and explain it.
2.2
Check what happens if the central component in a border layout of a frame
is not present. Add different combinations of border components, e.g. 'East'
and 'South'.
2.3
Play around with layouts to get a feeling of what the layout managers do. Re-
size the frames, change the parameters in the layouts (distances, row/column
numbers), etc.
Search WWH ::




Custom Search