Вопрос

I have created a method for getting the text from a selected radio button when I pass it the buttongroup it's in. I've been reading that helper/utility classes might not be the best idea because they can turn into god classes, which I can see happening after a while. Plus, I'm only adding one method and that method is very specific to buttons.

So my question is, is there a best way to add a method to a class that oracle made? I would like this method to always be available whenever I make a new project and use buttongroups.

Это было полезно?

Решение

Create a subclass that contains your new method.

Inheritance: http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

Другие советы

Do you mean that you want to add methods to JRadioButton? You cannot do that. The typical way this is done is by extending JRadioButton, add the method and use that class everywhere.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top