This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 4788 - Pre/Post Init code corrupts source
Summary: Pre/Post Init code corrupts source
Status: CLOSED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: All All
: P4 normal (vote)
Assignee: _ tboudreau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-11-26 19:53 UTC by _ tboudreau
Modified: 2003-07-02 15:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 1999-11-26 19:53:13 UTC
The possibility for Pre/Post Init/Creation code is a greate feature to
keep the code where it should be. BUT: If you edit more than one line, wrong
code is generated! To be precise: The line number at which
`//GEN-END:initComponents` is inserted is calculated wrong. It appears to be inserted as much
lines of code later than lines of Pre-Init-code(...) more than one is edited.
Following `//GEN-*` lines appear in the wrong line too.
You see the wrong code in the editor not immediately but the next time you
start f4j.
IF YOU ARE NOT CAREFUL NOW YOU MAY LOOSE PARTS OF YOUR CODE IN THIS
SITUATION!
If you change the Pre-Init-code(...) code immediately back to one or no
line, your code is restored.

In the example attached to this mail I started with a JFrame. Then I added
a JMenuBar. In the Component Inspector I selected the JMenuBar and added
some lines in the property `Post Init Code`. Then you have to save the code
and reopen it (best with another text editor) to see the mistakes.

public class test extends javax.swing.JFrame {


  /** Creates new form test */
  public test() {
    initComponents ();
    pack ();
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the FormEditor.
   */
  private void initComponents () {//GEN-BEGIN:initComponents
    jMenuBar1 = new javax.swing.JMenuBar ();
    jMenu1 = new javax.swing.JMenu ();
    // post init line 1
    // post init line 2
    // post init line 3
    // post init line 4
    // post init line 5

    jMenu1.setText ("Menu");


    jMenuBar1.add (jMenu1);
    addWindowListener (new java.awt.event.WindowAdapter () {
      public void windowClos

[PBUZEK] Problem is editor puts #0d #0d #0a at the end of each line. We could repair it here, but I suggest to resolve it in Editor.
Comment 1 Marek Grummich 2000-07-25 09:29:59 UTC
Priority is changed to P4 (normal).
Comment 2 Marian Mirilovic 2000-12-20 14:44:59 UTC
verified in [boston](1160) and [release31](33)
Comment 3 Quality Engineering 2003-07-02 15:43:47 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.