Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "John B. Matthews" Newsgroups: comp.lang.java.programmer Subject: Re: Netbeans "form" code is uneditable unless copy/paste into new java file Date: Mon, 27 Aug 2012 01:47:35 -0400 Organization: The Wasteland Lines: 76 Message-ID: References: <08941df4-43d5-4db8-acad-62149e87263c@googlegroups.com> NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:18326 In article , Lew wrote: > markspace wrote: > > clusardi2k@aol.com wrote: > >> How can I modify the code automatically created by Netbeans. Some > >> of that code appears to be uneditable. > >> > >> Instead, I can copy the code, delete the form file it was in, and > >> paste the code into a new class. But, the form disappears. At this > >> code I have all the code, but I lose the "Design" view entirely. > >> > >> Ok experts, what can I do. > >> > >> The reason I want to do this is the Swing pallet (in design view) > >> doesn't have things that I need such as modal window capabilities > >> (jdialogs), and Jlayer capabilities (for a light box effect). Am I > >> wrong about this. > > > > > > First, don't make JFrames forms. Make JPanels. You can add a > > JPanel to a JDialog. I haven't played with JLayer, but a quick > > read-through of their docs makes it appear that you can reasonably > > expect to add a JPanel to one as well. > > > > Then, when you still need to modify code for you JPanel forms, just > > don't modify the code the IDE generates. There's an > > initComponents() method where all the non-modifiable code goes. > > After initComponents() method is called, put your code there. > > > > MyJPanel() { > > initComponents(); > > ... add your code here... > > } > > > > initComponents() { > > ... can't modify this .. > > } > > > > Likewise, you can just add arbitrary methods to the JPanel to do > > whatever you need. > > > > void changeMyProperty( SomeProperty p ) { > > // ... do stuff... > > jLabel1.setText( p.someString() ); > > jTextField1 = new JTextField(); > > } > > > > // Instance fields added by NetBeans > > private void JLabel jLabel1; > > private void JTextField jTextField1; > > > > > > Basically you have to know Java programming, and then just do the > > obvious thing. But I realize it can be hard to get started > > sometimes, so the above few hints should help you out. > > Apropos of markspace's advice, the NetBeans GUI builder lets you link > your custom methods to the events you want to handle via the > properties pages for your screens. So you wire up those arbitrary > methods to be called by the uneditable parts that MB provides. Best > of both worlds. Exactly; there's a related example here: Also, add editor-managed panel(s) to a conventional top-level container, as shown here: -- John B. Matthews trashgod at gmail dot com