apache / apache/netbeans

TitledBorder do not have the correct properties displayed in form editor.

Open
#7,824 0 comments 0 reactions 0 assignees View on GitHub
kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 23

### What happened

When editing a swing form, applying a JInternalFrame with TitledBorder generated incorrect properties. A closer look on provided properties shows that these 2 properties do not have a value assigned to them.
![image](https://github.com/user-attachments/assets/3eb65c90-84d9-45e0-b254-775c466e56b0)
![image](https://github.com/user-attachments/assets/a4110e66-0224-43d8-a499-429375b4b77b)

Trying to select the property will result an unknown error
![image](https://github.com/user-attachments/assets/0aad0875-db44-4edb-b9d9-bbd6d27cb857)

The generated code produces null values for them instead, which is supposedly incorrect.
```java
// //GEN-BEGIN:initComponents
private void initComponents() {

jInternalFrame1 = new javax.swing.JInternalFrame();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jInternalFrame1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Actions.Grey"), null), "asdf", null, null, new java.awt.Font("Arial Narrow", 0, 14))); // NOI18N
jInternalFrame1.setVisible(true);

javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(280, Short.MAX_VALUE)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(92, 92, 92))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(122, Short.MAX_VALUE))
);

pack();
}// //GEN-END:initComponents
```

The workaround is to edit the problematic line and add the property manually using custom code.
```diff
- jInternalFrame1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Actions.Grey"), null), "asdf", null, null, new java.awt.Font("Arial Narrow", 0, 14))); // NOI18N
+ jInternalFrame1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Actions.Grey"), 1), "asdf", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Narrow", 0, 14))); // NOI18N
```

### Language / Project Type / NetBeans Component

Java ant project

### How to reproduce

- Create a new project
- Create a new JDialog form
- Add JInternalFrame and apply the border using TitledBorder
- Try to apply titleJustification and titlePosition, both do not have any values.

### Did this work correctly in an earlier version?

Apache NetBeans 22

### Operating System

Windows 10

### JDK

openjdk 17.0.11 2024-04-16 LTS OpenJDK Runtime Environment (build 17.0.11+12-LTS) OpenJDK 64-Bit Server VM (build 17.0.11+12-LTS, mixed mode, sharing)

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by reproducing the issue in the Swing form editor with a JInternalFrame and TitledBorder, then trace how titleJustification and titlePosition are displayed and emitted in the generated initializer. Done means both properties show values and generated code no longer emits null for them.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.