Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From JFrame to JPanel in Netbeans

I'm rethinking the design of my GUI. I designed a few JFrame with Netbeans automated GUI (yes, I'm lazy, and this generated code is often awful, I know !), but now I want them to be JPanel (actually, to inherit from another class that inherits JPanel). But I had the "setDefaultCloseOperation" modified, so my code is broken : setDefaultCloseOperation is impossible for a JPanel. Since I can't modify the generated code, I was wondering : is there a way to make Netbeans understand I changed my mind, and regenerate the code ?

like image 376
Raveline Avatar asked Dec 02 '10 19:12

Raveline


2 Answers

When I run into this (I've done the same thing before) I usually end up having to modify the generated code XML file (.form file) or just copying all of the controls I've added and paste into a new JPanel. Just my $0.02 but beware that this can break your code...

like image 64
Merky Avatar answered Oct 17 '22 20:10

Merky


IMHO, nb won't manage automatic refactoring in this case; it's easier to add new panel and copy-paste all elements from Your old JFrame (their methods will be copied as well).

like image 40
barti_ddu Avatar answered Oct 17 '22 21:10

barti_ddu