java @action method parameters in netbeans
I have @Action for example:
@Action
public void example(String name){
//sth to do
}
and I would like to add this method 开发者_JAVA技巧to button generated in netbeans. When I click to Customize Code and write:
myButton.setAction(example(myButton.getName()));
I'm getting error: 'void' type not allowed here.
Why I can't do like this? :/ @Actions generated by netbeans are also return void.
myButton.setAction
is a function which expects an argument. example
is a function which does not return anything.
myButton.setAction(example(...))
passes the value returned by an invocation of example(...)
to setAction
.
Do you see why that's a problem?
精彩评论