Another approach, if you know the window has roughly the same dimensions each time you use it, just guide the mouse to the right spot and then send a mouse click. This way might be easier as you don't need to get a list of controls and then work out which one you want. That would be the best way of course, once you've done the hard work of programming it. My way above would be a quick hack.
In case you're wondering though, people are less likely to devote time to programming a solution they can't test. Which java program are you using and which screen is it you need help with? Maybe you could post a picture of it? Without such info you're likely to get only general advice. Good luck.