Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
juersimon opened this issue Feb 9, 2024 · 0 comments · Fixed by #7864
Labels
FormDesigner GUI builder, also known as Matisse Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix

Comments

@juersimon
Copy link

juersimon commented Feb 9, 2024

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

@juersimon juersimon added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Feb 9, 2024
@mbien mbien added FormDesigner GUI builder, also known as Matisse Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Contribution welcome An issue or feature not currently being worked on, but a contribution would be welcomed! and removed needs:triage Requires attention from one of the committers labels Feb 10, 2024
@mbien mbien removed the Contribution welcome An issue or feature not currently being worked on, but a contribution would be welcomed! label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FormDesigner GUI builder, also known as Matisse Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants