Java Reference
In-Depth Information
Figure 14-12. JLabel with HTML text
Centering a Main Window
Problem
You want your main window to be centered on the screen.
Solution
First, be aware that some users on some platforms would rather that you didn't do this be-
cause they have existing “placement” schemes. However, at least on Windows, this tech-
nique is useful.
Subtract the width and height of the window from the width and height of the screen, divide
by two, and go there. Be aware that some platforms (Mac, Unix) make it pretty easy for the
power user to have multiple monitors active, so you don't always want to do this.
Search WWH ::




Custom Search