views:

23

answers:

1

In a rich client CRUD framework I'm working on, I have a so-called edit panel, which as the name suggests, is involved in editing row objects via the usual swing input components.

Now, the panel has a default focus component field, which references the input field which should receive focus when the edit panel is initialized or cleared. The problem is the most logical name for the method which performs the focus request.

public boolean requestDefaultFocus()
  return getDefaultFocusComponent().requestFocusInWindow();
}

The edit panel extends JPanel so this overrides the now deprecated JComponent method. The method name I'm currently using to avoid this is setDefaultFocus().That just doesn't sound quite right, although I will be able to live with it in case the answer to the question turns out to be a resounding no.

So, what are your thoughts on overriding a deprecated method like that?

+1  A: 

I would not recommend it. There's no way to stop your code from issuing deprecation warnings. It makes it look like there's something wrong. And that takes developer time to verify that the warnings are spurious.

How about setInitialFocus()?

Devon_C_Miller
Thank you sir! setInitialFocus() sounds just right, I'll rename the field to initialFocusComponent as well, now all I can do is wonder why I hadn't come up with that my self :).
darri