apache / apache/netbeans

Swing designer automatically removes enum references in components

Open
#6,989 2 comments 0 reactions 0 assignees View on GitHub
Contribution welcome FormDesigner kind:bug
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in the Swing designer with the generated setText() and setToolTipText() calls shown in the report, using an older-version project opened in NetBeans 20. Trace where the designer reads and rewrites these generated properties. Done means enum-based expressions remain references after saving, rather than being replaced with plain text values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.