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!

Hi everyone,

First let me say welcome to this forum

For the centering of the frame see the below link

http://javaalmanac.com/egs/java.awt/screen_CenterScreen.html

As for the setting the focus of a particular component do this

instance_of_your_component.grabFocus();

I hope this helps you

Yours Sincerely

Richard West

[

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)

Richard,

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

apart...

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.