This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 156293 - Allow to use custom methods as event handlers directly
Summary: Allow to use custom methods as event handlers directly
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL: http://forums.netbeans.org/viewtopic....
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-05 16:04 UTC by nite
Modified: 2010-09-23 08:08 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nite 2009-01-05 16:04:32 UTC
Hi,
i am experiencing the following problem:
When i right-click on a, for example, JButton inside the GUI designer and i choose "Events->(for
example)->"Action"->"actionPerformed" i am prompted inside the code, with the handler for the event already declared.
The problem is that i would like to choose custom names for events handlers methods, or choose already existing methods.

If i try to get inside the "Properties" of the JButton, in the "Events" tab, if i try to type the name of an already
existing method to handle the event, netbeans will create another empty method with the same name, ignoring the already
existing one. (and that will of course result in an error).

The only way to achieve what i'm looking for, is apparently to write the ActionListener by myself, with the "Customize
code" option.
But the problem of this solution is that netbeans will not recognize it, and if i will right-click on the component, in
the "Events" section, no event will be marked as handled (and this function is very useful to jump directly to the handler).

I hope i managed to clearly explain my problem.

Thanks in advance for any help!

Nite.
Comment 1 Petr Dvorak 2009-01-05 17:12:29 UTC
Reassigning to "form" for evaluation...
Comment 2 Tomas Pavek 2009-01-05 17:34:46 UTC
The GUI builder currently does not allow to use a custom method as an event handler directly. It is required the event
handler method is generated by the GUI builder as a guarded code (for consistency - because the call is also in guarded
code, so it can't be deleted by the user). Perhaps we could allow using user methods directly. We have similar
enhancements in issue 25010 and issue 104134.

There is a possible workaround, slightly less comfortable but fully working: let the GUI builder generate its event
handler and then call your method from it.