setBounds() method

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

Yes.

setBounds() method

The setBounds() method not only specifies the size of the frame, but the location of the upper left corner:

public void setBounds(int x, int y, int width, int height)

This puts the upper left corner at location (x, y), where x the the number of pixels from the left of the screen and y is is the number from the top of the screen. height and width are as before.

QUESTION 8:

Do you always want to exit the program when the close button (the little X button) is clicked?