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 56497 - [41cat] The defaultButton property in the Form Editor is always disabled.
Summary: [41cat] The defaultButton property in the Form Editor is always disabled.
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: PC Windows ME/2000
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-16 01:23 UTC by lleland
Modified: 2005-03-17 10:20 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 lleland 2005-03-16 01:23:00 UTC
[ BUILD # : Dev 20050315 ]
[ JDK VERSION : 1.5.0_02 ]

The defaultButton property is always disabled and cannot be set through the Form Editor property window. The defaultCapable property is enabled and can be set, but has no effect on the defaultButton property. You have to use the containing JRootPane to set this property in the source.

This property should be enabled if the component is capable of being a default button in the enclosing JRootPane, and should generate code when set to a value.
Comment 1 Jan Stola 2005-03-16 13:23:39 UTC
JButton doesn't have a setDefaultButton(boolean method). We would have
to create a special support for the requested behaviour.
Changing to enhancement.
See also related issue 12904.
Comment 2 lleland 2005-03-16 19:44:40 UTC
I never said that JButton had a setDefaultButton(boolean state) method. I said
that you have to use the containing JRootPane to set the default button. Like so:
  jButton1.getRootPane().setDefaultButton(jButton1);

The fact that the DefaultButton property exists for JButtons in NetBeans, and
that it does not work, is definitely a bug. However, it seems a mistake to
create the property to begin with. The property does not properly present the
concept that only one of a set of JButtons contained by a JRootPane can be the
default button.

It would probably be better to eliminate the per JButton defaultButton property,
and implement a list box property for JRootPane-using components (see JRootPane
JavaDoc) that lists all of the JButtons known by the Form Editor to be contained
by that JRootPane and that have the defaultCapable property set to true, and
allows you to choose one as the initial default button.

If that makes sense, then this issue would be a defect that calls for the
elimination of the per JButton defaultButton property, and issue #12904 can be
updated about the eventual implementation of the list box default button
property for any JRootPane-using component.
Comment 3 Jan Stola 2005-03-17 10:20:36 UTC
I agree that there shouldn't be a defaultButton property for JButton.
I even already considered removal of this property. And now, reading your
opinion, I have finally decided to remove it. So, marking this issue
as fixed (according to your suggestion).
Feel free to update issue 12904 with your comments.

Just one note at the end - the properties of individual components are
not determined by NetBeans (or at least not primarily). The form editor
is based on JavaBeans specification. So, we use BeanInfos of the components
to find information about their properties. For example: BeanInfo of JButton
contains information about read-only property defaultButton.
So, the root of the problem lies in Swing: the defaultButton is not a property
of JButton, but of the JRootPane (as you correctly noted). And as such it
shouldn't be mentioned by JButtonBeanInfo. There is unfortunately a lot of
things like this which forces us to implement various kinds of
workarounds/hacks :-( to make the GUI builder user-friendly.