1

In Netbeans when I make a dozen changes that break more than they fix, usually I find the culprit right away by looking at the history, find the culprit, fix it, and go on my merry way. Takes very little time.

But often I find that Netbeans shows nearly 100 changes. Almost all of them involve changes like the two pairs of history lines below (older line listed first in each pair):

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          


// </editor-fold>//GEN-END:initComponents
// </editor-fold>            

The vast majority of the changes seem to only occur on statements generated by Swing design.

Why do //GEN-BEGIN:initComponents and //GEN-END:initComponents get added onto lines I didn't change?

What did I do to cause this?

How can I avoid this? (Other than quit using Swing design, which I already have in other projects, but this is an older project that I'm sort of stuck with.)

What can I do to fix it so I can just see the lines I changed?

I went here but it doesn't tell how "You can also remove the //GEN-FIRST and //GEN-LAST to make them editable in Netbeans."

Community
  • 1
  • 1
DSlomer64
  • 4,234
  • 4
  • 53
  • 88
  • 1
    The folded code is regenerated based on properties _each_ time you build. – trashgod Sep 12 '14 at 22:43
  • @trashgod--Please let me make sure I understand: (1) this will happen ONLY to the class files designed in Swing builder AND (2) it will happen to them EVERY time I rebuild the project and so this is (3) just one more reason to avoid Swing builder. Am I right? – DSlomer64 Sep 13 '14 at 11:27
  • @trashgod--One last thought: All I really need to do is just MOVE into a different class file all the modules that COULD be placed elsewhere and make sure include as little as possible likely-to-change logic in the Swing-built class file. Meanwhile, just pan down to look for the blue arrows indicating MY changes, which is still a pain, but I guess it's the price I'll pay until I revamp the UI. – DSlomer64 Sep 13 '14 at 11:31

1 Answers1

5

The folded code is regenerated, based on GUI editor properties, each time you build; the effect you describe is not unexpected. Alter a specific property, e.g. by using the Customize Code… dialog, and see how the generated code changes. While the source code editor can collapse generated code, the history views cannot.

Some mitigation strategies:

  • Limit use of the GUI editor to the relatively small number of enclosing containers that really need it, as shown here.

  • Use the History View navigation controls to move among available changes.

  • Identify critical revisions in the Message column of the Diff Viewer pane.

  • Check Options > Team > History settings to match your workflow.

  • Search for History View in the help dialog for additional guidance.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    @trashgod--Thanks for encouraging me to dig deeper into the History area of Netbeans. I'd been using it but not with intelligence. You provided BIG HELP! – DSlomer64 Sep 15 '14 at 09:42