netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

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

Open Rizky92 opened this issue 1 year ago • 0 comments

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 image

Trying to select the property will result an unknown error image

The generated code produces null values for them instead, which is supposedly incorrect.

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
    }// </editor-fold>//GEN-END:initComponents

The workaround is to edit the problematic line and add the property manually using custom code.

- 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

Rizky92 avatar Oct 03 '24 03:10 Rizky92