Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18326

Re: Netbeans "form" code is uneditable unless copy/paste into new java file

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From "John B. Matthews" <nospam@nospam.invalid>
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 <nospam-ACF080.01473527082012@news.aioe.org> (permalink)
References <08941df4-43d5-4db8-acad-62149e87263c@googlegroups.com> <k1dpiq$2a1$1@dont-email.me> <k1eq7g$5hg$1@news.albasani.net>
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

Show key headers only | View raw


In article <k1eq7g$5hg$1@news.albasani.net>, Lew <noone@lewscanon.com> 
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:

<http://stackoverflow.com/a/10468877/230513>

Also, add editor-managed panel(s) to a conventional top-level container, 
as shown here:

<http://stackoverflow.com/a/2561540/230513>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Netbeans "form" code is uneditable unless copy/paste into new java file clusardi2k@aol.com - 2012-08-26 07:44 -0700
  Re: Netbeans "form" code is uneditable unless copy/paste into new java file Arne Vajhøj <arne@vajhoej.dk> - 2012-08-26 10:50 -0400
  Re: Netbeans "form" code is uneditable unless copy/paste into new java file markspace <-@.> - 2012-08-26 11:23 -0700
    Re: Netbeans "form" code is uneditable unless copy/paste into new java file Lew <noone@lewscanon.com> - 2012-08-26 20:40 -0700
      Re: Netbeans "form" code is uneditable unless copy/paste into new java file "John B. Matthews" <nospam@nospam.invalid> - 2012-08-27 01:47 -0400
  Re: Netbeans "form" code is uneditable unless copy/paste into new java file "John B. Matthews" <nospam@nospam.invalid> - 2012-08-26 14:54 -0400
  Re: Netbeans "form" code is uneditable unless copy/paste into new java file Nigel Wade <nmw@ion.le.ac.uk> - 2012-09-03 10:39 +0100

csiph-web