Skip to content

Swing designer automatically removes enum references in components #6989

@mflydahl

Description

@mflydahl

Apache NetBeans version

Apache NetBeans 20

What happened

When opening a project in the designer with generated code from an old NetBeans-version, the designer will automatically change path to enums with the actual plain text value from the enum. This means that future updates in the enum will not be likewise updated in the swing component.

I've seen this behavior in setText() and setToolTipText(). See reproduction details.

Language / Project Type / NetBeans Component

No response

How to reproduce

  1. Open class, which contains the following generated code (or equivalent):
    avtaleKnapp.setText(ProgramEnum.AVTALEVEDL.getDescription()); avtaleKnapp.setToolTipText(ProgramEnum.AVTALEVEDL.getTooltip());

  2. Save the class again, and the enum reference has been replaced with the string value from the enum:
    avtaleKnapp.setText("Agreement"); avtaleKnapp.setToolTipText("Agreement");

Did this work correctly in an earlier version?

Apache NetBeans 16 or earlier

Operating System

Ubuntu 20.04

JDK

11

Apache NetBeans packaging

Apache NetBeans Snap Package

Anything else

Probably everytime, but I have not been able to try more than once. This happened when opening an old project in the designer to remove deprecations. Didn't notice that the enum references had been replaced with the plain text value until I created a pull request.

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Contribution welcomeAn issue or feature not currently being worked on, but a contribution would be welcomed!FormDesignerGUI builder, also known as Matissekind:bugBug report or fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions