user241426
user241426

Reputation: 77

Netbeans GUI Form corrupted?

I was making a java gui application through netbeans IDE. All was working fine but yesterday when I opened the form in Netbeans, it said that the form had been corrupted and it could only open that form in read-only mode.

When I opened that form in read-only mode, I found that the code was incomplete as severals lines of coding wasn't there at the end.

Could anybody tell me how to recover the form. The form is perfect in lookwise but the generated code is incomplete.

The code is too long to write it again.

The Netbeans told me to get help from http://wiki.netbeans.org/FormGuardedBlockError but I didn't find any helpful information there.

Upvotes: 3

Views: 8149

Answers (5)

JRichardsz
JRichardsz

Reputation: 16495

This worked for me:

Basically add the special comments on initComponents()

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    ...
}// </editor-fold>//GEN-END:initComponents

and Variables declaration block

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
....
private javax.swing.JButton jButton2;
// End of variables declaration//GEN-END:variables

After that my netbeans shook and the design view appear.

It should be noted that after the success netbeans GUI detection, special comments were automatically deleted

//GEN-BEGIN  //GEN-END

source

http://wiki.netbeans.org/FormGuardedBlockError

Upvotes: 2

I got the same problem and I fixed it . I hope it works

I fixed it by Click --> team(At menubar netbean) --> History --> show History
and then you 'll see your last version that doesn't contain the problem , finally you click right and reverse to previous vision .

Upvotes: 1

Moein
Moein

Reputation: 749

I have a same problem, It seems the only way is using Restore From SVN/CVS/LocalHistory !!! That's so bad :(

Upvotes: 0

Jason Nichols
Jason Nichols

Reputation: 11733

I run into this at times and it drives me crazy. Often the issue isn't in the complaining form, but a dependency used by that form!

The most common gotcha that I see is when form dependencies (other forms being used by a bigger form) throw exceptions within the GUI builder. Remember, NetBeans is instantiating the forms when used by other forms, it usually invokes a parameterless constructor.

If the parameterless constructor in a sub form throws an exception, you may not know about it until your master form is instantiated (depending on what you do with the subform from your master form code).

I know that's a bit wordy, but I hope it helps!

Upvotes: 0

Paul Sasik
Paul Sasik

Reputation: 81429

Have you tried select all on the readonly form, copy and paste to a new form? That might regenerate your lost code.

btw, this is exactly the kind of common scenario programmers hedge against when they write code. i have used half a dozen UI designers at least and they have ALL given me this problem. But since i use SVN all i had to do was delete the corruption and do and update... all my lost work came back.

Upvotes: 1

Related Questions