Skip to content

The GUI Builder produces code for boxed primitive properties that is deprecated for removal #7049

Closed

Description

@juersimon

Apache NetBeans version

Apache NetBeans 20

What happened

When a JComponent has a property of type Long (not long) and a value is entered using the properties editor, the GUI Designer creates:
component.setProperty(new java.lang.Long(123L));
Since the Long(long) constructor is deprecated for removal and manual boxing is not required, the following code should be generated instead:
component.setProperty(123L);
This happens for all boxed primitive values except Boolean.
Furthermore, it is not possible to set a value to null using the Properties Editor. This also applies to Boolean.

Language / Project Type / NetBeans Component

Java

How to reproduce

  1. Create a JComponent that contains a property of type Long, Integer, etc.
public class TextField extends JTextField {
    
    private Long val1 = 123L;

    public Long getVal1() {
        return val1;
    }

    public void setVal1(Long val1) {
        this.val1 = val1;
    }
}
  1. Create a new container (JPanel, JDialog etc.) using the GUI Designer and add this component to the container.
  2. Change the value of val1 using the property editor and view the generated code.
  3. Try setting the value of val1 to null using the property editor.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows / Linux

JDK

all since JDK 9

Apache NetBeans packaging

Apache NetBeans provided installer, Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bug
    needs:triage
    on Feb 9, 2024
  2. added
    FormDesigner
    Java
    Contribution welcome
    and removed
    needs:triage
    on Feb 10, 2024
  3. removed
    Contribution welcome
    on Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FormDesignerJavakind:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions