I am new to Java but have some C, C++, VB6, and VB.Net. I've written my first GUI and would like to center it on the screen when it starts.

Also, I would like to put the cursor in the appropriate input box, depending on a user's choice of radio button.

Any help will be appreciated... Thanks in advance.
e c yarter

Don't force it - Get a bigger hammer!

12 Years
Discussion Span
Last Post by ecyarter


Thanks, Richard,

All this was so easy in VB... I got spoiled. If I only wanted to program for Windows, I wouldn't be here, would I?

e c yarter (Chuck)



grabFocus worked fine, thanks.

I added the code for centering the window after the code that sets up the

window in the first place and it compiled OK, but never got past the line

where it moves the window to the designated coordinates. It just sits

there, frozen, in the corner of the screen. Only thing that works is the

control box in the title bar. Checking the x,y coordinates, I got x=216,

y=297, where my window size is 600X200, and screen size is 1024x768.

Doing the math, the point would be at 212,284. This doesn't seem too far


Any idea what's wrong? I don't have to turn this in till March, and

centering the window isn't required for the assignment. Everything else

works fine, so no pressure. But the whole idea is to make this thing do

what I want it to, isn't it?

By the way, I'm using XP Home... maybe it's a bug?

e c yarter (Chuck)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.